Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/1868 #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ For older changes see the [archived Singularity change log](https://github.com/a

## Changes for v1.3.x

- Fixed the time discrepancy issue between the host and container, which occurs
when host's timezone is different from container's.

## v1.3.0 - \[2024-03-12\]

Changes since v1.2.5
Expand Down
1 change: 1 addition & 0 deletions e2e/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3063,5 +3063,6 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests {
"invalidRemote": np(c.invalidRemote), // GHSA-5mv9-q7fq-9394
"fakeroot home": c.actionFakerootHome, // test home dir in fakeroot
"relWorkdirScratch": np(c.relWorkdirScratch), // test relative --workdir with --scratch
"issue 1868": c.issue1868, // https://github.com/apptainer/apptainer/issues/1868
}
}
14 changes: 14 additions & 0 deletions e2e/actions/regressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,17 @@ func (c actionTests) issue1848(t *testing.T) {
),
)
}

// Verify whether the time discrepancy issue gets resolved
// see: https://github.com/apptainer/apptainer/issues/1868
func (c actionTests) issue1868(t *testing.T) {
c.env.RunApptainer(
t,
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("exec"),
e2e.WithArgs("docker://centos:7", "bash", "-c", "TZ=UTC date --date 2020-01-01T12:00:00 +%s"),
e2e.ExpectExit(0,
e2e.ExpectOutput(e2e.ExactMatch, "1577880000"),
),
)
}
21 changes: 21 additions & 0 deletions internal/pkg/runtime/engine/apptainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,16 @@ func (c *container) addBindsMount(system *mount.System) error {
}
}
if !skipAllBinds && !slice.ContainsString(skipBinds, localtimePath) {
if c.engine.EngineConfig.GetSessionLayer() == apptainer.OverlayLayer {
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 @@ -1817,6 +1827,17 @@ func (c *container) addBindsMount(system *mount.System) error {
bindOpt := ""
if src == localtimePath || src == hostsPath {
bindOpt = "skip-on-error"
if c.engine.EngineConfig.GetSessionLayer() == apptainer.OverlayLayer {
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
Loading