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

fix: correct instance error messages & xdg var e2e-tests #3506

Merged
merged 1 commit into from
Feb 10, 2025
Merged
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 @@ -6,6 +6,9 @@

- Use correct username (not user's name) when computing `singularity oci` conmon
/ singularity state dir.
- Write StdErr messages from starter to terminal StdErr when an instance fails
to start. Previously incorrectly written to terminal StdOut.
- Fix incorrect debug message in Cgroups checks.

### New Features & Functionality

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ reserved.

Copyright (c) 2017, SingularityWare, LLC. All rights reserved.

Copyright (c) 2018-2024, Sylabs, Inc. All rights reserved.
Copyright (c) 2018-2025, Sylabs, Inc. All rights reserved.

Copyright (c) Contributors to the Apptainer project, established as Apptainer a
Series of LF Projects LLC.
Expand Down
19 changes: 15 additions & 4 deletions e2e/cgroups/cgroups.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022-2024, Sylabs Inc. All rights reserved.
// Copyright (c) 2022-2025, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -467,7 +467,8 @@ func (c *ctx) actionDbusXDG(t *testing.T) {
e2e.WithProfile(profile),
e2e.WithCommand("exec"),
e2e.WithArgs(tt.args...),
e2e.WithEnv(testEnv),
e2e.WithRootlessEnv(), // Apply valid rootless env vars
e2e.WithEnv(testEnv), // Override with invalid values from test
e2e.ExpectExit(tt.expectErrorCode, exitFunc...),
)
}
Expand All @@ -487,6 +488,7 @@ func (c *ctx) instanceDbusXdg(t *testing.T) {
name string
args []string
expectErrorCode int
expectErrorOut string
xdgVar string
dbusVar string
}{
Expand All @@ -506,12 +508,14 @@ func (c *ctx) instanceDbusXdg(t *testing.T) {
name: "bad xdg limits",
args: []string{"--cpus", "1", c.env.ImagePath},
expectErrorCode: 255,
expectErrorOut: "XDG_RUNTIME_DIR",
xdgVar: "/not/a/dir",
},
{
name: "bad dbus limits",
args: []string{"--cpus", "1", c.env.ImagePath},
expectErrorCode: 255,
expectErrorOut: "DBUS_SESSION_BUS_ADDRESS",
dbusVar: "/not/a/dbus/socket",
},
}
Expand All @@ -520,6 +524,11 @@ func (c *ctx) instanceDbusXdg(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
instanceName := randomName(t)

exitFunc := []e2e.SingularityCmdResultOp{}
if tt.expectErrorOut != "" {
exitFunc = []e2e.SingularityCmdResultOp{e2e.ExpectError(e2e.ContainMatch, tt.expectErrorOut)}
}

testEnv := []string{}
if tt.xdgVar != "" {
testEnv = append(testEnv, "XDG_RUNTIME_DIR="+tt.xdgVar)
Expand All @@ -535,8 +544,9 @@ func (c *ctx) instanceDbusXdg(t *testing.T) {
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("instance start"),
e2e.WithArgs(createArgs...),
e2e.WithEnv(testEnv),
e2e.ExpectExit(tt.expectErrorCode),
e2e.WithRootlessEnv(), // Apply valid rootless env vars
e2e.WithEnv(testEnv), // Override with invalid values from test
e2e.ExpectExit(tt.expectErrorCode, exitFunc...),
)

if tt.expectErrorCode == 0 {
Expand All @@ -546,6 +556,7 @@ func (c *ctx) instanceDbusXdg(t *testing.T) {
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("instance stop"),
e2e.WithArgs(instanceName),
e2e.WithRootlessEnv(),
e2e.ExpectExit(0),
)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/cgroups/util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022-2024, Sylabs Inc. All rights reserved.
// Copyright (c) 2022-2025, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -140,7 +140,7 @@ func CanUseCgroups(systemd bool, warn bool) bool {
if warn {
sylog.Warningf("Rootless cgroups require the system to be configured for cgroups v2 in unified mode.")
} else {
sylog.Debugf("Rootless cgroups require 'systemd cgroups' to be enabled in singularity.conf")
sylog.Debugf("Rootless cgroups require the system to be configured for cgroups v2 in unified mode.")
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/runtime/launcher/native/launcher_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2024, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2025, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -1328,7 +1328,7 @@ func (l *Launcher) starterInstance(name string, useSuid bool) error {
if end-start > 0 {
output := make([]byte, end-start)
stderr.ReadAt(output, start)
fmt.Println(string(output))
fmt.Fprintln(os.Stderr, string(output))
}
}

Expand Down