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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Make action runner authority state crash-safe
rcourtmaned6f4296745f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 662c62fcf7..2713271dfa 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -146,7 +146,24 @@ registration does not wait for the collector's first-report identity file;the private identity file remains the compatibility fallback for installswhose ID is generated later. That direct binding is authoritative for runnerstartup, activation health, and self-revocation even if a stale collector-identity file is present. Issuance and every runner boundary use the same+identity file is present. Before any runner restart or activation attempt, the+installer replaces both the root-only bearer file and the root-owned+environment through same-filesystem temporary files, synchronizes each file,+renames it atomically, and synchronizes the containing directory. An existing+unit is disabled and runtime-masked before either live file changes, while its+already-running predecessor may continue with its in-memory credential until+the final restart. The mask prevents `Restart=on-failure` from reopening mixed+on-disk state during that interval; disabling preserves the same fail-closed+posture across a reboot, where the runtime mask no longer exists.+A staging, identity, or sync failure cannot truncate a live file or make mixed+on-disk authority state bootable. Readiness failure re-establishes the+stop/disable/runtime-mask fence and requires an authoritative inactive-state+check before classification or rewrite. Stop failure or a still-active process+retains every backup and never restores predecessor files beneath that process.+Indeterminate activation recovery may unmask and re-enable the runner only+after rebuilding and durably committing both files; otherwise it leaves the+unit masked, disabled, and backed up.+Issuance and every runner boundary use the samebounded action-identity vocabulary. Credentialrotation is a prepare/commit transaction. Issuance stores a ten-minute pendingreplacement beside the active predecessor; the pending transport may registerdiff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 1fe8c1e11e..4665f171b9 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -150,7 +150,21 @@ The same supported Linux systemd profile can install `pulse-agent-runner` onlythrough the separate `--enable-action-runner` choice, a private token file,and the already selected typed helper profile. The runner binary, unit,configuration, credential, health record, and receipt database are root-owned-and independent from collector state. Activation is transactional: the server+and independent from collector state. Before any restart or activation, the+installer stages the bearer and environment on the same root-owned filesystem,+synchronizes the complete temporary file, atomically renames it into place,+and synchronizes the containing directory. It disables and runtime-masks an+existing unit before either file changes, without interrupting the+already-running predecessor, and unmask/re-enables it only after both files are+durably complete. The runtime mask suppresses `Restart=on-failure` during the+transaction; persistent disablement keeps it closed after reboot. A write, ownership,+identity, sync, or rename failure cannot expose a partially written live file+or make mixed authority state bootable. Indeterminate recovery must rebuild+both files before re-enable, and readiness failure re-establishes the+stop/disable/runtime-mask fence plus an authoritative inactive-state check+before classification or rewrite. Stop failure or a still-active process never+restores predecessor files beneath that process. Failure leaves the unit+masked, disabled, and backed up. Activation is transactional: the serverkeeps the prior credential valid while a bounded replacement registers withoutdispatch authority in a separate pending session slot. Pending reconnects canreplace only that slot and cannot evict or interrupt the active dispatchdiff --git a/scripts/install.sh b/scripts/install.shindex b79205ff3c..b7e5fd24d7 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -1395,6 +1395,10 @@ EOFwrite_action_runner_config() {local runner_hostname="$HOSTNAME_OVERRIDE"local runner_agent_id=""+ local runner_env_target="$ACTION_RUNNER_ENV_FILE"+ local ACTION_RUNNER_ENV_FILE="$runner_env_target"+ local runner_env_tmp=""+ local old_umask=""if [[ -L "$ACTION_RUNNER_CONFIG_DIR" || -L "$ACTION_RUNNER_STATE_DIR" ||-L "$ACTION_RUNNER_TOKEN_FILE" || -L "$ACTION_RUNNER_ENV_FILE" ]]; thenfail "Refusing unsafe symlink in the action-runner config or state boundary" "$EXIT_GENERAL"@@ -1409,7 +1413,8 @@ write_action_runner_config() {fiif [[ -n "$ACTION_TOKEN" ]]; then- printf '%s\n' "$ACTION_TOKEN" > "$ACTION_RUNNER_TOKEN_FILE"+ persist_action_runner_replacement_token "$ACTION_TOKEN" ||+ fail "Could not atomically persist the action-runner credential" "$EXIT_GENERAL"elif [[ ! -s "$ACTION_RUNNER_TOKEN_FILE" ]]; thenfail "--enable-action-runner requires a separate --action-token-file on first install" "$EXIT_MISSING_ARGS"fi@@ -1428,7 +1433,14 @@ write_action_runner_config() {fail "Action runner requires a safely resolved canonical collector identity" "$EXIT_MISSING_ARGS"AGENT_ID="$runner_agent_id"- : > "$ACTION_RUNNER_ENV_FILE"+ old_umask=$(umask)+ umask 077+ runner_env_tmp=$(mktemp "${ACTION_RUNNER_CONFIG_DIR%/}/.runner-env.XXXXXX") || {+ umask "$old_umask"+ fail "Could not stage the action-runner environment" "$EXIT_GENERAL"+ }+ umask "$old_umask"+ ACTION_RUNNER_ENV_FILE="$runner_env_tmp"chmod 0600 "$ACTION_RUNNER_ENV_FILE"write_action_runner_env_value "PULSE_URL" "$PULSE_URL"write_action_runner_env_value "PULSE_AGENT_RUNNER_TOKEN_FILE" "$ACTION_RUNNER_TOKEN_FILE"@@ -1447,6 +1459,13 @@ write_action_runner_config() {write_action_runner_env_value "PULSE_INSECURE" "true"fichown root:root "$ACTION_RUNNER_ENV_FILE"+ if ! sync -f "$ACTION_RUNNER_ENV_FILE" ||+ ! mv -f "$ACTION_RUNNER_ENV_FILE" "$runner_env_target" ||+ ! sync -f "$ACTION_RUNNER_CONFIG_DIR"; then+ rm -f "$runner_env_tmp"+ fail "Could not atomically persist the action-runner environment" "$EXIT_GENERAL"+ fi+ ACTION_RUNNER_ENV_FILE="$runner_env_target"}generate_action_runner_activation_nonce() {@@ -1647,6 +1666,7 @@ provision_action_runner() {local replacement_action_token=""local expected_agent_id=""local expected_hostname="$HOSTNAME_OVERRIDE"+ local runner_stop_succeeded="false"if [[ -n "$ACTION_TOKEN" ]]; thencredential_replacement_requested="true"@@ -1677,6 +1697,10 @@ provision_action_runner() {ACTION_RUNNER_ACTIVATION_NONCE="$activation_nonce"if (set -e+ if [[ "$had_unit" == "true" ]]; then+ systemctl disable "${ACTION_RUNNER_NAME}.service"+ systemctl mask --runtime "${ACTION_RUNNER_NAME}.service"+ firm -f "$ACTION_RUNNER_HEALTH_FILE"mkdir -p "$PRIVILEGE_HELPER_DIR"install -o root -g root -m 0755 "$TMP_ACTION_RUNNER_BIN" "${ACTION_RUNNER_BINARY_PATH}.new"@@ -1687,6 +1711,7 @@ provision_action_runner() {chown root:root "${ACTION_RUNNER_SERVICE_UNIT}.new"chmod 0644 "${ACTION_RUNNER_SERVICE_UNIT}.new"mv "${ACTION_RUNNER_SERVICE_UNIT}.new" "$ACTION_RUNNER_SERVICE_UNIT"+ systemctl unmask --runtime "${ACTION_RUNNER_NAME}.service"systemctl daemon-reloadaction_runner_verify_effective_targetsystemctl enable "${ACTION_RUNNER_NAME}.service"@@ -1712,17 +1737,33 @@ provision_action_runner() {fiif [[ "$runner_active" != "true" ]]; then- systemctl stop "${ACTION_RUNNER_NAME}.service" 2>/dev/null || true+ if systemctl stop "${ACTION_RUNNER_NAME}.service" 2>/dev/null; then+ runner_stop_succeeded="true"+ fi+ if ! systemctl disable "${ACTION_RUNNER_NAME}.service" 2>/dev/null ||+ ! systemctl mask --runtime "${ACTION_RUNNER_NAME}.service" 2>/dev/null; then+ ACTION_RUNNER_ACTIVATION_NONCE=""+ fail "Action runner recovery could not fence automatic restart; the runner was stopped and local recovery material was retained" "$EXIT_GENERAL"+ fi+ if [[ "$runner_stop_succeeded" != "true" ]] ||+ systemctl is-active --quiet "${ACTION_RUNNER_NAME}.service" 2>/dev/null; then+ ACTION_RUNNER_ACTIVATION_NONCE=""+ fail "Action runner recovery could not confirm the replacement is inactive; the unit remains masked and disabled, and every local recovery artifact was retained" "$EXIT_GENERAL"+ fiif [[ "$credential_replacement_requested" == "true" ]]; thenexpected_agent_id=$(resolve_action_runner_agent_id || true)if ! cancel_pending_action_runner_credential "$expected_agent_id" "$expected_hostname" "$replacement_action_token"; thenlog_error "The server did not durably confirm cancellation of the pending action-runner credential. The predecessor cannot be restored because activation may already be committed."- if ! persist_action_runner_replacement_token "$replacement_action_token"; then+ if ! (+ ACTION_TOKEN="$replacement_action_token"+ write_action_runner_config+ ); thenreplacement_action_token=""- log_error "Could not durably persist the exact replacement action-runner credential. The runner remains stopped, the predecessor was not restored, and action-runner re-enrollment is required."+ log_error "Could not durably persist the complete replacement action-runner credential and environment. The runner remains disabled, the predecessor was not restored, and action-runner re-enrollment is required."ACTION_RUNNER_ACTIVATION_NONCE=""- fail "Action runner credential recovery requires re-enrollment; no predecessor credential was restored" "$EXIT_GENERAL"+ fail "Action runner authority-state recovery requires re-enrollment; no predecessor credential was restored" "$EXIT_GENERAL"fi+ ACTION_TOKEN=""log_error "The exact replacement credential and runtime were retained durably; repair is required."replacement_action_token=""rm -f "${ACTION_RUNNER_BINARY_PATH}.new" "${ACTION_RUNNER_SERVICE_UNIT}.new"@@ -1732,6 +1773,7 @@ provision_action_runner() {"${ACTION_RUNNER_ENV_FILE}${backup_suffix}" \"${ACTION_RUNNER_TOKEN_FILE}${backup_suffix}"systemctl daemon-reload 2>/dev/null || true+ systemctl unmask --runtime "${ACTION_RUNNER_NAME}.service" 2>/dev/null || truesystemctl enable --now "${ACTION_RUNNER_NAME}.service" 2>/dev/null || trueACTION_RUNNER_ACTIVATION_NONCE=""fail "Action runner activation requires repair; the new credential and runtime were retained and the previous credential was not restored" "$EXIT_GENERAL"@@ -1756,6 +1798,7 @@ provision_action_runner() {fisystemctl daemon-reload 2>/dev/null || trueif [[ "$had_unit" == "true" && "$had_binary" == "true" ]]; then+ systemctl unmask --runtime "${ACTION_RUNNER_NAME}.service" 2>/dev/null || truesystemctl enable --now "${ACTION_RUNNER_NAME}.service" 2>/dev/null || truefiACTION_RUNNER_ACTIVATION_NONCE=""diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.goindex f02bfc3a25..73c61d8ffe 100644--- a/scripts/installtests/install_sh_test.go+++ b/scripts/installtests/install_sh_test.go@@ -5999,7 +5999,8 @@ func TestInstallSHActionRunnerIsSeparateOptInLifecycle(t *testing.T) {`action_runner_health_matches_activation "$expected_agent_id" "$activation_nonce"`,`[[ "$health_agent_id" == "$expected_agent_id" && "$health_activation_nonce" == "$expected_nonce" ]]`,`cancel_pending_action_runner_credential "$expected_agent_id" "$expected_hostname" "$replacement_action_token"`,- `persist_action_runner_replacement_token "$replacement_action_token"`,+ `ACTION_TOKEN="$replacement_action_token"`,+ `Could not durably persist the complete replacement action-runner credential and environment`,`if ! cancel_pending_action_runner_credential`,`The exact replacement credential and runtime were retained durably`,`did not durably confirm cancellation`,@@ -6043,10 +6044,18 @@ EXIT_MISSING_ARGS=2fail() { printf '%s\n' "$1" >&2; exit "$2"; }install() { local destination="${!#}"; mkdir -p "$destination"; chmod 0700 "$destination"; }chown() { return 0; }+stat() {+ case "$1:$2" in+ '-c:%u') printf '0\n' ;;+ '-c:%a') printf '600\n' ;;+ *) command stat "$@" ;;+ esac+}` + extractInstallShellFunction(t, "write_action_runner_env_value") + `` + extractInstallShellFunction(t, "action_runner_url_uses_loopback_http") + `` + extractInstallShellFunction(t, "action_runner_url_transport_allowed") + `` + extractInstallShellFunction(t, "resolve_action_runner_agent_id") + `+` + extractInstallShellFunction(t, "persist_action_runner_replacement_token") + `` + extractInstallShellFunction(t, "write_action_runner_config") + `write_action_runner_config`@@ -6061,6 +6070,129 @@ write_action_runner_configif !strings.Contains(string(content), want) {t.Fatalf("action-runner environment missing immediate identity binding %q:\n%s", want, content)}+ for path, wantMode := range map[string]os.FileMode{+ filepath.Join(root, "config", "token"): 0o600,+ envFile: 0o600,+ } {+ info, statErr := os.Stat(path)+ if statErr != nil {+ t.Fatal(statErr)+ }+ if got := info.Mode().Perm(); got != wantMode {+ t.Fatalf("%s mode = %o, want %o", path, got, wantMode)+ }+ }+}++func TestInstallSHActionRunnerConfigFailureLeavesOnlyCompleteFiles(t *testing.T) {+ for _, test := range []struct {+ name string+ failPattern string+ wantToken string+ wantEnvironment string+ wantDiagnostic string+ }{+ {+ name: "credential sync failure preserves predecessor",+ failPattern: ".replacement-token.",+ wantToken: "old-runner-token\n",+ wantEnvironment: "old-runner-environment\n",+ wantDiagnostic: "atomically persist the action-runner credential",+ },+ {+ name: "environment sync failure preserves complete environment",+ failPattern: ".runner-env.",+ wantToken: "new-runner-token\n",+ wantEnvironment: "old-runner-environment\n",+ wantDiagnostic: "atomically persist the action-runner environment",+ },+ } {+ t.Run(test.name, func(t *testing.T) {+ root := t.TempDir()+ configDir := filepath.Join(root, "config")+ stateDir := filepath.Join(root, "state")+ if err := os.MkdirAll(configDir, 0o700); err != nil {+ t.Fatal(err)+ }+ tokenPath := filepath.Join(configDir, "token")+ envPath := filepath.Join(configDir, "runner.env")+ if err := os.WriteFile(tokenPath, []byte("old-runner-token\n"), 0o600); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(envPath, []byte("old-runner-environment\n"), 0o600); err != nil {+ t.Fatal(err)+ }++ script := `+set -u+ACTION_RUNNER_CONFIG_DIR="` + configDir + `"+ACTION_RUNNER_STATE_DIR="` + stateDir + `"+ACTION_RUNNER_TOKEN_FILE="` + tokenPath + `"+ACTION_RUNNER_ENV_FILE="` + envPath + `"+ACTION_RUNNER_HEALTH_FILE="` + filepath.Join(stateDir, "health.json") + `"+ACTION_RUNNER_ACTIVATION_NONCE="` + strings.Repeat("a", 64) + `"+STATE_DIR="` + filepath.Join(root, "collector") + `"+HOSTNAME_OVERRIDE="secure-runtime.lab"+AGENT_ID="agent-durable"+ACTION_TOKEN="new-runner-token"+PULSE_URL="https://pulse.example"+SERVER_FINGERPRINT=""+CURL_CA_BUNDLE=""+INSECURE="false"+EXIT_GENERAL=1+EXIT_MISSING_ARGS=2+FAIL_PATTERN="` + test.failPattern + `"+fail() { printf '%s\n' "$1" >&2; exit "$2"; }+install() { local destination="${!#}"; mkdir -p "$destination"; chmod 0700 "$destination"; }+chown() { return 0; }+stat() {+ case "$1:$2" in+ '-c:%u') printf '0\n' ;;+ '-c:%a') printf '600\n' ;;+ *) command stat "$@" ;;+ esac+}+sync() {+ if [[ "${2:-}" == *"$FAIL_PATTERN"* ]]; then+ return 1+ fi+ command sync "$@"+}+` + extractInstallShellFunction(t, "write_action_runner_env_value") + `+` + extractInstallShellFunction(t, "action_runner_url_uses_loopback_http") + `+` + extractInstallShellFunction(t, "action_runner_url_transport_allowed") + `+` + extractInstallShellFunction(t, "resolve_action_runner_agent_id") + `+` + extractInstallShellFunction(t, "persist_action_runner_replacement_token") + `+` + extractInstallShellFunction(t, "write_action_runner_config") + `+write_action_runner_config+`+ out, err := exec.Command("bash", "-c", script).CombinedOutput()+ if err == nil || !strings.Contains(string(out), test.wantDiagnostic) {+ t.Fatalf("fault injection did not fail closed: %v\n%s", err, out)+ }+ if strings.Contains(string(out), "new-runner-token") {+ t.Fatalf("credential leaked in failure output: %s", out)+ }+ for path, want := range map[string]string{tokenPath: test.wantToken, envPath: test.wantEnvironment} {+ got, readErr := os.ReadFile(path)+ if readErr != nil {+ t.Fatalf("read %s: %v", path, readErr)+ }+ if string(got) != want {+ t.Fatalf("%s = %q, want complete %q", path, got, want)+ }+ }+ for _, pattern := range []string{".replacement-token.*", ".runner-env.*"} {+ matches, globErr := filepath.Glob(filepath.Join(configDir, pattern))+ if globErr != nil {+ t.Fatal(globErr)+ }+ if len(matches) != 0 {+ t.Fatalf("temporary authority files were retained: %v", matches)+ }+ }+ })+ }}func TestInstallSHActionRunnerRejectsGenericInsecureHTTPSBeforeCredentialWrite(t *testing.T) {@@ -6089,6 +6221,7 @@ install() { local destination="${!#}"; mkdir -p "$destination"; chmod 0700 "$des` + extractInstallShellFunction(t, "write_action_runner_env_value") + `` + extractInstallShellFunction(t, "action_runner_url_uses_loopback_http") + `` + extractInstallShellFunction(t, "action_runner_url_transport_allowed") + `+` + extractInstallShellFunction(t, "persist_action_runner_replacement_token") + `` + extractInstallShellFunction(t, "write_action_runner_config") + `write_action_runner_config`@@ -6158,12 +6291,20 @@ EXIT_MISSING_ARGS=2fail() { printf '%s\n' "$1" >&2; exit "$2"; }install() { local destination="${!#}"; mkdir -p "$destination"; chmod 0700 "$destination"; }chown() { return 0; }+stat() {+ case "$1:$2" in+ '-c:%u') printf '0\n' ;;+ '-c:%a') printf '600\n' ;;+ *) command stat "$@" ;;+ esac+}` + extractInstallShellFunction(t, "collector_lifecycle_binary") + `` + extractInstallShellFunction(t, "read_action_runner_env_value") + `` + extractInstallShellFunction(t, "resolve_action_runner_agent_id") + `` + extractInstallShellFunction(t, "write_action_runner_env_value") + `` + extractInstallShellFunction(t, "action_runner_url_uses_loopback_http") + `` + extractInstallShellFunction(t, "action_runner_url_transport_allowed") + `+` + extractInstallShellFunction(t, "persist_action_runner_replacement_token") + `` + extractInstallShellFunction(t, "write_action_runner_config") + `write_action_runner_configprintf 'attacker-rewrite\n' > "${STATE_DIR}/agent-id"@@ -6279,12 +6420,13 @@ action_runner_health_matches_activation "agent-1" "` + nonce + `"func TestInstallSHActionRunnerPostCommitReadinessFailureRetainsReplacement(t *testing.T) {for _, test := range []struct {- name string- cancelBody string- persistFailure bool- rollback bool- tokenWriteBody string- wantToken string+ name string+ cancelBody string+ recoveryConfigFailure bool+ stopFailure bool+ rollback bool+ tokenWriteBody string+ wantToken string}{{name: "durable pending cancellation authorizes rollback", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 0`, rollback: true,@@ -6295,23 +6437,23 @@ func TestInstallSHActionRunnerPostCommitReadinessFailureRetainsReplacement(t *tetokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",},{- name: "replacement token durable write failure", cancelBody: "return 1", persistFailure: true,+ name: "replacement authority state durable write failure", cancelBody: "return 1", recoveryConfigFailure: true,tokenWriteBody: `: > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "",},+ {+ name: "failed stop retains fenced recovery material", cancelBody: "return 91", stopFailure: true,+ tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ },} {t.Run(test.name, func(t *testing.T) {- testInstallSHActionRunnerReadinessFailureRetainsReplacement(t, test.cancelBody, test.persistFailure, test.rollback, test.tokenWriteBody, test.wantToken)+ testInstallSHActionRunnerReadinessFailureRetainsReplacement(t, test.cancelBody, test.recoveryConfigFailure, test.stopFailure, test.rollback, test.tokenWriteBody, test.wantToken)})}}-func testInstallSHActionRunnerReadinessFailureRetainsReplacement(t *testing.T, cancelBody string, persistFailure, rollback bool, tokenWriteBody, wantToken string) {+func testInstallSHActionRunnerReadinessFailureRetainsReplacement(t *testing.T, cancelBody string, recoveryConfigFailure, stopFailure, rollback bool, tokenWriteBody, wantToken string) {t.Helper()cancelFunction := `cancel_pending_action_runner_credential() { ` + cancelBody + `; }`- persistFunction := extractInstallShellFunction(t, "persist_action_runner_replacement_token")- if persistFailure {- persistFunction = `persist_action_runner_replacement_token() { return 1; }`- }root := t.TempDir()binPath := filepath.Join(root, "bin", "pulse-agent-runner")unitPath := filepath.Join(root, "systemd", "pulse-agent-runner.service")@@ -6351,9 +6493,18 @@ PULSE_URL="http://127.0.0.1:7655"INSECURE="true"CURL_CA_BUNDLE=""EXIT_GENERAL=1+RECOVERY_CONFIG_FAILURE="` + strconv.FormatBool(recoveryConfigFailure) + `"+STOP_FAILURE="` + strconv.FormatBool(stopFailure) + `"+CONFIG_WRITE_MARKER="` + filepath.Join(root, "config-write-marker") + `"+SERVICE_ACTIVE_MARKER="` + filepath.Join(root, "service-active-marker") + `"generate_action_runner_activation_nonce() { printf '%064d\n' 0; }restore_selinux_contexts() { return 0; }write_action_runner_config() {+ printf 'write-config\n' >> "` + serviceLog + `"+ if [[ -e "$CONFIG_WRITE_MARKER" && "$RECOVERY_CONFIG_FAILURE" == "true" ]]; then+ return 1+ fi+ : > "$CONFIG_WRITE_MARKER"` + tokenWriteBody + `printf 'new:env\n' > "$ACTION_RUNNER_ENV_FILE"}@@ -6375,6 +6526,16 @@ stat() {}systemctl() {printf '%s\n' "$*" >> "` + serviceLog + `"+ case "$1" in+ restart) : > "$SERVICE_ACTIVE_MARKER" ;;+ stop)+ if [[ "$STOP_FAILURE" == "true" ]]; then+ return 1+ fi+ rm -f "$SERVICE_ACTIVE_MARKER"+ ;;+ is-active) [[ -e "$SERVICE_ACTIVE_MARKER" ]] ; return ;;+ esacreturn 0}action_runner_health_matches_activation() { return 1; }@@ -6384,7 +6545,6 @@ sleep() { return 0; }log_error() { printf 'ERROR: %s\n' "$1" >&2; }log_info() { printf 'INFO: %s\n' "$1"; }fail() { printf 'FAIL: %s\n' "$1" >&2; exit "$2"; }-` + persistFunction + `` + extractInstallShellFunction(t, "provision_action_runner") + `provision_action_runner`@@ -6396,14 +6556,19 @@ provision_action_runnerif !strings.Contains(string(out), "rolling back runner-only files") || strings.Contains(string(out), "retained durably") {t.Fatalf("204 cancellation did not exclusively authorize predecessor restore:\n%s", out)}- } else if persistFailure {+ } else if stopFailure {+ if !strings.Contains(string(out), "could not confirm the replacement is inactive") ||+ strings.Contains(string(out), "did not durably confirm cancellation") {+ t.Fatalf("failed stop did not retain fenced recovery state before classification:\n%s", out)+ }+ } else if recoveryConfigFailure {if strings.Contains(string(out), "retained durably") || !strings.Contains(string(out), "re-enrollment") {- t.Fatalf("durable token failure did not fail closed for re-enrollment:\n%s", out)+ t.Fatalf("durable authority-state failure did not fail closed for re-enrollment:\n%s", out)}} else if !strings.Contains(string(out), "replacement credential and runtime were retained durably") || !strings.Contains(string(out), "repair") {t.Fatalf("missing repair-required result:\n%s", out)}- if !rollback && !strings.Contains(string(out), "did not durably confirm cancellation") {+ if !rollback && !stopFailure && !strings.Contains(string(out), "did not durably confirm cancellation") {t.Fatalf("missing atomic cancellation diagnostic:\n%s", out)}wantBinary, wantUnit, wantEnv := "new:runner\n", "new:unit\n", "new:env\n"@@ -6428,10 +6593,10 @@ provision_action_runnerif err != nil {t.Fatal(err)}- if persistFailure && len(backups) == 0 {- t.Fatal("durable token failure removed every predecessor backup before repair")+ if (recoveryConfigFailure || stopFailure) && len(backups) == 0 {+ t.Fatal("durable authority-state failure removed every predecessor backup before repair")}- if !persistFailure && len(backups) != 0 {+ if !recoveryConfigFailure && !stopFailure && len(backups) != 0 {t.Fatalf("revoked predecessor backups retained: %v", backups)}serviceCalls, err := os.ReadFile(serviceLog)@@ -6441,12 +6606,27 @@ provision_action_runnerif !strings.Contains(string(serviceCalls), "stop pulse-agent-runner.service") {t.Fatalf("replacement was not stopped before classification: %s", serviceCalls)}- if persistFailure && strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {- t.Fatalf("runner restarted without a durably retained replacement credential: %s", serviceCalls)+ disableAt := strings.Index(string(serviceCalls), "disable pulse-agent-runner.service")+ maskAt := strings.Index(string(serviceCalls), "mask --runtime pulse-agent-runner.service")+ writeAt := strings.Index(string(serviceCalls), "write-config")+ if disableAt < 0 || maskAt < disableAt || writeAt < maskAt {+ t.Fatalf("runner was not disabled and runtime-masked before authority files changed: %s", serviceCalls)+ }+ if (recoveryConfigFailure || stopFailure) && strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {+ t.Fatalf("runner restarted without a complete durable authority state: %s", serviceCalls)}- if !persistFailure && !strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {+ serviceLines := "\n" + string(serviceCalls)+ lastMaskAt := strings.LastIndex(serviceLines, "\nmask --runtime pulse-agent-runner.service")+ lastUnmaskAt := strings.LastIndex(serviceLines, "\nunmask --runtime pulse-agent-runner.service")+ if (recoveryConfigFailure || stopFailure) && lastMaskAt < lastUnmaskAt {+ t.Fatalf("runner remained unmasked without a complete durable authority state: %s", serviceCalls)+ }+ if !recoveryConfigFailure && !stopFailure && !strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {t.Fatalf("replacement was not stopped for classification and restarted for repair: %s", serviceCalls)}+ if !recoveryConfigFailure && !stopFailure && lastUnmaskAt < lastMaskAt {+ t.Fatalf("complete authority state was not unmasked for restart: %s", serviceCalls)+ }}func TestInstallSHActionRunnerAtomicCancelUsesPrivateGoTransportAndRequires204(t *testing.T) {