Skip to content

Commit

Permalink
Add ReconciliationPolicy to ControlPlane API to managing the reconcil…
Browse files Browse the repository at this point in the history
…iation/pause policies

Signed-off-by: Sergen Yalçın <[email protected]>
  • Loading branch information
sergenyalcin committed Jul 24, 2024
1 parent 92e3d90 commit fec342e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
59 changes: 59 additions & 0 deletions apis/spaces/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ const (

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

// ConditionTypePaused indicates that the control plane has been paused.
ConditionTypePaused xpcommonv1.ConditionType = "Paused"
// ReasonPauseInProgress indicates that the control plane is being paused.
ReasonPauseInProgress xpcommonv1.ConditionReason = "InProgress"
// ReasonPauseCompleted indicates that the control plane has been paused.
ReasonPauseCompleted xpcommonv1.ConditionReason = "Completed"
// ReasonPauseRestartInProgress indicates that the control plane is being restarted.
ReasonPauseRestartInProgress xpcommonv1.ConditionReason = "RestartInProgress"
// ReasonPauseRestarted indicates that the control plane has been restarted.
ReasonPauseRestarted xpcommonv1.ConditionReason = "Restarted"
)

// SourceSynced returns a condition that indicates the control plane is in sync
Expand Down Expand Up @@ -194,3 +205,51 @@ func RestorePending() xpcommonv1.Condition {
Message: "Control plane restore is pending",
}
}

// PauseInProgress returns a condition that indicates that the control plane
// is being paused.
func PauseInProgress() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypePaused,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonPauseInProgress,
Message: "Control plane is being paused",
}
}

// PauseCompleted returns a condition that indicates that the control plane
// has been paused.
func PauseCompleted() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypePaused,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonPauseCompleted,
Message: "Control plane has been paused",
}
}

// PauseRestartInProgress returns a condition that indicates that the control
// plane is being restarted.
func PauseRestartInProgress() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypePaused,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonPauseRestartInProgress,
Message: "Control plane is being restarted",
}
}

// PauseRestarted returns a condition that indicates that the control
// plane has been restarted.
func PauseRestarted() xpcommonv1.Condition {
return xpcommonv1.Condition{
Type: ConditionTypePaused,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonPauseRestarted,
Message: "Control plane has been restarted",
}
}
20 changes: 20 additions & 0 deletions apis/spaces/v1beta1/controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const (
AuthSecretKeySSHKnownHosts = "knownHosts"

CASecretKeyCAFile = "ca.crt"

PauseControlNone = "None"
PauseControlAllCrossplane = "AllCrossplane"
)

const (
Expand Down Expand Up @@ -342,6 +345,11 @@ type ControlPlaneSpec struct {
// +optional
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.finishedAt) || oldSelf.finishedAt == self.finishedAt",message="finishedAt is immutable once set"
Restore *Restore `json:"restore,omitempty"`

// ReconciliationPolicy specifies the reconciliation policies on the
// crossplane and the workloads that work on the ControlPlane
// +optional
ReconciliationPolicy *ReconciliationPolicy `json:"reconciliationPolicy,omitempty"`
}

// Restore specifies details about the backup to restore from.
Expand All @@ -362,6 +370,18 @@ type Restore struct {
FinishedAt *metav1.Time `json:"finishedAt,omitempty"`
}

type ReconciliationPolicy struct {
// PausedControllers controls whether the ControlPlane is paused or not.
// It has two valid values.
// AllCrossplane: Pauses/Scales Down all crossplane and provider workloads
// in the ControlPlane
// None: Restarts/Scales Up all crossplane and provider workloads in the
// ControlPlane
// +kubebuilder:validation:Enum=None;AllCrossplane
// +kubebuilder:default=None
PausedControllers string `json:"pausedControllers,omitempty"`
}

// A ControlPlaneStatus represents the observed state of a ControlPlane.
type ControlPlaneStatus struct {
xpv1.ResourceStatus `json:",inline"`
Expand Down
20 changes: 20 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.

0 comments on commit fec342e

Please sign in to comment.