Skip to content

Commit f136911

Browse files
authored
interface: beforeStageTask for updateRun (#308)
1 parent 1723b18 commit f136911

18 files changed

+820
-211
lines changed

apis/placement/v1beta1/stageupdate_types.go

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,23 @@ type StageConfig struct {
293293
// +kubebuilder:validation:Optional
294294
// +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'Approval' && has(e.waitTime))",message="AfterStageTaskType is Approval, waitTime is not allowed"
295295
// +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'TimedWait' && !has(e.waitTime))",message="AfterStageTaskType is TimedWait, waitTime is required"
296-
AfterStageTasks []AfterStageTask `json:"afterStageTasks,omitempty"`
296+
AfterStageTasks []StageTask `json:"afterStageTasks,omitempty"`
297+
298+
// The collection of tasks that needs to completed successfully by each stage before starting the stage.
299+
// Each task is executed in parallel and there cannot be more than one task of the same type.
300+
// +kubebuilder:validation:Optional
301+
// +kubebuilder:validation:MaxItems=1
302+
// +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'Approval' && has(e.waitTime))",message="AfterStageTaskType is Approval, waitTime is not allowed"
303+
// +kubebuilder:validation:XValidation:rule="!self.exists(e, e.type == 'TimedWait')",message="BeforeStageTaskType cannot be TimedWait"
304+
BeforeStageTasks []StageTask `json:"beforeStageTasks,omitempty"`
297305
}
298306

299-
// AfterStageTask is the collection of post-stage tasks that ALL need to be completed before moving to the next stage.
300-
type AfterStageTask struct {
301-
// The type of the after-stage task.
307+
// StageTask is the pre or post stage task that needs to be completed before starting or moving to the next stage.
308+
type StageTask struct {
309+
// The type of the before or after stage task.
302310
// +kubebuilder:validation:Enum=TimedWait;Approval
303311
// +kubebuilder:validation:Required
304-
Type AfterStageTaskType `json:"type"`
312+
Type StageTaskType `json:"type"`
305313

306314
// The time to wait after all the clusters in the current stage complete the update before moving to the next stage.
307315
// +kubebuilder:validation:Pattern="^0|([0-9]+(\\.[0-9]+)?(s|m|h))+$"
@@ -404,7 +412,12 @@ type StageUpdatingStatus struct {
404412
// Empty if the stage has not finished updating all the clusters.
405413
// +kubebuilder:validation:MaxItems=2
406414
// +kubebuilder:validation:Optional
407-
AfterStageTaskStatus []AfterStageTaskStatus `json:"afterStageTaskStatus,omitempty"`
415+
AfterStageTaskStatus []StageTaskStatus `json:"afterStageTaskStatus,omitempty"`
416+
417+
// The status of the pre-update tasks associated with the current stage.
418+
// +kubebuilder:validation:MaxItems=1
419+
// +kubebuilder:validation:Optional
420+
BeforeStageTaskStatus []StageTaskStatus `json:"beforeStageTaskStatus,omitempty"`
408421

409422
// The time when the update started on the stage. Empty if the stage has not started updating.
410423
// +kubebuilder:validation:Optional
@@ -494,11 +507,11 @@ const (
494507
ClusterUpdatingConditionSucceeded ClusterUpdatingStatusConditionType = "Succeeded"
495508
)
496509

497-
type AfterStageTaskStatus struct {
498-
// The type of the post-update task.
510+
type StageTaskStatus struct {
511+
// The type of the pre or post update task.
499512
// +kubebuilder:validation:Enum=TimedWait;Approval
500513
// +kubebuilder:validation:Required
501-
Type AfterStageTaskType `json:"type"`
514+
Type StageTaskType `json:"type"`
502515

503516
// The name of the approval request object that is created for this stage.
504517
// Only valid if the AfterStageTaskType is Approval.
@@ -510,45 +523,45 @@ type AfterStageTaskStatus struct {
510523
// +listType=map
511524
// +listMapKey=type
512525
//
513-
// Conditions is an array of current observed conditions for the specific type of post-update task.
526+
// Conditions is an array of current observed conditions for the specific type of pre or post update task.
514527
// Known conditions are "ApprovalRequestCreated", "WaitTimeElapsed", and "ApprovalRequestApproved".
515528
// +kubebuilder:validation:Optional
516529
Conditions []metav1.Condition `json:"conditions,omitempty"`
517530
}
518531

519-
// AfterStageTaskType identifies a specific type of the AfterStageTask.
532+
// StageTaskType identifies a specific type of the AfterStageTask or BeforeStageTask.
520533
// +enum
521-
type AfterStageTaskType string
534+
type StageTaskType string
522535

523536
const (
524-
// AfterStageTaskTypeTimedWait indicates the post-stage task is a timed wait.
525-
AfterStageTaskTypeTimedWait AfterStageTaskType = "TimedWait"
537+
// StageTaskTypeTimedWait indicates the stage task is a timed wait.
538+
StageTaskTypeTimedWait StageTaskType = "TimedWait"
526539

527-
// AfterStageTaskTypeApproval indicates the post-stage task is an approval.
528-
AfterStageTaskTypeApproval AfterStageTaskType = "Approval"
540+
// StageTaskTypeApproval indicates the stage task is an approval.
541+
StageTaskTypeApproval StageTaskType = "Approval"
529542
)
530543

531-
// AfterStageTaskConditionType identifies a specific condition of the AfterStageTask.
544+
// StageTaskConditionType identifies a specific condition of the AfterStageTask or BeforeStageTask.
532545
// +enum
533-
type AfterStageTaskConditionType string
546+
type StageTaskConditionType string
534547

535548
const (
536-
// AfterStageTaskConditionApprovalRequestCreated indicates if the approval request has been created.
549+
// StageTaskConditionApprovalRequestCreated indicates if the approval request has been created.
537550
// Its condition status can be:
538551
// - "True": The approval request has been created.
539-
AfterStageTaskConditionApprovalRequestCreated AfterStageTaskConditionType = "ApprovalRequestCreated"
552+
StageTaskConditionApprovalRequestCreated StageTaskConditionType = "ApprovalRequestCreated"
540553

541-
// AfterStageTaskConditionApprovalRequestApproved indicates if the approval request has been approved.
554+
// StageTaskConditionApprovalRequestApproved indicates if the approval request has been approved.
542555
// Its condition status can be:
543556
// - "True": The approval request has been approved.
544-
AfterStageTaskConditionApprovalRequestApproved AfterStageTaskConditionType = "ApprovalRequestApproved"
557+
StageTaskConditionApprovalRequestApproved StageTaskConditionType = "ApprovalRequestApproved"
545558

546-
// AfterStageTaskConditionWaitTimeElapsed indicates if the wait time after each stage has elapsed.
559+
// StageTaskConditionWaitTimeElapsed indicates if the wait time after each stage has elapsed.
547560
// If the status is "False", the condition message will include the remaining wait time.
548561
// Its condition status can be:
549562
// - "True": The wait time has elapsed.
550563
// - "False": The wait time has not elapsed.
551-
AfterStageTaskConditionWaitTimeElapsed AfterStageTaskConditionType = "WaitTimeElapsed"
564+
StageTaskConditionWaitTimeElapsed StageTaskConditionType = "WaitTimeElapsed"
552565
)
553566

554567
// ClusterStagedUpdateRunList contains a list of ClusterStagedUpdateRun.

apis/placement/v1beta1/zz_generated.deepcopy.go

Lines changed: 58 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)