Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Handle collected transient units in rootless qualification

rcourtman6a45460afff1
diff --git a/scripts/installtests/secure_runtime_rootless_qualification_test.go b/scripts/installtests/secure_runtime_rootless_qualification_test.go
index 3d63fd856b..a90fd6c763 100644
--- a/scripts/installtests/secure_runtime_rootless_qualification_test.go
+++ b/scripts/installtests/secure_runtime_rootless_qualification_test.go
@@ -1081,7 +1081,15 @@ func rootlessQualUserStateClean(d rootlessQualDaemon) bool {
func rootlessQualStopUnit(t *testing.T, unit string) {
t.Helper()
rootlessQualCommand(t, 30*time.Second, "systemctl", "stop", unit)
- rootlessQualCommand(t, 30*time.Second, "systemctl", "reset-failed", unit)
+ resetOutput, resetErr := rootlessQualCommandError(30*time.Second, "systemctl", "reset-failed", unit)
+ if resetErr == nil {
+ return
+ }
+ loadState, stateErr := rootlessQualCommandError(30*time.Second, "systemctl", "show", "--property=LoadState", "--value", unit)
+ if stateErr == nil && strings.TrimSpace(loadState) == "not-found" {
+ return
+ }
+ t.Fatalf("systemctl reset-failed %s: %v\n%s", unit, resetErr, resetOutput)
}
func rootlessQualBestEffortStop(units ...string) {
@@ -1268,6 +1276,37 @@ func TestRootlessQualificationBaselineUsesReportSemanticShape(t *testing.T) {
}
}
+func TestRootlessQualificationStopAcceptsCollectedTransientUnit(t *testing.T) {
+ tempDir := t.TempDir()
+ logPath := filepath.Join(tempDir, "systemctl.log")
+ systemctlPath := filepath.Join(tempDir, "systemctl")
+ script := `#!/bin/sh
+printf '%s\n' "$*" >>"$ROOTLESS_QUAL_SYSTEMCTL_LOG"
+case "$1" in
+ stop) exit 0 ;;
+ reset-failed) echo 'Unit is not loaded.' >&2; exit 1 ;;
+ show) echo 'not-found'; exit 0 ;;
+esac
+exit 2
+`
+ if err := os.WriteFile(systemctlPath, []byte(script), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ t.Setenv("ROOTLESS_QUAL_SYSTEMCTL_LOG", logPath)
+ t.Setenv("PATH", tempDir+string(os.PathListSeparator)+os.Getenv("PATH"))
+ rootlessQualStopUnit(t, "pulse-rootless-docker")
+ logText := string(rootlessQualReadFile(t, logPath))
+ for _, command := range []string{
+ "stop pulse-rootless-docker",
+ "reset-failed pulse-rootless-docker",
+ "show --property=LoadState --value pulse-rootless-docker",
+ } {
+ if !strings.Contains(logText, command) {
+ t.Fatalf("systemctl lifecycle did not execute %q: %s", command, logText)
+ }
+ }
+}
+
func TestRootlessQualificationGoSchemaPassesPythonValidator(t *testing.T) {
commit := strings.Repeat("a", 40)
digest := strings.Repeat("b", 64)