Skip to content

Commit

Permalink
ControlPlanes: remove scheduled and add healthy condition
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <[email protected]>
  • Loading branch information
turkenh committed Jul 3, 2024
1 parent 92e3d90 commit b04a03d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 61 deletions.
85 changes: 26 additions & 59 deletions apis/spaces/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +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"

// ConditionTypeSourceSynced indicates that the git source is in sync.
ConditionTypeSourceSynced xpcommonv1.ConditionType = "SourceSynced"
// ReasonSourceCompleted indicates that the git sync has been completed.
ReasonSourceCompleted xpcommonv1.ConditionReason = "Completed"
// 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"
Expand All @@ -53,6 +48,25 @@ const (
ReasonRestorePending xpcommonv1.ConditionReason = "RestorePending"
)

func Healthy() xpcommonv1.Condition {

Check failure on line 51 in apis/spaces/v1beta1/conditions.go

View workflow job for this annotation

GitHub Actions / lint

exported function `Healthy` should have comment or be unexported (golint)
return xpcommonv1.Condition{
Type: ConditionTypeHealthy,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonHealthy,
}
}

func Unhealthy(err error) xpcommonv1.Condition {

Check failure on line 60 in apis/spaces/v1beta1/conditions.go

View workflow job for this annotation

GitHub Actions / lint

exported function `Unhealthy` should have comment or be unexported (golint)
return xpcommonv1.Condition{
Type: ConditionTypeHealthy,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonUnhealthy,
Message: err.Error(),
}
}

// SourceSynced returns a condition that indicates the control plane is in sync
// with the source.
func SourceSynced(revision string) xpcommonv1.Condition {
Expand Down Expand Up @@ -89,53 +103,6 @@ func SourceError(err error) xpcommonv1.Condition {
}
}

// Scheduled returns a condition that indicates that scheduling of the
// control plane has succeeded.
func Scheduled() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeScheduled,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonScheduled,
}
}

// SchedulingError returns a condition that indicates that scheduling of the
// control plane had an error.
func SchedulingError(err error) xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeScheduled,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonSchedulingError,
Message: err.Error(),
}
}

// SchedulingFailed returns a condition that indicates that scheduling of the
// control plane did not succeed.
func SchedulingFailed(reason string) xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeScheduled,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonSchedulingFailed,
Message: reason,
}
}

// 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 {
return xpcommonv1.Condition{
Type: ConditionTypeScheduled,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonDeploymentFailed,
Message: err.Error(),
}
}

// SupportedCrossplaneVersion returns a condition that indicates that the
// control plane is running a supported version of Crossplane.
func SupportedCrossplaneVersion() xpcommonv1.Condition {
Expand Down
5 changes: 3 additions & 2 deletions apis/spaces/v1beta1/controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ type Restore struct {
type ControlPlaneStatus struct {
xpv1.ResourceStatus `json:",inline"`

Message string `json:"message,omitempty"`
ControlPlaneID string `json:"controlPlaneID,omitempty"`
HostClusterID string `json:"hostClusterID,omitempty"`

Expand All @@ -377,9 +378,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
Expand Down

0 comments on commit b04a03d

Please sign in to comment.