Add policy_stopped workload status and enforce policy gate on restart#4857
Add policy_stopped workload status and enforce policy gate on restart#4857
Conversation
Introduces WorkloadStatusPolicyStopped as a first-class workload status to support enterprise policy enforcement. When non-registry servers are blocked by policy, workloads can be set to this status so the UI and CLI can surface the reason clearly, rather than showing an opaque "error". - Add WorkloadStatusPolicyStopped constant to pkg/container/runtime/types.go - Update enums tag in pkg/core/workload.go to include policy_stopped - Map policy_stopped to BackendUnhealthy in mapWorkloadStatusToVMCPHealth - Call EagerCheckCreateServer in restartSingleWorkload so the policy gate blocks restart of workloads that violate the active policy - Add 🚫 indicator for policy_stopped in CLI list and status output, following the existing⚠️ pattern for unauthenticated workloads - Regenerate swagger docs to include the new status enum value Part of stacklok/stacklok-enterprise-platform#406 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4857 +/- ##
=======================================
Coverage 69.43% 69.43%
=======================================
Files 539 539
Lines 55750 55760 +10
=======================================
+ Hits 38708 38716 +8
- Misses 14067 14069 +2
Partials 2975 2975 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add all WorkloadStatus cases to the switches in list and status commands to satisfy the exhaustive linter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@claude can you verify if the comments were addressed? |
- Add policy_stopped to workloadStatusResponse enums tag so the swagger spec for the status endpoint includes the new value - Add EagerCheckCreateServer check in maybeSetupContainerWorkload after loadRunnerFromState to cover the path where the outer LoadState call fails on a partial name but succeeds after label-based name resolution - Regenerate swagger docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@claude can you review if the comments have been addressed? |
|
Claude finished @reyortiz3's task in 56s —— View job Review comment verification
Both previous review comments have been addressed. ✅ Comment 1 — Missing
|
…ndicator - Call SetWorkloadStatus with WorkloadStatusPolicyStopped in both policy gate failure paths in restartSingleWorkload and maybeSetupContainerWorkload, so a blocked restart transitions the workload into the new status instead of leaving it as stopped - Extract the status indicator switch (⚠️ / 🚫) from list.go and status.go into a single workloadStatusIndicator helper in common.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@claude can you review what comments are pending address? |
|
Claude finished @reyortiz3's task in 1m 18s —— View job Pending comment review
All three of @jhrozek's review comments have been addressed. Here's the breakdown: Comment 1 —
|
| Comment | Commenter | Status |
|---|---|---|
SetWorkloadStatus never called for policy_stopped |
jhrozek | ✅ Fixed |
BackendUnhealthy vs dedicated BackendPolicyStopped |
jhrozek | 💬 Author justified; awaiting reviewer acknowledgement |
Duplicated switch block in list.go/status.go |
jhrozek | ✅ Fixed (extracted to common.go) |
The only item that is technically still "open" is the BackendUnhealthy mapping question — but it's a design discussion, not a required change. The thread needs @jhrozek to respond or be dismissed.
jhrozek
left a comment
There was a problem hiding this comment.
Changes look good. The status-setting and deduplication fixes address the review comments well.
Summary
non_registry_serverspolicy on existing workloads.WorkloadStatusPolicyStoppedas a first-class status (following the precedent ofWorkloadStatusUnauthenticated) so the policy layer can set it when stopping a non-compliant workload, giving the UI and CLI a programmatic signal rather than freeform text.EagerCheckCreateServerinrestartSingleWorkloadso the policy gate blocks any restart attempt for workloads that violate the active policy.Changes
pkg/container/runtime/types.goWorkloadStatusPolicyStoppedconstantpkg/core/workload.gopolicy_stoppedtoenumstag for swaggerpkg/workloads/manager.gopolicy_stopped→BackendUnhealthy; callEagerCheckCreateServerin restart pathcmd/thv/app/list.go,status.gopolicy_stoppedin CLI outputdocs/server/swagger.*,docs.goType of change
Test plan
task buildpassestask testpasses (pre-existing failures inpkg/clientandpkg/telemetryare unrelated to this change and reproduce onmain)task docsDoes this introduce a user-facing change?
CLI
listandstatuscommands will show🚫 policy_stoppedfor workloads stopped by policy, making the reason immediately visible rather than showing a plainstoppedorerror.Generated with Claude Code