@@ -282,14 +282,18 @@ type StageConfig struct {
282282 // +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'Approval' && has(e.waitTime))",message="AfterStageTaskType is Approval, waitTime is not allowed"
283283 // +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'TimedWait' && !has(e.waitTime))",message="AfterStageTaskType is TimedWait, waitTime is required"
284284 AfterStageTasks []AfterStageTask `json:"afterStageTasks,omitempty"`
285+
286+ // The task that needs to be completed successfully before starting the stage.
287+ // +kubebuilder:validation:Optional
288+ BeforeStageTask * BeforeStageTask `json:"beforeStageTask,omitempty"`
285289}
286290
287291// AfterStageTask is the collection of post-stage tasks that ALL need to be completed before moving to the next stage.
288292type AfterStageTask struct {
289293 // The type of the after-stage task.
290294 // +kubebuilder:validation:Enum=TimedWait;Approval
291295 // +kubebuilder:validation:Required
292- Type AfterStageTaskType `json:"type"`
296+ Type StageTaskType `json:"type"`
293297
294298 // The time to wait after all the clusters in the current stage complete the update before moving to the next stage.
295299 // +kubebuilder:validation:Pattern="^0|([0-9]+(\\.[0-9]+)?(s|m|h))+$"
@@ -298,6 +302,14 @@ type AfterStageTask struct {
298302 WaitTime * metav1.Duration `json:"waitTime,omitempty"`
299303}
300304
305+ // BeforeStageTask is the pre-stage task that needs to be completed before starting the stage.
306+ type BeforeStageTask struct {
307+ // The type of the before-stage task.
308+ // +kubebuilder:validation:Enum=Approval
309+ // +kubebuilder:validation:Required
310+ Type StageTaskType `json:"type"`
311+ }
312+
301313// UpdateRunStatus defines the observed state of the ClusterStagedUpdateRun.
302314type UpdateRunStatus struct {
303315 // PolicySnapShotIndexUsed records the policy snapshot index of the ClusterResourcePlacement (CRP) that
@@ -392,7 +404,12 @@ type StageUpdatingStatus struct {
392404 // Empty if the stage has not finished updating all the clusters.
393405 // +kubebuilder:validation:MaxItems=2
394406 // +kubebuilder:validation:Optional
395- AfterStageTaskStatus []AfterStageTaskStatus `json:"afterStageTaskStatus,omitempty"`
407+ AfterStageTaskStatus []StageTaskStatus `json:"afterStageTaskStatus,omitempty"`
408+
409+ // The status of the pre-update task associated with the current stage.
410+ // Nil if the stage has not finished updating all the clusters.
411+ // +kubebuilder:validation:Optional
412+ BeforeStageTaskStatus * StageTaskStatus `json:"beforeStageTaskStatus,omitempty"`
396413
397414 // The time when the update started on the stage. Empty if the stage has not started updating.
398415 // +kubebuilder:validation:Optional
@@ -482,11 +499,11 @@ const (
482499 ClusterUpdatingConditionSucceeded ClusterUpdatingStatusConditionType = "Succeeded"
483500)
484501
485- type AfterStageTaskStatus struct {
486- // The type of the post- update task.
502+ type StageTaskStatus struct {
503+ // The type of the pre or post update task.
487504 // +kubebuilder:validation:Enum=TimedWait;Approval
488505 // +kubebuilder:validation:Required
489- Type AfterStageTaskType `json:"type"`
506+ Type StageTaskType `json:"type"`
490507
491508 // The name of the approval request object that is created for this stage.
492509 // Only valid if the AfterStageTaskType is Approval.
@@ -498,45 +515,45 @@ type AfterStageTaskStatus struct {
498515 // +listType=map
499516 // +listMapKey=type
500517 //
501- // Conditions is an array of current observed conditions for the specific type of post- update task.
518+ // Conditions is an array of current observed conditions for the specific type of pre or post update task.
502519 // Known conditions are "ApprovalRequestCreated", "WaitTimeElapsed", and "ApprovalRequestApproved".
503520 // +kubebuilder:validation:Optional
504521 Conditions []metav1.Condition `json:"conditions,omitempty"`
505522}
506523
507- // AfterStageTaskType identifies a specific type of the AfterStageTask.
524+ // StageTaskType identifies a specific type of the AfterStageTask or BeforeStageTask .
508525// +enum
509- type AfterStageTaskType string
526+ type StageTaskType string
510527
511528const (
512- // AfterStageTaskTypeTimedWait indicates the post- stage task is a timed wait.
513- AfterStageTaskTypeTimedWait AfterStageTaskType = "TimedWait"
529+ // StageTaskTypeTimedWait indicates the stage task is a timed wait.
530+ StageTaskTypeTimedWait StageTaskType = "TimedWait"
514531
515- // AfterStageTaskTypeApproval indicates the post- stage task is an approval.
516- AfterStageTaskTypeApproval AfterStageTaskType = "Approval"
532+ // StageTaskTypeApproval indicates the stage task is an approval.
533+ StageTaskTypeApproval StageTaskType = "Approval"
517534)
518535
519- // AfterStageTaskConditionType identifies a specific condition of the AfterStageTask.
536+ // StageTaskConditionType identifies a specific condition of the AfterStageTask or BeforeStageTask .
520537// +enum
521- type AfterStageTaskConditionType string
538+ type StageTaskConditionType string
522539
523540const (
524- // AfterStageTaskConditionApprovalRequestCreated indicates if the approval request has been created.
541+ // StageTaskConditionApprovalRequestCreated indicates if the approval request has been created.
525542 // Its condition status can be:
526543 // - "True": The approval request has been created.
527- AfterStageTaskConditionApprovalRequestCreated AfterStageTaskConditionType = "ApprovalRequestCreated"
544+ StageTaskConditionApprovalRequestCreated StageTaskConditionType = "ApprovalRequestCreated"
528545
529- // AfterStageTaskConditionApprovalRequestApproved indicates if the approval request has been approved.
546+ // StageTaskConditionApprovalRequestApproved indicates if the approval request has been approved.
530547 // Its condition status can be:
531548 // - "True": The approval request has been approved.
532- AfterStageTaskConditionApprovalRequestApproved AfterStageTaskConditionType = "ApprovalRequestApproved"
549+ StageTaskConditionApprovalRequestApproved StageTaskConditionType = "ApprovalRequestApproved"
533550
534- // AfterStageTaskConditionWaitTimeElapsed indicates if the wait time after each stage has elapsed.
551+ // StageTaskConditionWaitTimeElapsed indicates if the wait time after each stage has elapsed.
535552 // If the status is "False", the condition message will include the remaining wait time.
536553 // Its condition status can be:
537554 // - "True": The wait time has elapsed.
538555 // - "False": The wait time has not elapsed.
539- AfterStageTaskConditionWaitTimeElapsed AfterStageTaskConditionType = "WaitTimeElapsed"
556+ StageTaskConditionWaitTimeElapsed StageTaskConditionType = "WaitTimeElapsed"
540557)
541558
542559// ClusterStagedUpdateRunList contains a list of ClusterStagedUpdateRun.
0 commit comments