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

Add State to ControlPlane.Spec.Crossplane for managing the crossplane state #103

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
60 changes: 60 additions & 0 deletions apis/spaces/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ const (

// ReasonRestorePending indicates that the control plane restore is pending.
ReasonRestorePending xpcommonv1.ConditionReason = "RestorePending"

// ConditionTypeRunning indicates whether the workloads on the Control Plane
// are running or not.
ConditionTypeRunning xpcommonv1.ConditionType = "Running"
sergenyalcin marked this conversation as resolved.
Show resolved Hide resolved
// ReasonPausing indicates that the crossplane and provider workloads are being paused.
ReasonPausing xpcommonv1.ConditionReason = "Pausing"
// ReasonPaused indicates that the crossplane and provider workloads have been paused.
ReasonPaused xpcommonv1.ConditionReason = "Paused"
// ReasonStarting indicates that the crossplane and provider workloads are being started.
ReasonStarting xpcommonv1.ConditionReason = "Starting"
// ReasonStarted indicates that the crossplane and provider workloads have been started.
ReasonStarted xpcommonv1.ConditionReason = "Started"
)

// Healthy returns a condition that indicates the control plane is healthy.
Expand Down Expand Up @@ -203,3 +215,51 @@ func RestorePending() xpcommonv1.Condition {
Message: "Control plane restore is pending",
}
}

// PauseInProgress returns a condition that indicates that the crossplane and
// provider workloads are being paused.
func PauseInProgress() xpcommonv1.Condition {
sergenyalcin marked this conversation as resolved.
Show resolved Hide resolved
return xpcommonv1.Condition{
Type: ConditionTypeRunning,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonPausing,
Message: "The crossplane and provider workloads are being paused",
}
}

// PauseCompleted returns a condition that indicates that the crossplane and
// provider workloads have been paused.
func PauseCompleted() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeRunning,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonPaused,
Message: "The crossplane and provider workloads have been paused",
}
}

// StartInProgress returns a condition that indicates that the crossplane and
// provider workloads are being restarted.
func StartInProgress() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeRunning,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonStarting,
Message: "The crossplane and provider workloads are being started",
}
}

// StartCompleted returns a condition that indicates that the crossplane and
// provider workloads have been restarted.
func StartCompleted() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypeRunning,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonStarted,
Message: "The crossplane and provider workloads have been started",
sergenyalcin marked this conversation as resolved.
Show resolved Hide resolved
}
}
22 changes: 22 additions & 0 deletions apis/spaces/v1beta1/controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ const (
CrossplaneUpgradeRapid CrossplaneUpgradeChannel = "Rapid"
)

// CrossplaneState is the running state for the crossplane and provider workloads.
type CrossplaneState string

const (
// CrossplaneStateRunning switches the crossplane and provider workloads to
// the running state by scaling up them.
CrossplaneStateRunning CrossplaneState = "Running"

// CrossplaneStatePaused switches the crossplane and provider workloads to
// the paused state by scaling down them.
CrossplaneStatePaused CrossplaneState = "Paused"
)

// CrossplaneAutoUpgradeSpec defines the auto upgrade policy for Crossplane.
type CrossplaneAutoUpgradeSpec struct {
// Channel defines the upgrade channels for Crossplane. We support the following channels where 'Stable' is the
Expand Down Expand Up @@ -129,6 +142,15 @@ type CrossplaneSpec struct {
// +optional
// +kubebuilder:default={"channel":"Stable"}
AutoUpgradeSpec *CrossplaneAutoUpgradeSpec `json:"autoUpgrade,omitempty"`

// State defines the state for crossplane and provider workloads. We support
// the following states where 'Running' is the default:
// - Running: Starts/Scales up all crossplane and provider workloads in the ControlPlane
// - Paused: Pauses/Scales down all crossplane and provider workloads in the ControlPlane
// +optional
// +kubebuilder:validation:Enum=Running;Paused
// +kubebuilder:default=Running
State *CrossplaneState `json:"state,omitempty"`
}

// A SecretReference is a reference to a secret in an arbitrary namespace.
Expand Down
5 changes: 5 additions & 0 deletions apis/spaces/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading