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.

Restore Windows native agent verification

pulse-triage[bot]184b3cbfa6b8
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 2594ca4822..c4a049500e 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -84,6 +84,11 @@ credential self-revoke before deleting local state. The delete route may
remove only the caller's exact host-bound action-runner record; an unreachable
server cannot prevent local runner removal and leaves an explicit operator
revocation residual.
+Runner readiness is exposed through a bounded, secret-free health marker that
+is replaced atomically only after its contents reach stable storage. POSIX
+targets must sync the containing directory after rename; Windows targets must
+use a write-through replacement rather than attempting to flush the read-only
+directory handle returned by the standard library.
Fresh installs carry an explicit local command-authority profile. The closed
values are `monitoring-only`, `command-capable`, and `legacy`. A
`monitoring-only` service may accept remote configuration that keeps commands
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 9126759559..653be4225c 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1402,7 +1402,10 @@
],
"match_files": [
"cmd/pulse-agent-runner/main.go",
- "internal/dockeragent/action_runtime.go"
+ "internal/dockeragent/action_runtime.go",
+ "internal/hostagent/action_runner_client.go",
+ "internal/hostagent/action_runner_health_persistence_unix.go",
+ "internal/hostagent/action_runner_health_persistence_windows.go"
],
"allow_same_subsystem_tests": true,
"test_prefixes": [
diff --git a/internal/hostagent/action_runner_client.go b/internal/hostagent/action_runner_client.go
index 4b7492aced..450c3bc284 100644
--- a/internal/hostagent/action_runner_client.go
+++ b/internal/hostagent/action_runner_client.go
@@ -127,13 +127,8 @@ func (c *CommandClient) writeActionRunnerHealth() error {
if err := temp.Close(); err != nil {
return err
}
- if err := os.Rename(tempPath, c.healthPath); err != nil {
+ if err := replaceActionRunnerHealthFile(tempPath, c.healthPath); err != nil {
return err
}
- directory, err := os.Open(dir)
- if err != nil {
- return err
- }
- defer directory.Close()
- return directory.Sync()
+ return syncActionRunnerHealthDirectory(dir)
}
diff --git a/internal/hostagent/action_runner_client_test.go b/internal/hostagent/action_runner_client_test.go
index ae1762a9c3..62c57ae63f 100644
--- a/internal/hostagent/action_runner_client_test.go
+++ b/internal/hostagent/action_runner_client_test.go
@@ -97,6 +97,9 @@ func TestActionRunnerHealthIsAtomicBoundedAndSecretFree(t *testing.T) {
StateDir: filepath.Join(dir, "state"), HealthPath: healthPath, Logger: &logger,
}, "agent-1", "host-1", "v1")
t.Cleanup(func() { _ = client.Close() })
+ if err := os.WriteFile(healthPath, []byte("stale-health-marker"), 0600); err != nil {
+ t.Fatal(err)
+ }
if err := client.writeActionRunnerHealth(); err != nil {
t.Fatal(err)
}
diff --git a/internal/hostagent/action_runner_health_persistence_unix.go b/internal/hostagent/action_runner_health_persistence_unix.go
new file mode 100644
index 0000000000..b0d4e5e75a
--- /dev/null
+++ b/internal/hostagent/action_runner_health_persistence_unix.go
@@ -0,0 +1,30 @@
+//go:build !windows
+
+package hostagent
+
+import (
+ "fmt"
+ "os"
+)
+
+func replaceActionRunnerHealthFile(from, to string) error {
+ if err := os.Rename(from, to); err != nil {
+ return fmt.Errorf("replace action-runner health marker: %w", err)
+ }
+ return nil
+}
+
+func syncActionRunnerHealthDirectory(path string) error {
+ directory, err := os.Open(path)
+ if err != nil {
+ return fmt.Errorf("open action-runner health directory for sync: %w", err)
+ }
+ if err := directory.Sync(); err != nil {
+ _ = directory.Close()
+ return fmt.Errorf("sync action-runner health directory: %w", err)
+ }
+ if err := directory.Close(); err != nil {
+ return fmt.Errorf("close action-runner health directory after sync: %w", err)
+ }
+ return nil
+}
diff --git a/internal/hostagent/action_runner_health_persistence_windows.go b/internal/hostagent/action_runner_health_persistence_windows.go
new file mode 100644
index 0000000000..5656046646
--- /dev/null
+++ b/internal/hostagent/action_runner_health_persistence_windows.go
@@ -0,0 +1,35 @@
+//go:build windows
+
+package hostagent
+
+import (
+ "fmt"
+
+ "golang.org/x/sys/windows"
+)
+
+func replaceActionRunnerHealthFile(from, to string) error {
+ fromPath, err := windows.UTF16PtrFromString(from)
+ if err != nil {
+ return fmt.Errorf("encode action-runner health source path: %w", err)
+ }
+ toPath, err := windows.UTF16PtrFromString(to)
+ if err != nil {
+ return fmt.Errorf("encode action-runner health destination path: %w", err)
+ }
+ if err := windows.MoveFileEx(
+ fromPath,
+ toPath,
+ windows.MOVEFILE_REPLACE_EXISTING|windows.MOVEFILE_WRITE_THROUGH,
+ ); err != nil {
+ return fmt.Errorf("replace action-runner health marker with write-through: %w", err)
+ }
+ return nil
+}
+
+func syncActionRunnerHealthDirectory(string) error {
+ // MoveFileEx with WRITE_THROUGH is the Windows metadata durability barrier;
+ // FlushFileBuffers requires a write-capable handle and is not guaranteed for
+ // the read-only directory handles returned by os.Open.
+ return nil
+}
diff --git a/internal/hostagent/privilege_helper_client_test.go b/internal/hostagent/privilege_helper_client_test.go
index e5ac9df2fd..81eb80ad73 100644
--- a/internal/hostagent/privilege_helper_client_test.go
+++ b/internal/hostagent/privilege_helper_client_test.go
@@ -8,6 +8,7 @@ import (
"io"
"net"
"os/exec"
+ "path/filepath"
"testing"
"time"
@@ -43,7 +44,7 @@ func (f *fakePrivilegedTelemetry) ProxmoxLXCFilesystems(context.Context) (*agent
func testPrivilegeHelperTelemetry(t *testing.T, result agenthelper.HealthResult) *privilegeHelperTelemetry {
t.Helper()
client, err := agenthelper.NewClient(agenthelper.ClientConfig{
- SocketPath: "/run/pulse-agent/helper.sock",
+ SocketPath: filepath.Join(t.TempDir(), "helper.sock"),
MaxDeadline: privilegeHelperOperationDeadline,
NewRequestID: func() (string, error) {
return "health-request", nil