-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: implement clusterStagedUpdateRun validation #991
Conversation
d52ec3b
to
06a2156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pkg/controllers/updaterun/controller.go: Evaluated as low risk
Comments suppressed due to low confidence (13)
pkg/controllers/updaterun/validation.go:44
- [nitpick] The error message uses %v to print the ApplyStrategy, which might not provide a clear and readable output. Consider using a more specific format or converting the ApplyStrategy to a string.
mismatchErr := fmt.Errorf("the applyStrategy in the clusterStagedUpdateRun is outdated, latest: %v, recorded: %v", updateRunCopy.Status.ApplyStrategy, updateRun.Status.ApplyStrategy)
pkg/controllers/updaterun/validation.go:56
- Include the placementName in the error message for better context.
mismatchErr := fmt.Errorf("the policy snapshot index used in the clusterStagedUpdateRun is outdated, latest: %s, recorded: %s", latestPolicySnapshot.Name, updateRun.Status.PolicySnapshotIndexUsed)
pkg/controllers/updaterun/validation.go:62
- Include the placementName in the error message for better context.
mismatchErr := fmt.Errorf("the cluster count initialized in the clusterStagedUpdateRun is outdated, latest: %d, recorded: %d", clusterCount, updateRun.Status.PolicyObservedClusterCount)
pkg/controllers/updaterun/validation.go:210
- [nitpick] The error message should be more descriptive. Consider including more context about the failure.
failedErr := fmt.Errorf("the stage `%s` has failed, err: %s", stageStatus.StageName, stageSucceedCond.Message)
pkg/controllers/updaterun/validation_test.go:222
- The 'validateDeleteStageStatus' function has several branches that are not covered by tests. Ensure that all possible paths are tested.
func TestValidateDeleteStageStatus(t *testing.T) {
pkg/controllers/updaterun/controller_integration_test.go:472
- The 'condType' parameter uses the 'any' type, which could lead to runtime errors if an unsupported type is passed. Ensure that only supported types are passed to this function.
func generateTrueCondition(updateRun *placementv1alpha1.ClusterStagedUpdateRun, condType any) metav1.Condition {
pkg/controllers/updaterun/controller_integration_test.go:510
- The 'condType' parameter uses the 'any' type, which could lead to runtime errors if an unsupported type is passed. Ensure that only supported types are passed to this function.
func generateFalseCondition(updateRun *placementv1alpha1.ClusterStagedUpdateRun, condType any) metav1.Condition {
pkg/controllers/updaterun/initialization_integration_test.go:255
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
pkg/controllers/updaterun/initialization_integration_test.go:288
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
pkg/controllers/updaterun/initialization_integration_test.go:320
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
pkg/controllers/updaterun/initialization_integration_test.go:356
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
pkg/controllers/updaterun/initialization_integration_test.go:413
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
pkg/controllers/updaterun/initialization_integration_test.go:554
- The comment should be 'Setting the latest policy snapshot condition as fully scheduled'.
By("Set the latest policy snapshot condition as fully scheduled")
06a2156
to
fd9a057
Compare
ddc7a6b
to
4afc143
Compare
@@ -258,6 +256,22 @@ func validateDeleteStageStatus( | |||
klog.ErrorS(unexpectedErr, "Failed to find the deletionStageStatus in the clusterStagedUpdateRun", "clusterStagedUpdateRun", updateRunRef) | |||
return -1, fmt.Errorf("%w: %s", errStagedUpdatedAborted, unexpectedErr.Error()) | |||
} | |||
|
|||
// Validate whether toBeDeletedBindings are a subnet of the clusters in the delete stage status. | |||
// We only validate if it's a subnet because clusters can unjoin from the fleet and we allow that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the real reason is not about cluster leave the fleet ( we don't allow that for updating ones). It's about the action on the cluster in the deleting stages is to delete the binding so they will disappear in the next round of validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I realized that when I write the execution code. Updated this comments.
// if condition.IsConditionStatusFalse(meta.FindStatusCondition(updateRun.Status.Conditions, string(placementv1alpha1.StagedUpdateRunConditionProgressing)), updateRun.Generation) { | ||
// // The clusterStagedUpdateRun has not started yet. | ||
// klog.V(2).InfoS("Starting the staged update run from the beginning", "clusterStagedUpdateRun", updateRunRef) | ||
// return 0, scheduledBindings, toBeDeletedBindings, nil | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit different though. The condition is a short cut to save any validation. Do we want that?
0346c3d
to
3bfcfa2
Compare
Description of your changes
This PR implements the
clusterStagedUpdateRun
validationFixes #
I have:
make reviewable
to ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer