Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlPlanes: remove scheduled and add healthy condition #97

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 62 additions & 53 deletions apis/spaces/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ 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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super happy with the name of this condition, open for suggestions.

This will basically indicate that we are done with deploying stuff that goes into control plane, some example, crossplane, some crds, some roles for external controllers.

// 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.
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,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(),
}
}
Expand Down
8 changes: 5 additions & 3 deletions apis/spaces/v1beta1/controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
turkenh marked this conversation as resolved.
Show resolved Hide resolved
ControlPlaneID string `json:"controlPlaneID,omitempty"`
HostClusterID string `json:"hostClusterID,omitempty"`

Expand All @@ -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
Expand Down
Loading