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.

Auto-acknowledge findings on intentionally-offline resources

rcourtman8a70a2c23c8f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f9f7cdc4ff..2626604227 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -919,10 +919,14 @@ profile and assignment columns, but embedded table framing must route through
The findings runtime now consumes operator-set per-resource state
through a provider adapter wired in `internal/api/router.go` at
-startup: when a resource is in an operator-set maintenance window,
-new findings against it are auto-acknowledged at creation time so a
-scheduled-maintenance window does not flood notifications during the
-window. The agent runtime keeps the operator commitment honored across
+startup. The adapter returns a `ResourceOperatorStateProjection`
+covering every signal in one call (active maintenance window plus
+the indefinite `IntentionallyOffline` flag), so adding new signals
+later does not multiply round-trips per finding. When a resource is
+in an operator-set maintenance window OR is marked intentionally
+offline, new findings against it are auto-acknowledged at creation
+time so the operator's commitment is honored without flooding
+notifications. The agent runtime keeps the operator commitment honored across
restarts because the underlying state lives in the durable
`resource_operator_state` SQLite table.
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index f5cf93ffdf..c49117986b 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -584,14 +584,27 @@ The findings store now consults a `ResourceOperatorStateProvider`
during the new-finding path. The interface lives in `internal/ai` to
avoid an import cycle with `internal/unifiedresources`; the API layer
wires the adapter at startup, projecting
-`unified.ResourceOperatorState` into the narrow
-`ActiveMaintenanceWindow` shape the findings runtime needs. When the
-provider reports an active maintenance window, the new-finding path
-auto-dismisses with reason `expected_behavior`, attributes the
-suppression on the lifecycle timeline (`operator_state_cause:
-maintenance_window`), and persists the finding for audit history.
-Deployments without a provider keep the original new-finding behavior
-— suppression is opt-in.
+`unified.ResourceOperatorState` into the
+`ResourceOperatorStateProjection` shape the findings runtime
+consumes. The projection carries every operator-set signal in one
+call (active maintenance window plus the `IntentionallyOffline`
+flag) so adding new signals later does not multiply round-trips per
+finding.
+
+When the projection carries an active maintenance window, the
+new-finding path auto-dismisses with reason `expected_behavior`,
+attributes the suppression on the lifecycle timeline
+(`operator_state_cause: maintenance_window`, with
+`maintenance_end_at` metadata), and persists the finding for audit
+history. The `IntentionallyOffline` branch is the indefinite
+counterpart — same auto-dismiss but with
+`operator_state_cause: intentionally_offline` and no
+`maintenance_end_at` field because the suppression has no scheduled
+end. Maintenance windows take priority over intentionally-offline
+when both are active, because the time-bounded suppression is the
+more honest one to surface to the operator. Deployments without a
+provider keep the original new-finding behavior — suppression is
+opt-in.
This subsystem now makes Pulse Assistant and Patrol backend runtime ownership
explicit inside the current architecture lane instead of leaving those
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 288b893ccf..23f266bf86 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1347,11 +1347,13 @@ The router wires the operator-state adapter into the findings runtime
at startup: `internal/api/router.go` calls
`patrol.GetFindings().SetResourceOperatorStateProvider(...)` with a
`ResourceOperatorStateProviderFunc` closure that reads the unified
-store and projects `state.IsInMaintenanceAt` into the
-`ActiveMaintenanceWindow` shape `internal/ai` consumes. This keeps
-`internal/ai` free of an `internal/unifiedresources` import while
-giving the findings runtime per-resource maintenance suppression
-without each org needing a separate adapter declaration.
+store and returns a `ResourceOperatorStateProjection` carrying every
+operator-set signal in one call (maintenance window via
+`state.IsInMaintenanceAt` plus the `IntentionallyOffline` flag).
+This keeps `internal/ai` free of an `internal/unifiedresources`
+import while giving the findings runtime full per-resource
+suppression without each org needing a separate adapter declaration
+and without growing per-finding lookups as new signals land.
`/api/resources/{id}/operator-state` is the canonical surface for
operator-set per-resource intent (intentionally offline, never
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index e69317d1e1..048fb9db2f 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -1178,14 +1178,18 @@ finding" context for chat or tickets.
The findings store also consumes per-resource operator-set state via
the narrow `ResourceOperatorStateProvider` interface installed by
`SetResourceOperatorStateProvider`. The API layer wires an adapter
-that projects `unified.ResourceOperatorState` into the
-`ActiveMaintenanceWindow` projection so `internal/ai` does not need
-to import `internal/unifiedresources`. When a new finding is raised
-against a resource currently in an operator-set maintenance window,
-the new-finding path auto-dismisses it as `expected_behavior`,
-populates `AcknowledgedAt`, writes a `UserNote` naming the window
-and reason, and emits a `dismissed` lifecycle event with the
-`operator_state_cause: maintenance_window` metadata so the timeline
-can attribute the suppression to its source. Default deployments
-without a provider behave identically to before — operator-state
-suppression is opt-in.
+that projects `unified.ResourceOperatorState` into a
+`ResourceOperatorStateProjection` so `internal/ai` does not need to
+import `internal/unifiedresources`. The projection returns every
+operator-set signal in one call (maintenance window + the
+`IntentionallyOffline` flag), and the new-finding path branches on
+both: maintenance window suppression takes priority and emits
+`operator_state_cause: maintenance_window` plus the
+`maintenance_end_at` metadata; the `IntentionallyOffline` branch is
+the indefinite fallback that emits `operator_state_cause:
+intentionally_offline` with no end-at field because the suppression
+has no scheduled end. Both branches set `DismissedReason =
+expected_behavior` and write a `UserNote` naming the cause so the
+operator can audit why future findings stayed quiet without
+expanding each row. Default deployments without a provider behave
+identically to before — operator-state suppression is opt-in.
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 740d7ff082..f64ccfcb21 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -507,12 +507,16 @@ shell clickable behind another overlay.
## Current State
The new-finding hot path now consults a per-resource operator-state
-provider when one is wired (slice 31). The provider call is gated on
+provider when one is wired. The provider call is gated on
`f.ResourceID != ""` and a non-nil provider so deployments without
the feature wired pay no extra work; the provider implementation
itself is a single SQLite point lookup keyed on `canonical_id`, no
-join, no scan. Maintenance-window suppression therefore adds at most
-one read per new finding, not per existing-finding update.
+join, no scan. The projection returns every operator-set signal in
+one call, so adding new signals (intentionally offline, never
+auto-remediate, criticality) does not multiply per-finding lookups.
+Operator-state suppression therefore adds at most one read per new
+finding, not per existing-finding update, and not per operator-set
+flag.
Summary cards for Infrastructure, Storage, Workloads, and Recovery now surface
health-state counts (offline, degraded, alerting) instead of raw online/offline
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 0febf8ec36..7bdc87d0b4 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -949,9 +949,12 @@ bypass the API fail-closed execution gate.
The findings runtime reads operator-set state through the same
durable `resource_operator_state` SQLite table on every
-new-finding-add. A maintenance window persisted before a process
-restart still suppresses new findings after the agent reloads — the
-operator commitment survives without needing a re-entry on startup.
+new-finding-add. Both the time-bounded maintenance window and the
+indefinite `IntentionallyOffline` flag persist across restarts; the
+operator commitment in either form survives without needing a
+re-entry on startup. The provider adapter returns one projection
+covering all signals so the storage path is touched once per
+finding regardless of which signal is active.
The `resource_operator_state` SQLite table introduced by the
unified-resources store keeps operator-set per-resource intent
diff --git a/internal/ai/findings.go b/internal/ai/findings.go
index 5358f41e41..dcdda88370 100644
--- a/internal/ai/findings.go
+++ b/internal/ai/findings.go
@@ -683,25 +683,37 @@ type ResourceOperatorStateMaintenanceWindow struct {
Reason string
}
+// ResourceOperatorStateProjection is the per-resource view the
+// findings runtime consumes during the new-finding path. One provider
+// call returns every signal the runtime needs, so adding new signals
+// does not multiply round-trips per finding. MaintenanceWindow is nil
+// when no window is currently active; IntentionallyOffline reflects
+// the operator's "this resource is expected to be offline" flag.
+type ResourceOperatorStateProjection struct {
+ MaintenanceWindow *ResourceOperatorStateMaintenanceWindow
+ IntentionallyOffline bool
+}
+
// ResourceOperatorStateProvider is the narrow interface the findings
// store consumes for per-resource operator intent. Implementations
// adapt the unified-resources `ResourceOperatorState` shape into the
-// projection that the findings runtime needs (currently just the
-// active maintenance window). Returning ok=false means "no active
-// operator state for this resource" and the store falls through to
-// the default new-finding path.
+// projection that the findings runtime needs. Returning ok=false
+// means "no operator state recorded for this resource" and the store
+// falls through to the default new-finding path; ok=true with all
+// projection fields zero means "operator state exists but no signal
+// is currently active" (e.g. window scheduled for the future).
type ResourceOperatorStateProvider interface {
- ActiveMaintenanceWindow(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool)
+ OperatorStateProjection(canonicalID string, now time.Time) (ResourceOperatorStateProjection, bool)
}
// ResourceOperatorStateProviderFunc is a function adapter so wire-up
// code in the API layer can pass a closure without declaring a struct.
-type ResourceOperatorStateProviderFunc func(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool)
+type ResourceOperatorStateProviderFunc func(canonicalID string, now time.Time) (ResourceOperatorStateProjection, bool)
-// ActiveMaintenanceWindow implements ResourceOperatorStateProvider.
-func (f ResourceOperatorStateProviderFunc) ActiveMaintenanceWindow(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {
+// OperatorStateProjection implements ResourceOperatorStateProvider.
+func (f ResourceOperatorStateProviderFunc) OperatorStateProjection(canonicalID string, now time.Time) (ResourceOperatorStateProjection, bool) {
if f == nil {
- return ResourceOperatorStateMaintenanceWindow{}, false
+ return ResourceOperatorStateProjection{}, false
}
return f(canonicalID, now)
}
@@ -1166,29 +1178,50 @@ func (s *FindingsStore) Add(f *Finding) bool {
s.syncLoopStateLocked(f)
s.appendLifecycleLocked(f, "detected", "Detected by Pulse Patrol", "", f.LoopState, nil)
- // Operator-state suppression: when the resource is currently in a
- // maintenance window the operator set, auto-dismiss the finding as
- // expected_behavior with a reason that names the window. The
- // finding still lands in durable history (so the operator can
- // audit what tripped during the window) but does not surface as
- // active. Severity escalation paths still wake it later if the
- // underlying condition stays after the window closes.
+ // Operator-state suppression: when the operator has set per-resource
+ // intent that suppresses findings, auto-dismiss the finding as
+ // expected_behavior with a reason that names the cause. Maintenance
+ // windows take priority because they're time-bounded ("expect this
+ // noise until the window closes"); IntentionallyOffline is the
+ // fallback branch ("expect this resource to stay quiet
+ // indefinitely"). The finding still lands in durable history so
+ // the operator can audit what tripped during the suppression;
+ // severity escalation paths still wake it later if the underlying
+ // condition stays after the operator clears the state.
if provider := s.resourceOperatorStateProvider; provider != nil && f.ResourceID != "" {
- if window, ok := provider.ActiveMaintenanceWindow(f.ResourceID, time.Now()); ok {
+ if projection, ok := provider.OperatorStateProjection(f.ResourceID, time.Now()); ok {
now := time.Now()
- f.DismissedReason = "expected_behavior"
- f.AcknowledgedAt = &now
- noteParts := []string{fmt.Sprintf("Resource is in operator-set maintenance window until %s.", window.EndAt.Format(time.RFC3339))}
- if reason := strings.TrimSpace(window.Reason); reason != "" {
- noteParts = append(noteParts, "Reason: "+reason)
+ switch {
+ case projection.MaintenanceWindow != nil:
+ window := projection.MaintenanceWindow
+ f.DismissedReason = "expected_behavior"
+ f.AcknowledgedAt = &now
+ noteParts := []string{fmt.Sprintf("Resource is in operator-set maintenance window until %s.", window.EndAt.Format(time.RFC3339))}
+ if reason := strings.TrimSpace(window.Reason); reason != "" {
+ noteParts = append(noteParts, "Reason: "+reason)
+ }
+ f.UserNote = strings.Join(noteParts, " ")
+ s.appendLifecycleLocked(f, "dismissed", "Auto-acknowledged: resource in maintenance window", f.LoopState, string(FindingLoopStateDismissed), map[string]string{
+ "reason": "expected_behavior",
+ "operator_state_cause": "maintenance_window",
+ "maintenance_end_at": window.EndAt.Format(time.RFC3339),
+ })
+ s.syncLoopStateLocked(f)
+ case projection.IntentionallyOffline:
+ // Operator has marked this resource as expected-to-be-offline,
+ // so any finding raised against it is by definition expected
+ // noise. Auto-dismiss with a clear note so the operator
+ // understands why future findings stayed quiet without
+ // expanding each row.
+ f.DismissedReason = "expected_behavior"
+ f.AcknowledgedAt = &now
+ f.UserNote = "Resource is marked intentionally offline by the operator. Clear the flag on the resource detail surface to resume notifications."
+ s.appendLifecycleLocked(f, "dismissed", "Auto-acknowledged: resource is intentionally offline", f.LoopState, string(FindingLoopStateDismissed), map[string]string{
+ "reason": "expected_behavior",
+ "operator_state_cause": "intentionally_offline",
+ })
+ s.syncLoopStateLocked(f)
}
- f.UserNote = strings.Join(noteParts, " ")
- s.appendLifecycleLocked(f, "dismissed", "Auto-acknowledged: resource in maintenance window", f.LoopState, string(FindingLoopStateDismissed), map[string]string{
- "reason": "expected_behavior",
- "operator_state_cause": "maintenance_window",
- "maintenance_end_at": window.EndAt.Format(time.RFC3339),
- })
- s.syncLoopStateLocked(f)
}
}
diff --git a/internal/ai/findings_test.go b/internal/ai/findings_test.go
index ea1336f4ce..4030638e87 100644
--- a/internal/ai/findings_test.go
+++ b/internal/ai/findings_test.go
@@ -1619,14 +1619,16 @@ func TestFindingsStore_Add_AutoAcknowledgesDuringMaintenanceWindow(t *testing.T)
// the window) but does not surface as active.
store := NewFindingsStore()
now := time.Now()
- provider := ResourceOperatorStateProviderFunc(func(canonicalID string, queriedAt time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {
+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, queriedAt time.Time) (ResourceOperatorStateProjection, bool) {
if canonicalID != "vm:101" {
- return ResourceOperatorStateMaintenanceWindow{}, false
+ return ResourceOperatorStateProjection{}, false
}
- return ResourceOperatorStateMaintenanceWindow{
- StartAt: now.Add(-time.Hour),
- EndAt: now.Add(time.Hour),
- Reason: "Q3 storage upgrade",
+ return ResourceOperatorStateProjection{
+ MaintenanceWindow: &ResourceOperatorStateMaintenanceWindow{
+ StartAt: now.Add(-time.Hour),
+ EndAt: now.Add(time.Hour),
+ Reason: "Q3 storage upgrade",
+ },
}, true
})
store.SetResourceOperatorStateProvider(provider)
@@ -1675,8 +1677,8 @@ func TestFindingsStore_Add_DoesNotAutoAcknowledgeOutsideMaintenanceWindow(t *tes
// so the suppression branch can't drift into "always suppress when
// provider is set".
store := NewFindingsStore()
- provider := ResourceOperatorStateProviderFunc(func(canonicalID string, now time.Time) (ResourceOperatorStateMaintenanceWindow, bool) {
- return ResourceOperatorStateMaintenanceWindow{}, false
+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, now time.Time) (ResourceOperatorStateProjection, bool) {
+ return ResourceOperatorStateProjection{}, false
})
store.SetResourceOperatorStateProvider(provider)
@@ -1699,11 +1701,106 @@ func TestFindingsStore_Add_DoesNotAutoAcknowledgeOutsideMaintenanceWindow(t *tes
}
}
+func TestFindingsStore_Add_AutoAcknowledgesOnIntentionallyOfflineResource(t *testing.T) {
+ // When the operator has marked a resource as intentionally offline,
+ // any new finding raised against it must be auto-dismissed as
+ // expected_behavior with operator_state_cause=intentionally_offline.
+ // The intent is an indefinite "shut up about this resource" — no
+ // time window — so the lifecycle event must not include a
+ // maintenance_end_at field.
+ store := NewFindingsStore()
+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, now time.Time) (ResourceOperatorStateProjection, bool) {
+ if canonicalID != "vm:archived" {
+ return ResourceOperatorStateProjection{}, false
+ }
+ return ResourceOperatorStateProjection{
+ IntentionallyOffline: true,
+ }, true
+ })
+ store.SetResourceOperatorStateProvider(provider)
+
+ store.Add(&Finding{
+ ID: "f-archived",
+ ResourceID: "vm:archived",
+ Severity: FindingSeverityWarning,
+ Title: "Resource is offline",
+ })
+
+ got := store.Get("f-archived")
+ if got == nil {
+ t.Fatal("finding must be persisted even when auto-dismissed")
+ }
+ if got.DismissedReason != "expected_behavior" {
+ t.Errorf("expected DismissedReason=expected_behavior; got %q", got.DismissedReason)
+ }
+ if got.AcknowledgedAt == nil {
+ t.Error("AcknowledgedAt must be populated for auto-dismissed findings")
+ }
+ if !strings.Contains(got.UserNote, "intentionally offline") {
+ t.Errorf("UserNote should explain the intentionally-offline suppression; got %q", got.UserNote)
+ }
+ foundEvent := false
+ for _, ev := range got.Lifecycle {
+ if ev.Type == "dismissed" && ev.Metadata["operator_state_cause"] == "intentionally_offline" {
+ foundEvent = true
+ if _, hasEnd := ev.Metadata["maintenance_end_at"]; hasEnd {
+ t.Error("intentionally_offline event must not carry maintenance_end_at metadata; the suppression is indefinite")
+ }
+ break
+ }
+ }
+ if !foundEvent {
+ t.Error("expected a 'dismissed' lifecycle event with operator_state_cause=intentionally_offline")
+ }
+}
+
+func TestFindingsStore_Add_MaintenanceWindowTakesPriorityOverIntentionallyOffline(t *testing.T) {
+ // When both signals are active for the same resource, the
+ // maintenance window must win because it's time-bounded — operators
+ // will see the suppression auto-clear when the window ends, which
+ // is more honest than the indefinite intentionally-offline branch.
+ store := NewFindingsStore()
+ now := time.Now()
+ provider := ResourceOperatorStateProviderFunc(func(canonicalID string, queriedAt time.Time) (ResourceOperatorStateProjection, bool) {
+ return ResourceOperatorStateProjection{
+ IntentionallyOffline: true,
+ MaintenanceWindow: &ResourceOperatorStateMaintenanceWindow{
+ StartAt: now.Add(-time.Hour),
+ EndAt: now.Add(time.Hour),
+ Reason: "active maintenance",
+ },
+ }, true
+ })
+ store.SetResourceOperatorStateProvider(provider)
+
+ store.Add(&Finding{
+ ID: "f-both",
+ ResourceID: "vm:101",
+ Severity: FindingSeverityWarning,
+ Title: "CPU saturated",
+ })
+
+ got := store.Get("f-both")
+ if got == nil {
+ t.Fatal("finding must be persisted")
+ }
+ foundMaintenance := false
+ for _, ev := range got.Lifecycle {
+ if ev.Type == "dismissed" && ev.Metadata["operator_state_cause"] == "maintenance_window" {
+ foundMaintenance = true
+ break
+ }
+ }
+ if !foundMaintenance {
+ t.Error("maintenance window must take priority over intentionally_offline when both are active")
+ }
+}
+
func TestFindingsStore_Add_OperatorStateSuppressionIsOptIn(t *testing.T) {
// The default store (no provider wired) must behave exactly as
- // before — slice 31 must not regress the existing new-finding
- // path for any deployment that hasn't opted in to the
- // operator-state feature yet.
+ // before — the operator-state feature must not regress the
+ // existing new-finding path for any deployment that hasn't opted
+ // in yet.
store := NewFindingsStore()
store.Add(&Finding{
ID: "f-default",
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index aacf439759..2bc9db03f1 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -13260,6 +13260,9 @@ func TestContract_FindingsResourceOperatorStateProviderIsWired(t *testing.T) {
if !strings.Contains(src, "GetResourceOperatorState(canonicalID)") {
t.Error("router.go must read state from the unified store's canonical accessor")
}
+ if !strings.Contains(src, "IntentionallyOffline: state.IntentionallyOffline") {
+ t.Error("router.go must propagate state.IntentionallyOffline through the projection so the findings runtime sees it")
+ }
}
// TestContract_ResourceOperatorStateUrlCanonicalIDWinsOverBody pins the
diff --git a/internal/api/router.go b/internal/api/router.go
index b0c8e3b079..ecff3310ef 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1751,32 +1751,35 @@ func (r *Router) startPatrolForContext(ctx context.Context, orgID string) bool {
unifiedStore.Resolve(findingID)
})
// Wire per-resource operator-state into the findings runtime so
- // new findings raised against a resource currently in a
- // maintenance window get auto-acknowledged with reason
- // "expected_behavior". The adapter projects
- // `unified.ResourceOperatorState` into the narrow
- // `ResourceOperatorStateProvider` shape the findings store
- // consumes — keeps `internal/ai` clear of an
+ // new findings raised against a resource the operator has
+ // flagged (maintenance window or intentionally offline) get
+ // auto-acknowledged with reason "expected_behavior". One
+ // adapter call returns the full projection so adding new
+ // signals later does not multiply round-trips per finding.
+ // Keeps `internal/ai` clear of an
// `internal/unifiedresources` import.
patrol.GetFindings().SetResourceOperatorStateProvider(
ai.ResourceOperatorStateProviderFunc(
- func(canonicalID string, now time.Time) (ai.ResourceOperatorStateMaintenanceWindow, bool) {
+ func(canonicalID string, now time.Time) (ai.ResourceOperatorStateProjection, bool) {
orgStore, lookupErr := r.resourceHandlers.getStore(orgID)
if lookupErr != nil {
- return ai.ResourceOperatorStateMaintenanceWindow{}, false
+ return ai.ResourceOperatorStateProjection{}, false
}
state, found, fetchErr := orgStore.GetResourceOperatorState(canonicalID)
if fetchErr != nil || !found {
- return ai.ResourceOperatorStateMaintenanceWindow{}, false
+ return ai.ResourceOperatorStateProjection{}, false
}
- if !state.IsInMaintenanceAt(now) {
- return ai.ResourceOperatorStateMaintenanceWindow{}, false
+ projection := ai.ResourceOperatorStateProjection{
+ IntentionallyOffline: state.IntentionallyOffline,
}
- return ai.ResourceOperatorStateMaintenanceWindow{
- StartAt: *state.MaintenanceStartAt,
- EndAt: *state.MaintenanceEndAt,
- Reason: state.MaintenanceReason,
- }, true
+ if state.IsInMaintenanceAt(now) {
+ projection.MaintenanceWindow = &ai.ResourceOperatorStateMaintenanceWindow{
+ StartAt: *state.MaintenanceStartAt,
+ EndAt: *state.MaintenanceEndAt,
+ Reason: state.MaintenanceReason,
+ }
+ }
+ return projection, true
},
),
)