-
Notifications
You must be signed in to change notification settings - Fork 38
fix: fix waitTime and approval task blocking each other #1063
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -267,6 +267,8 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta | |||||
| klog.V(2).InfoS("There is no after stage task for this stage", "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| return true, 0, nil | ||||||
| } | ||||||
| passed := true | ||||||
| afterStageWaitTime := time.Duration(-1) | ||||||
| for i, task := range updatingStage.AfterStageTasks { | ||||||
| switch task.Type { | ||||||
| case placementv1beta1.AfterStageTaskTypeTimedWait: | ||||||
|
|
@@ -275,10 +277,12 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta | |||||
| waitTime := time.Until(waitStartTime.Add(task.WaitTime.Duration)) | ||||||
| if waitTime > 0 { | ||||||
| klog.V(2).InfoS("The after stage task still need to wait", "waitStartTime", waitStartTime, "waitTime", task.WaitTime, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| return false, waitTime, nil | ||||||
| passed = false | ||||||
| afterStageWaitTime = waitTime | ||||||
| } else { | ||||||
| markAfterStageWaitTimeElapsed(&updatingStageStatus.AfterStageTaskStatus[i], updateRun.Generation) | ||||||
| klog.V(2).InfoS("The after stage wait task has completed", "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| } | ||||||
| markAfterStageWaitTimeElapsed(&updatingStageStatus.AfterStageTaskStatus[i], updateRun.Generation) | ||||||
| klog.V(2).InfoS("The after stage wait task has completed", "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| case placementv1beta1.AfterStageTaskTypeApproval: | ||||||
| // Check if the approval request has been created. | ||||||
| approvalRequest := placementv1beta1.ClusterApprovalRequest{ | ||||||
|
|
@@ -310,18 +314,24 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta | |||||
| return false, -1, fmt.Errorf("%w: %s", errStagedUpdatedAborted, unexpectedErr.Error()) | ||||||
| } | ||||||
| approvalAccepted := condition.IsConditionStatusTrue(meta.FindStatusCondition(approvalRequest.Status.Conditions, string(placementv1beta1.ApprovalRequestConditionApprovalAccepted)), approvalRequest.Generation) | ||||||
| // Approved state should not change once the approval is accepted. | ||||||
| if !approvalAccepted && !condition.IsConditionStatusTrue(meta.FindStatusCondition(approvalRequest.Status.Conditions, string(placementv1beta1.ApprovalRequestConditionApproved)), approvalRequest.Generation) { | ||||||
| approved := condition.IsConditionStatusTrue(meta.FindStatusCondition(approvalRequest.Status.Conditions, string(placementv1beta1.ApprovalRequestConditionApproved)), approvalRequest.Generation) | ||||||
| if !approvalAccepted && !approved { | ||||||
jwtty marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| klog.V(2).InfoS("The approval request has not been approved yet", "approvalRequestTask", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| return false, -1, nil | ||||||
| passed = false | ||||||
| continue | ||||||
| } | ||||||
| klog.V(2).InfoS("The approval request has been approved", "approvalRequestTask", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| if !approvalAccepted { | ||||||
| if err = r.updateApprovalRequestAccepted(ctx, &approvalRequest); err != nil { | ||||||
| klog.ErrorS(err, "Failed to accept the approved approval request", "approvalRequest", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| // retriable err | ||||||
| return false, 0, err | ||||||
| if approved { | ||||||
| klog.V(2).InfoS("The approval request has been approved", "approvalRequestTask", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| if !approvalAccepted { | ||||||
| if err = r.updateApprovalRequestAccepted(ctx, &approvalRequest); err != nil { | ||||||
| klog.ErrorS(err, "Failed to accept the approved approval request", "approvalRequest", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| // retriable err | ||||||
| return false, -1, err | ||||||
| } | ||||||
| } | ||||||
| } else { | ||||||
| // Approved state should not change once the approval is accepted. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| klog.V(2).InfoS("The approval request has been approval-accepted, ignoring changing back to unapproved", "approvalRequestTask", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| } | ||||||
| markAfterStageRequestApproved(&updatingStageStatus.AfterStageTaskStatus[i], updateRun.Generation) | ||||||
| } else { | ||||||
|
|
@@ -333,12 +343,14 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta | |||||
| // The approval request has been created for the first time. | ||||||
| klog.V(2).InfoS("The approval request has been created", "approvalRequestTask", requestRef, "stage", updatingStage.Name, "clusterStagedUpdateRun", updateRunRef) | ||||||
| markAfterStageRequestCreated(&updatingStageStatus.AfterStageTaskStatus[i], updateRun.Generation) | ||||||
| return false, -1, nil | ||||||
| passed = false | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| // All the after stage tasks have been finished or the for loop will return before this line. | ||||||
| return true, 0, nil | ||||||
| if passed { | ||||||
| afterStageWaitTime = 0 | ||||||
| } | ||||||
| return passed, afterStageWaitTime, nil | ||||||
| } | ||||||
|
|
||||||
| // updateBindingRolloutStarted updates the binding status to indicate the rollout has started. | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.