-
Notifications
You must be signed in to change notification settings - Fork 20
fix: add label to update run approval object to distinguish between before and after stage tasks #356
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
Open
britaniar
wants to merge
5
commits into
kubefleet-dev:main
Choose a base branch
from
britaniar:fixBeforeStageTask
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: add label to update run approval object to distinguish between before and after stage tasks #356
Changes from 4 commits
Commits
Show all changes
5 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
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
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 |
|---|---|---|
|
|
@@ -83,10 +83,6 @@ func (r *Reconciler) execute( | |
| // which would update the lastTransitionTime even though the status hasn't effectively changed. | ||
| markUpdateRunProgressingIfNotWaitingOrStuck(updateRun) | ||
| if updatingStageIndex < len(updateRunStatus.StagesStatus) { | ||
| maxConcurrency, err := calculateMaxConcurrencyValue(updateRunStatus, updatingStageIndex) | ||
| if err != nil { | ||
| return false, 0, err | ||
| } | ||
| updatingStageStatus = &updateRunStatus.StagesStatus[updatingStageIndex] | ||
| approved, err := r.checkBeforeStageTasksStatus(ctx, updatingStageIndex, updateRun) | ||
| if err != nil { | ||
|
|
@@ -97,6 +93,10 @@ func (r *Reconciler) execute( | |
| markUpdateRunWaiting(updateRun, fmt.Sprintf(condition.UpdateRunWaitingMessageFmt, "before-stage", updatingStageStatus.StageName)) | ||
| return false, stageUpdatingWaitTime, nil | ||
| } | ||
| maxConcurrency, err := calculateMaxConcurrencyValue(updateRunStatus, updatingStageIndex) | ||
|
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. why is maxConcurrency calculation included in this PR? |
||
| if err != nil { | ||
| return false, 0, err | ||
| } | ||
| waitTime, err = r.executeUpdatingStage(ctx, updateRun, updatingStageIndex, toBeUpdatedBindings, maxConcurrency) | ||
| // The execution has not finished yet. | ||
| return false, waitTime, err | ||
|
|
@@ -111,17 +111,17 @@ func (r *Reconciler) execute( | |
| func (r *Reconciler) checkBeforeStageTasksStatus(ctx context.Context, updatingStageIndex int, updateRun placementv1beta1.UpdateRunObj) (bool, error) { | ||
| updateRunRef := klog.KObj(updateRun) | ||
| updateRunStatus := updateRun.GetUpdateRunStatus() | ||
| updatingStageStatus := &updateRunStatus.StagesStatus[updatingStageIndex] | ||
| updatingStage := &updateRunStatus.UpdateStrategySnapshot.Stages[updatingStageIndex] | ||
| if updatingStage.BeforeStageTasks == nil { | ||
| klog.V(2).InfoS("There is no before stage task for this stage", "stage", updatingStage.Name, "updateRun", updateRunRef) | ||
| return true, nil | ||
| } | ||
|
|
||
| updatingStageStatus := &updateRunStatus.StagesStatus[updatingStageIndex] | ||
| for i, task := range updatingStage.BeforeStageTasks { | ||
| switch task.Type { | ||
| case placementv1beta1.StageTaskTypeApproval: | ||
| approved, err := r.handleStageApprovalTask(ctx, &updatingStageStatus.BeforeStageTaskStatus[i], updatingStage, updateRun) | ||
| approved, err := r.handleStageApprovalTask(ctx, &updatingStageStatus.BeforeStageTaskStatus[i], updatingStage, updateRun, placementv1beta1.BeforeStageTaskLabelValue) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
@@ -418,7 +418,7 @@ func (r *Reconciler) checkAfterStageTasksStatus(ctx context.Context, updatingSta | |
| klog.V(2).InfoS("The after stage wait task has completed", "stage", updatingStage.Name, "updateRun", updateRunRef) | ||
| } | ||
| case placementv1beta1.StageTaskTypeApproval: | ||
| approved, err := r.handleStageApprovalTask(ctx, &updatingStageStatus.AfterStageTaskStatus[i], updatingStage, updateRun) | ||
| approved, err := r.handleStageApprovalTask(ctx, &updatingStageStatus.AfterStageTaskStatus[i], updatingStage, updateRun, placementv1beta1.AfterStageTaskLabelValue) | ||
| if err != nil { | ||
| return false, -1, err | ||
| } | ||
|
|
@@ -440,6 +440,7 @@ func (r *Reconciler) handleStageApprovalTask( | |
| stageTaskStatus *placementv1beta1.StageTaskStatus, | ||
| updatingStage *placementv1beta1.StageConfig, | ||
| updateRun placementv1beta1.UpdateRunObj, | ||
| stageTaskType string, | ||
| ) (bool, error) { | ||
| updateRunRef := klog.KObj(updateRun) | ||
|
|
||
|
|
@@ -450,7 +451,7 @@ func (r *Reconciler) handleStageApprovalTask( | |
| } | ||
|
|
||
| // Check if the approval request has been created. | ||
| approvalRequest := buildApprovalRequestObject(types.NamespacedName{Name: stageTaskStatus.ApprovalRequestName, Namespace: updateRun.GetNamespace()}, updatingStage.Name, updateRun.GetName()) | ||
| approvalRequest := buildApprovalRequestObject(types.NamespacedName{Name: stageTaskStatus.ApprovalRequestName, Namespace: updateRun.GetNamespace()}, updatingStage.Name, updateRun.GetName(), stageTaskType) | ||
| requestRef := klog.KObj(approvalRequest) | ||
| if err := r.Client.Create(ctx, approvalRequest); err != nil { | ||
| if apierrors.IsAlreadyExists(err) { | ||
|
|
@@ -618,9 +619,9 @@ func checkClusterUpdateResult( | |
| return false, nil | ||
| } | ||
|
|
||
| // buildApprovalRequestObject creates an approval request object for after-stage tasks. | ||
| // buildApprovalRequestObject creates an approval request object for before-stage or after-stage tasks. | ||
| // It returns a ClusterApprovalRequest if namespace is empty, otherwise returns an ApprovalRequest. | ||
| func buildApprovalRequestObject(namespacedName types.NamespacedName, stageName, updateRunName string) placementv1beta1.ApprovalRequestObj { | ||
| func buildApprovalRequestObject(namespacedName types.NamespacedName, stageName, updateRunName, stageTaskType string) placementv1beta1.ApprovalRequestObj { | ||
| var approvalRequest placementv1beta1.ApprovalRequestObj | ||
| if namespacedName.Namespace == "" { | ||
| approvalRequest = &placementv1beta1.ClusterApprovalRequest{ | ||
|
|
@@ -629,6 +630,7 @@ func buildApprovalRequestObject(namespacedName types.NamespacedName, stageName, | |
| Labels: map[string]string{ | ||
| placementv1beta1.TargetUpdatingStageNameLabel: stageName, | ||
| placementv1beta1.TargetUpdateRunLabel: updateRunName, | ||
| placementv1beta1.TargetTaskTypeLabel: stageTaskType, | ||
| placementv1beta1.IsLatestUpdateRunApprovalLabel: "true", | ||
| }, | ||
| }, | ||
|
|
@@ -645,6 +647,7 @@ func buildApprovalRequestObject(namespacedName types.NamespacedName, stageName, | |
| Labels: map[string]string{ | ||
| placementv1beta1.TargetUpdatingStageNameLabel: stageName, | ||
| placementv1beta1.TargetUpdateRunLabel: updateRunName, | ||
| placementv1beta1.TargetTaskTypeLabel: stageTaskType, | ||
| placementv1beta1.IsLatestUpdateRunApprovalLabel: "true", | ||
| }, | ||
| }, | ||
|
|
||
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
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.