Skip to content
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

fix: use index number in clusterStagedUpdateRun and add ApprovalAccepted status to ApprovalRequests #1019

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jwtty
Copy link
Contributor

@jwtty jwtty commented Jan 17, 2025

Description of your changes

  1. Show index in PolicySnapshotIndexObserved in updateRun status
  2. Accept index in ResourceSnapshotIndex in updateRun spec
  3. Add ApprovalAccepted status in approvalRequests
  4. Fix the waitTime flaky UT (use no earlier than instead of after)
  5. Fix observedClusterCount difference for pickAll policy in validation.

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@jwtty jwtty changed the title fix: use index instead of name in PolicySnapshotIndexUsed and resourceSnapshotIndex fix: use index in PolicySnapshotIndexUsed and resourceSnapshotIndex Jan 17, 2025
@jwtty jwtty force-pushed the stagerun-index-fix branch 3 times, most recently from 2843cee to 79a44b9 Compare January 21, 2025 23:01
@jwtty jwtty changed the title fix: use index in PolicySnapshotIndexUsed and resourceSnapshotIndex fix: use index number in clusterStagedUpdateRun and add ApprovalAccepted status to ApprovalRequests Jan 22, 2025
@jwtty jwtty force-pushed the stagerun-index-fix branch 5 times, most recently from c9bf1a9 to dd0aad0 Compare January 23, 2025 20:02
@jwtty jwtty force-pushed the stagerun-index-fix branch from dd0aad0 to fe9aefe Compare January 23, 2025 22:59
GenericFunc: func(ctx context.Context, e event.GenericEvent, q workqueue.RateLimitingInterface) {
klog.V(2).InfoS("Handling a clusterApprovalRequest generic event", "clusterApprovalRequest", klog.KObj(e.Object))
handleClusterApprovalRequest(e.Object, q)
handleClusterApprovalRequest(e.ObjectOld, e.ObjectNew, q)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, I wonder why removing the genricFunc? I put it there just for safety as I am not 100% sure what is considered "generic".

// and enqueues it to the ClusterStagedUpdateRun controller queue.
func handleClusterApprovalRequest(obj client.Object, q workqueue.RateLimitingInterface) {
approvalRequest, ok := obj.(*placementv1beta1.ClusterApprovalRequest)
// and enqueues it to the ClusterStagedUpdateRun controller queue only when the approved condition gets changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// and enqueues it to the ClusterStagedUpdateRun controller queue only when the approved condition gets changed.
// and enqueues it to the ClusterStagedUpdateRun controller queue only when the approved condition is changed.

klog.ErrorS(mismatchErr, "there's a new latest policy snapshot", "clusterResourcePlacement", placementName, "clusterStagedUpdateRun", updateRunRef)
return -1, nil, nil, fmt.Errorf("%w: %s", errStagedUpdatedAborted, mismatchErr.Error())
}
// Make sure the cluster count in the policy snapshot has not changed.
if updateRun.Status.PolicyObservedClusterCount != clusterCount {
// PickAll policy case will be verified in validateStagesStatus.
if clusterCount != -1 && updateRun.Status.PolicyObservedClusterCount != clusterCount {
Copy link
Contributor

@ryanzhang-oss ryanzhang-oss Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding the extra check since both will be -1 in the case of pickAll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants