Skip to content

Commit

Permalink
second solution
Browse files Browse the repository at this point in the history
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
  • Loading branch information
JasonYangShadow committed Mar 18, 2024
1 parent 13f4e0b commit 8da5f2a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/pkg/runtime/engine/apptainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,6 @@ func create(ctx context.Context, engine *EngineOperations, rpcOps *client.RPC, p
if err := system.RunAfterTag(mount.SharedTag, c.chdirFinal); err != nil {
return err
}
if err := system.RunBeforeTag(mount.LayerTag, c.unsymlinkLocatime); err != nil {
return err
}

if err := c.addRootfsMount(system); err != nil {
return err
Expand Down Expand Up @@ -1819,6 +1816,13 @@ func (c *container) addBindsMount(system *mount.System) error {
}
}
if !skipAllBinds && !slice.ContainsString(skipBinds, localtimePath) {
content, err := os.ReadFile(localtimePath)
if err != nil {
return fmt.Errorf("while reading host %s, err: %s", localtimePath, err)
}
if err := c.session.AddFile(filepath.Join(c.session.Layer.Dir(), localtimePath), content); err != nil {
return err
}
if err := system.Points.AddBind(mount.BindsTag, localtimePath, localtimePath, flags, "skip-on-error"); err != nil {
return fmt.Errorf("unable to add %s to mount list: %s", localtimePath, err)
}
Expand Down Expand Up @@ -1850,6 +1854,15 @@ func (c *container) addBindsMount(system *mount.System) error {
bindOpt := ""
if src == localtimePath || src == hostsPath {
bindOpt = "skip-on-error"
if src == localtimePath {
content, err := os.ReadFile(localtimePath)
if err != nil {
return fmt.Errorf("while reading host %s, err: %s", localtimePath, err)
}
if err := c.session.AddFile(filepath.Join(c.session.Layer.Dir(), localtimePath), content); err != nil {
return err
}
}
}

err := system.Points.AddBind(mount.BindsTag, src, dst, flags, bindOpt)
Expand Down

0 comments on commit 8da5f2a

Please sign in to comment.