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
Normalize bounded Docker action clock skew
rcourtman43e70411a68a
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 9cdd9d02d2..1d919f96ce 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -471,7 +471,12 @@ or canonical Docker host name and may mark its vetted container lifecycledispatch as a trusted agent command after the API action has enteredexecution; lifecycle surfaces still consume only the resource payload, actionreadiness, and action-audit result rather than issuing or approving-command-agent grants themselves.+command-agent grants themselves. Because the agent and Pulse server have+independent clocks, the API-owned Docker result projector validates raw+lifecycle/update chronology within its bounded skew window and then binds a+slightly future valid observation to the server receipt boundary for canonical+evidence. Agent lifecycle consumers must not reject that bounded case, widen+the skew window, or clamp stale/excessively future evidence into validity.Docker / Podman container image updates are a fourth typed operation on thatsame closed channel, not an extension of the raw command path and not adiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 1eeef2141f..e147358cbd 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -2025,7 +2025,12 @@ a new API state machine, queue contract, or verification-accounting field.the executor may dispatch the vetted container lifecycle and verificationcommands as trusted agent commands; the host-agent hard-block policy stillapplies, and the action audit remains the approval and lifecycle source of- truth.+ truth. Docker lifecycle and image-update result evidence must validate raw+ agent chronology against the bounded freshness/skew window before canonical+ normalization. When that valid raw observation is slightly ahead of the+ server clock, the API conservatively binds its canonical `ObservedAt` to the+ server `ReceivedAt` boundary; stale or excessively future observations stay+ inconclusive and must never be made fresh by clamping.Proxmox QEMU VM and LXC lifecycle execution is part of that same API-ownedaction contract. Proxmox guest resources may expose only conservativelifecycle operations (`start`, `shutdown`, `reboot`, `stop`) and executiondiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 492672b07e..b9d2796dd6 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -466,7 +466,12 @@ lifecycle executor resolves a command agent by Docker source ID or canonicalhost name and dispatches a trusted internal container command after actionapproval, storage and recovery consumers may observe only the resulting actionaudit and verification evidence; they must not reinterpret that trusted command-path as recovery authority or a storage-owned action transport.+path as recovery authority or a storage-owned action transport. Canonical+Docker action evidence may bind a raw, freshness-validated agent observation+that is slightly ahead of the server clock to the server receipt boundary;+storage/recovery consumers must preserve that evidence rather than treating+normal bounded clock skew as recovery failure, and must not apply the same+clamp to observations outside the API-owned freshness window.Container restart declares rollback unavailable. Its canonical`ActionResultV2.compensation` therefore records support `unavailable` and status`not_available`; neither same-agent readback nor a distinct direct-daemondiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 37bb9b4e90..434f1cc47b 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -20159,6 +20159,28 @@ func TestContract_DockerLifecycleActionsResolveCommandAgentAndDispatchOneTypedOp}}+func TestContract_DockerActionEvidenceBoundsPositiveAgentClockSkewAtReceipt(t *testing.T) {+ source, err := os.ReadFile("docker_container_action_result.go")+ if err != nil {+ t.Fatalf("read docker_container_action_result.go: %v", err)+ }+ src := string(source)+ for _, snippet := range []string{+ "freshDockerLifecycleObservation(facts.Before.ObservedAt, facts.After.ObservedAt, receivedAt)",+ "freshDockerUpdateObservation(facts.After.ObservedAt, receivedAt)",+ "func dockerActionEvidenceTimes(observedAt, receivedAt time.Time) (time.Time, time.Time)",+ "if observedAt.After(receivedAt) {",+ "observedAt = receivedAt",+ } {+ if !strings.Contains(src, snippet) {+ t.Fatalf("Docker action evidence must preserve bounded clock-skew handling snippet %q", snippet)+ }+ }+ if calls := strings.Count(src, "dockerActionEvidenceTimes("); calls != 5 {+ t.Fatalf("Docker lifecycle/update agent and independent evidence must all use the receipt-boundary helper; calls = %d, want 5", calls)+ }+}+func TestContract_ProxmoxLifecycleActionsResolveNodeCommandAgentAndVerifyState(t *testing.T) {source, err := os.ReadFile("proxmox_guest_action_executor.go")if err != nil {diff --git a/internal/api/docker_container_action_result.go b/internal/api/docker_container_action_result.goindex 9112abef93..ceda50e05e 100644--- a/internal/api/docker_container_action_result.go+++ b/internal/api/docker_container_action_result.go@@ -25,10 +25,11 @@ func dockerContainerExecutionResult(resourceID, agentID string, req agentexec.Doverification.ReasonCode = "stale_agent_readback"verification.Summary = "The agent readback was stale, skewed, or had invalid mutation chronology."} else {+ evidenceObservedAt, evidenceReceivedAt := dockerActionEvidenceTimes(facts.After.ObservedAt, receivedAt)evidence, err := unified.NormalizeActionEvidence(unified.ActionEvidence{Version: unified.ActionEvidenceVersion, ID: req.Operation + "-agent-readback", ObserverID: agentID,ObserverKind: "unified_agent", ObserverTrustDomain: "agent:" + agentID, ExecutorTrustDomain: "agent:" + agentID,- Method: "typed_container_read_after_write", SubjectID: resourceID, ObservedAt: facts.After.ObservedAt.UTC(), ReceivedAt: receivedAt.UTC(), Summary: summary,+ Method: "typed_container_read_after_write", SubjectID: resourceID, ObservedAt: evidenceObservedAt, ReceivedAt: evidenceReceivedAt, Summary: summary,})if err != nil {return nil, fmt.Errorf("normalize docker lifecycle evidence: %w", err)@@ -43,6 +44,7 @@ func dockerContainerExecutionResult(resourceID, agentID string, req agentexec.Do}}if independent != nil && freshDockerLifecycleObservation(facts.Before.ObservedAt, independent.Snapshot.ObservedAt, independent.ReceivedAt) && strings.TrimSpace(independent.TrustDomain) != "" && strings.TrimSpace(independent.TrustDomain) != "agent:"+agentID && strings.EqualFold(independent.Snapshot.ContainerID, facts.ContainerID) {+ evidenceObservedAt, evidenceReceivedAt := dockerActionEvidenceTimes(independent.Snapshot.ObservedAt, independent.ReceivedAt)observationDigest, err := operationreceipt.DigestCanonicalJSON(struct {ActionID string `json:"action_id"`SubjectID string `json:"subject_id"`@@ -56,7 +58,7 @@ func dockerContainerExecutionResult(resourceID, agentID string, req agentexec.Doevidence, err := unified.NormalizeActionEvidence(unified.ActionEvidence{Version: unified.ActionEvidenceVersion, ID: req.ActionID + "-direct-daemon-observation", ObserverID: independent.ObserverID,ObserverKind: "docker_daemon_observer", ObserverTrustDomain: independent.TrustDomain, ExecutorTrustDomain: "agent:" + agentID,- Method: independent.Method, SubjectID: resourceID, ObservedAt: independent.Snapshot.ObservedAt, ReceivedAt: independent.ReceivedAt,+ Method: independent.Method, SubjectID: resourceID, ObservedAt: evidenceObservedAt, ReceivedAt: evidenceReceivedAt,Summary: independentSummary, Refs: []unified.ActionEvidenceRef{{ID: req.ActionID, Kind: "docker_before_after", Digest: observationDigest}},})if err != nil {@@ -99,10 +101,11 @@ func dockerContainerUpdateExecutionResult(resourceID, agentID string, facts agenverification.ReasonCode = "stale_agent_readback"verification.Summary = "The agent readback was stale or skewed."} else {+ evidenceObservedAt, evidenceReceivedAt := dockerActionEvidenceTimes(facts.After.ObservedAt, receivedAt)evidence, err := unified.NormalizeActionEvidence(unified.ActionEvidence{Version: unified.ActionEvidenceVersion, ID: facts.Operation + "-agent-readback", ObserverID: agentID,ObserverKind: "unified_agent", ObserverTrustDomain: "agent:" + agentID, ExecutorTrustDomain: "agent:" + agentID,- Method: "typed_container_read_after_write", SubjectID: resourceID, ObservedAt: facts.After.ObservedAt.UTC(), ReceivedAt: receivedAt.UTC(), Summary: summary,+ Method: "typed_container_read_after_write", SubjectID: resourceID, ObservedAt: evidenceObservedAt, ReceivedAt: evidenceReceivedAt, Summary: summary,})if err != nil {return nil, fmt.Errorf("normalize docker update evidence: %w", err)@@ -117,6 +120,7 @@ func dockerContainerUpdateExecutionResult(resourceID, agentID string, facts agen}}if independent != nil && facts.NewContainerID != "" && freshDockerUpdateObservation(independent.Snapshot.ObservedAt, independent.ReceivedAt) && strings.TrimSpace(independent.TrustDomain) != "" && strings.TrimSpace(independent.TrustDomain) != "agent:"+agentID {+ evidenceObservedAt, evidenceReceivedAt := dockerActionEvidenceTimes(independent.Snapshot.ObservedAt, independent.ReceivedAt)observationDigest, err := operationreceipt.DigestCanonicalJSON(struct {ActionID string `json:"action_id"`SubjectID string `json:"subject_id"`@@ -130,7 +134,7 @@ func dockerContainerUpdateExecutionResult(resourceID, agentID string, facts agenevidence, err := unified.NormalizeActionEvidence(unified.ActionEvidence{Version: unified.ActionEvidenceVersion, ID: facts.ActionID + "-direct-daemon-observation", ObserverID: independent.ObserverID,ObserverKind: "docker_daemon_observer", ObserverTrustDomain: independent.TrustDomain, ExecutorTrustDomain: "agent:" + agentID,- Method: independent.Method, SubjectID: resourceID, ObservedAt: independent.Snapshot.ObservedAt, ReceivedAt: independent.ReceivedAt,+ Method: independent.Method, SubjectID: resourceID, ObservedAt: evidenceObservedAt, ReceivedAt: evidenceReceivedAt,Summary: independentSummary, Refs: []unified.ActionEvidenceRef{{ID: facts.ActionID, Kind: "docker_update_replacement", Digest: observationDigest}},})if err != nil {@@ -217,6 +221,20 @@ func freshDockerUpdateObservation(observedAt, receivedAt time.Time) bool {return !observedAt.Before(receivedAt.UTC().Add(-30*time.Minute)) && !observedAt.After(receivedAt.UTC().Add(5*time.Minute))}+// dockerActionEvidenceTimes preserves the server receipt boundary required by+// canonical evidence while tolerating bounded positive clock skew already+// admitted by the Docker freshness checks. The raw timestamps are validated+// before this helper is called, so an excessively future or stale observation+// still fails closed instead of being made fresh by clamping.+func dockerActionEvidenceTimes(observedAt, receivedAt time.Time) (time.Time, time.Time) {+ observedAt = observedAt.UTC()+ receivedAt = receivedAt.UTC()+ if observedAt.After(receivedAt) {+ observedAt = receivedAt+ }+ return observedAt, receivedAt+}+// dockerUpdateFactsMatch confirms the observed container is the replacement// the agent claims to have created. A stopped original is recreated without// being started, so run-state is not part of the postcondition; identity is.diff --git a/internal/api/docker_container_action_result_test.go b/internal/api/docker_container_action_result_test.goindex 950d3c14e1..ae37cad818 100644--- a/internal/api/docker_container_action_result_test.go+++ b/internal/api/docker_container_action_result_test.go@@ -51,6 +51,56 @@ func TestDockerContainerExecutionResultStaleReadbackIsInconclusive(t *testing.T)}}+func TestDockerContainerExecutionResultClampsBoundedPositiveAgentClockSkew(t *testing.T) {+ receivedAt := time.Now().UTC()+ facts := dockerResultFacts(receivedAt.Add(2*time.Second), true, true, true, true)+ result, err := dockerContainerExecutionResult("app-container:fixture", "agent-1", agentexec.DockerContainerLifecyclePayload{Operation: agentexec.DockerContainerOperationRestart}, facts, nil, receivedAt)+ if err != nil {+ t.Fatal(err)+ }+ verification := result.ActionResultV2.Verification+ if verification.Status != unified.ActionVerificationConfirmed || len(verification.Evidence) != 1 {+ t.Fatalf("verification = %#v", verification)+ }+ if !verification.Evidence[0].ObservedAt.Equal(receivedAt) || !verification.Evidence[0].ReceivedAt.Equal(receivedAt) {+ t.Fatalf("evidence timestamps = observed %s received %s, want receipt boundary %s", verification.Evidence[0].ObservedAt, verification.Evidence[0].ReceivedAt, receivedAt)+ }+}++func TestDockerContainerExecutionResultRejectsExcessivePositiveAgentClockSkew(t *testing.T) {+ receivedAt := time.Now().UTC()+ facts := dockerResultFacts(receivedAt.Add(6*time.Minute), true, true, true, true)+ result, err := dockerContainerExecutionResult("app-container:fixture", "agent-1", agentexec.DockerContainerLifecyclePayload{Operation: agentexec.DockerContainerOperationRestart}, facts, nil, receivedAt)+ if err != nil {+ t.Fatal(err)+ }+ verification := result.ActionResultV2.Verification+ if verification.Status != unified.ActionVerificationInconclusive || verification.ReasonCode != "stale_agent_readback" || len(verification.Evidence) != 0 {+ t.Fatalf("verification = %#v", verification)+ }+}++func TestDockerContainerUpdateExecutionResultClampsBoundedPositiveAgentClockSkew(t *testing.T) {+ receivedAt := time.Now().UTC()+ observedAt := receivedAt.Add(2 * time.Second)+ facts := agentexec.DockerContainerUpdateResultPayload{+ Operation: agentexec.DockerContainerOperationUpdate, ActionID: "action-update", ExecutionPhase: agentexec.DockerContainerPhaseComplete,+ MutationStarted: true, MutationCompleted: true, ReadbackRan: true, NewContainerID: dockerLifecycleTestID,+ After: agentexec.DockerContainerLifecycleSnapshot{ContainerID: dockerLifecycleTestID, State: "running", Running: true, ObservedAt: observedAt},+ }+ result, err := dockerContainerUpdateExecutionResult("app-container:fixture", "agent-1", facts, nil, receivedAt)+ if err != nil {+ t.Fatal(err)+ }+ verification := result.ActionResultV2.Verification+ if verification.Status != unified.ActionVerificationConfirmed || len(verification.Evidence) != 1 {+ t.Fatalf("verification = %#v", verification)+ }+ if !verification.Evidence[0].ObservedAt.Equal(receivedAt) || !verification.Evidence[0].ReceivedAt.Equal(receivedAt) {+ t.Fatalf("evidence timestamps = observed %s received %s, want receipt boundary %s", verification.Evidence[0].ObservedAt, verification.Evidence[0].ReceivedAt, receivedAt)+ }+}+func TestDockerContainerExecutionResultClassifiesDistinctDaemonObserverAsIndependent(t *testing.T) {now := time.Now().UTC()facts := dockerResultFacts(now, true, true, true, true)