diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b309b036..f40141e8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/e2e/cgroups/cgroups.go b/e2e/cgroups/cgroups.go index 6001e9ca68..2f1a6f33a6 100644 --- a/e2e/cgroups/cgroups.go +++ b/e2e/cgroups/cgroups.go @@ -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. @@ -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...), ) } @@ -487,6 +488,7 @@ func (c *ctx) instanceDbusXdg(t *testing.T) { name string args []string expectErrorCode int + expectErrorOut string xdgVar string dbusVar string }{ @@ -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", }, } @@ -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) @@ -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 { @@ -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), ) } diff --git a/internal/pkg/cgroups/util.go b/internal/pkg/cgroups/util.go index 244ba39407..efb7985feb 100644 --- a/internal/pkg/cgroups/util.go +++ b/internal/pkg/cgroups/util.go @@ -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. @@ -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.") } } diff --git a/internal/pkg/runtime/launcher/native/launcher_linux.go b/internal/pkg/runtime/launcher/native/launcher_linux.go index 68b9127625..08b86d36e0 100644 --- a/internal/pkg/runtime/launcher/native/launcher_linux.go +++ b/internal/pkg/runtime/launcher/native/launcher_linux.go @@ -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. @@ -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)) } }