diff --git a/apis/spaces/v1beta1/conditions.go b/apis/spaces/v1beta1/conditions.go index 281fe3e..0ce6333 100644 --- a/apis/spaces/v1beta1/conditions.go +++ b/apis/spaces/v1beta1/conditions.go @@ -13,6 +13,20 @@ import ( ) const ( + // ConditionTypeHealthy indicates that the control plane is healthy. + ConditionTypeHealthy xpcommonv1.ConditionType = "Healthy" + // ReasonHealthy indicates that the control plane is healthy. + ReasonHealthy xpcommonv1.ConditionReason = "HealthyControlPlane" + // ReasonUnhealthy indicates that the control plane is unhealthy. + ReasonUnhealthy xpcommonv1.ConditionReason = "UnhealthyControlPlane" + + // ConditionTypeControlPlaneProvisioned indicates that the control plane is provisioned. + ConditionTypeControlPlaneProvisioned xpcommonv1.ConditionType = "ControlPlaneProvisioned" + // ReasonProvisioned indicates that the control plane is provisioned. + ReasonProvisioned xpcommonv1.ConditionReason = "Provisioned" + // ReasonProvisioningError indicates that the control plane provisioning has failed. + ReasonProvisioningError xpcommonv1.ConditionReason = "ProvisioningError" + // ConditionTypeSourceSynced indicates that the git source is in sync. ConditionTypeSourceSynced xpcommonv1.ConditionType = "SourceSynced" // ReasonSourceCompleted indicates that the git sync has been completed. @@ -20,18 +34,6 @@ const ( // ReasonSourceInProgress indicates that the git sync is still in progress. ReasonSourceInProgress xpcommonv1.ConditionReason = "InProgress" - // ConditionTypeScheduled indicates that the control plane has been scheduled. - ConditionTypeScheduled xpcommonv1.ConditionType = "Scheduled" - // ReasonScheduled indicates that the control plane has been scheduled. - ReasonScheduled xpcommonv1.ConditionReason = "Scheduled" - // ReasonSchedulingError indicates that the control plane scheduling had an error. - ReasonSchedulingError xpcommonv1.ConditionReason = "SchedulingError" - // ReasonSchedulingFailed indicates that the control plane scheduling did not succeed - // for non-error reasons, e.g. capacity. - ReasonSchedulingFailed xpcommonv1.ConditionReason = "ScheduleFailed" - // ReasonDeploymentFailed indicates that the control plane deployment did not succeed. - ReasonDeploymentFailed xpcommonv1.ConditionReason = "DeploymentFailed" - // ConditionTypeSupported indicates that the control plane is running a // supported version of Crossplane. ConditionTypeSupported xpcommonv1.ConditionType = "Supported" @@ -53,85 +55,92 @@ const ( ReasonRestorePending xpcommonv1.ConditionReason = "RestorePending" ) -// SourceSynced returns a condition that indicates the control plane is in sync -// with the source. -func SourceSynced(revision string) xpcommonv1.Condition { +// Healthy returns a condition that indicates the control plane is healthy. +func Healthy() xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeSourceSynced, + Type: ConditionTypeHealthy, Status: corev1.ConditionTrue, LastTransitionTime: metav1.Now(), - Reason: ReasonSourceCompleted, - Message: fmt.Sprintf("In sync with the revision %s", revision), + Reason: ReasonHealthy, } } -// SourceInProgress returns a condition that indicates the control plane is still -// processing resources coming from the source. -func SourceInProgress(revision string) xpcommonv1.Condition { +// Unhealthy returns a condition that indicates the control plane is unhealthy. +func Unhealthy() xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeSourceSynced, + Type: ConditionTypeHealthy, Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), - Reason: ReasonSourceInProgress, - Message: fmt.Sprintf("Syncing revision %s", revision), + Reason: ReasonUnhealthy, } } -// SourceError returns a condition that indicates the source operation of the -// control plane has failed. -func SourceError(err error) xpcommonv1.Condition { +// ControlPlaneProvisioned returns a condition that indicates the control plane +// has been provisioned. +func ControlPlaneProvisioned() xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeSourceSynced, - Status: corev1.ConditionFalse, + Type: ConditionTypeControlPlaneProvisioned, + Status: corev1.ConditionTrue, LastTransitionTime: metav1.Now(), - Reason: ReasonSourceInProgress, - Message: err.Error(), + Reason: ReasonProvisioned, } } -// Scheduled returns a condition that indicates that scheduling of the -// control plane has succeeded. -func Scheduled() xpcommonv1.Condition { +// ControlPlaneProvisionInProgress returns a condition that indicates the control +// plane is still being provisioned. +func ControlPlaneProvisionInProgress() xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeScheduled, - Status: corev1.ConditionTrue, + Type: ConditionTypeControlPlaneProvisioned, + Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), - Reason: ReasonScheduled, + Reason: ReasonProvisioned, } } -// SchedulingError returns a condition that indicates that scheduling of the -// control plane had an error. -func SchedulingError(err error) xpcommonv1.Condition { +// ControlPlaneProvisioningError returns a condition that indicates the control +// plane provisioning has failed. +func ControlPlaneProvisioningError(err error) xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeScheduled, + Type: ConditionTypeControlPlaneProvisioned, Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), - Reason: ReasonSchedulingError, + Reason: ReasonProvisioningError, Message: err.Error(), } } -// SchedulingFailed returns a condition that indicates that scheduling of the -// control plane did not succeed. -func SchedulingFailed(reason string) xpcommonv1.Condition { +// SourceSynced returns a condition that indicates the control plane is in sync +// with the source. +func SourceSynced(revision string) xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeScheduled, + Type: ConditionTypeSourceSynced, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.Now(), + Reason: ReasonSourceCompleted, + Message: fmt.Sprintf("In sync with the revision %s", revision), + } +} + +// SourceInProgress returns a condition that indicates the control plane is still +// processing resources coming from the source. +func SourceInProgress(revision string) xpcommonv1.Condition { + return xpcommonv1.Condition{ + Type: ConditionTypeSourceSynced, Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), - Reason: ReasonSchedulingFailed, - Message: reason, + Reason: ReasonSourceInProgress, + Message: fmt.Sprintf("Syncing revision %s", revision), } } -// DeploymentFailed returns a condition that indicates that deployment of the -// control plane to a host cluster did not succeed. -func DeploymentFailed(err error) xpcommonv1.Condition { +// SourceError returns a condition that indicates the source operation of the +// control plane has failed. +func SourceError(err error) xpcommonv1.Condition { return xpcommonv1.Condition{ - Type: ConditionTypeScheduled, + Type: ConditionTypeSourceSynced, Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), - Reason: ReasonDeploymentFailed, + Reason: ReasonSourceInProgress, Message: err.Error(), } } diff --git a/apis/spaces/v1beta1/controlplane_types.go b/apis/spaces/v1beta1/controlplane_types.go index 4d814ab..1338aec 100644 --- a/apis/spaces/v1beta1/controlplane_types.go +++ b/apis/spaces/v1beta1/controlplane_types.go @@ -365,7 +365,9 @@ type Restore struct { // A ControlPlaneStatus represents the observed state of a ControlPlane. type ControlPlaneStatus struct { xpv1.ResourceStatus `json:",inline"` - + // Message is a human-readable message indicating details about why the + // ControlPlane is in this condition. + Message string `json:"message,omitempty"` ControlPlaneID string `json:"controlPlaneID,omitempty"` HostClusterID string `json:"hostClusterID,omitempty"` @@ -377,9 +379,9 @@ type ControlPlaneStatus struct { // +kubebuilder:object:root=true // +kubebuilder:storageversion // +kubebuilder:printcolumn:name="Crossplane",type="string",JSONPath=".spec.crossplane.version" -// +kubebuilder:printcolumn:name="Synced",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" -// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=`.metadata.annotations['internal\.spaces\.upbound\.io/message']` +// +kubebuilder:printcolumn:name="Healthy",type="string",JSONPath=".status.conditions[?(@.type=='Healthy')].status" +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=`.status.message` // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:subresource:status // +kubebuilder:resource:scope=Namespaced,categories=spaces,shortName=ctp;ctps