alien_core/deployment/status.rs
1//! Deployment status enum and lifecycle phase checks.
2
3use serde::{Deserialize, Serialize};
4
5/// Deployment status in the deployment lifecycle.
6///
7/// For observe-only deployments with no release or stack state, `Running`
8/// means the Operator is attached. Connectivity comes from `lastHeartbeatAt`;
9/// resource health comes from inventory and resource heartbeat data.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
12#[serde(rename_all = "kebab-case")]
13pub enum DeploymentStatus {
14 Pending,
15 PreflightsFailed,
16 InitialSetup,
17 InitialSetupFailed,
18 Provisioning,
19 WaitingForMachines,
20 /// A required deployer secret is missing or invalid in the customer's
21 /// secret store; workloads wait until it is written.
22 WaitingForSecrets,
23 ProvisioningFailed,
24 Running,
25 RefreshFailed,
26 UpdatePending,
27 Updating,
28 UpdateFailed,
29 DeletePending,
30 Deleting,
31 DeleteFailed,
32 TeardownRequired,
33 TeardownFailed,
34 /// Runtime cleanup finished with retained data and recovery inventory.
35 /// The setup owner must remove remaining access; Alien has not verified removal.
36 RetentionRequired,
37 /// The actor removing setup-owned access observed its completion.
38 /// Durable data and recovery inventory remain; only setup teardown writes this status.
39 Retained,
40 Deleted,
41 Error,
42}
43
44impl DeploymentStatus {
45 /// Check if deployment is synced (current state matches desired state).
46 ///
47 /// When synced, no more deployment steps are needed *for the current operation*.
48 /// Note: This doesn't mean the deployment is "done forever":
49 /// - `Running` → heartbeats continue, updates can come
50 /// - `*Failed` → can be retried
51 /// - `Deleted` → can be recreated
52 ///
53 /// "Synced" means: "we've reached the goal of the current deployment phase"
54 pub fn is_synced(&self) -> bool {
55 matches!(
56 self,
57 DeploymentStatus::Running
58 | DeploymentStatus::PreflightsFailed
59 | DeploymentStatus::InitialSetupFailed
60 | DeploymentStatus::ProvisioningFailed
61 | DeploymentStatus::UpdateFailed
62 | DeploymentStatus::DeleteFailed
63 | DeploymentStatus::TeardownRequired
64 | DeploymentStatus::TeardownFailed
65 | DeploymentStatus::RefreshFailed
66 | DeploymentStatus::RetentionRequired
67 | DeploymentStatus::Retained
68 | DeploymentStatus::Deleted
69 | DeploymentStatus::Error
70 )
71 }
72
73 /// Check if deployment is in a failed state that requires retry to proceed.
74 pub fn is_failed(&self) -> bool {
75 matches!(
76 self,
77 DeploymentStatus::PreflightsFailed
78 | DeploymentStatus::InitialSetupFailed
79 | DeploymentStatus::ProvisioningFailed
80 | DeploymentStatus::UpdateFailed
81 | DeploymentStatus::DeleteFailed
82 | DeploymentStatus::TeardownFailed
83 | DeploymentStatus::RefreshFailed
84 | DeploymentStatus::Error
85 )
86 }
87}