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

Use Patch to add finalizers, Get updated objects when removing finalizer with update fails with conflict. #1023

Conversation

kaovilai
Copy link
Contributor

@kaovilai kaovilai commented Feb 26, 2024

Signed-off-by: Tiger Kaovilai [email protected]

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This PR cleans up some of the unit test reactor code, and eliminate update calls that I can see, fixing unit tests to accommodate the changes.
Previously update call was required simply cause unit test is borked. Patch calls was modifying original input causing compare failures.
Which issue(s) this PR fixes:

Fixes #748

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


This PR extend #876 work to later added update calls.

Similar to #1019 but using Update calls for finalizer removal.

Signed-off-by: Tiger Kaovilai <[email protected]>

remove debugging code

Signed-off-by: Tiger Kaovilai <[email protected]>

remove more update calls

Signed-off-by: Tiger Kaovilai <[email protected]>

Fix patch json unmarshal unitTests comparison failures

Signed-off-by: Tiger Kaovilai <[email protected]>

Fix tests in reactor by not modifying original for patch

Signed-off-by: Tiger Kaovilai <[email protected]>
Signed-off-by: Tiger Kaovilai <[email protected]>
Signed-off-by: Tiger Kaovilai <[email protected]>
Signed-off-by: Tiger Kaovilai <[email protected]>
@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 26, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @kaovilai. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kaovilai
Once this PR has been reviewed and has the lgtm label, please assign xing-yang for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 26, 2024
@kaovilai kaovilai changed the title Use Patch to add finalizers, Get updated objects when removing finalizer with update Use Patch to add finalizers, Get updated objects when removing finalizer with update fails with conflict. Feb 26, 2024
if err != nil {
return nil, err
}
return UpdateRemoveFinalizers(obj, client, finalizers...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've been told before that recursion is bad.. but felt like this is visually easier to read and it's not expected to run in most cases. Can refactor to non-recursion if needed.

@kaovilai kaovilai force-pushed the removeUpdateCallsForAdding,GetWhenApplyOutOfDate branch from 027dcff to 931529b Compare February 26, 2024 21:38
Signed-off-by: Tiger Kaovilai <[email protected]>
Comment on lines 24 to 36
object.SetFinalizers(RemoveStrings(object.GetFinalizers(), finalizers...))
object, err := updateFunc(context.TODO(), object, metav1.UpdateOptions{})
if err != nil {
if apierrors.IsConflict(err) {
object, err = getFunc(context.TODO(), object.GetName(), metav1.GetOptions{})
if err != nil {
return object, err
}
return UpdateRemoveFinalizers(object, updateFunc, getFunc, finalizers...)
} else {
return object, err
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main difference from #1019

Signed-off-by: Tiger Kaovilai <[email protected]>
Comment on lines +88 to +97
{
name: "2-4 - successful remove Snapshot finalizer after update conflict",
initialSnapshots: newSnapshotArray("snap2-4", "snapuid2-4", "claim2-4", "", classSilver, "", &False, nil, nil, nil, false, true, nil),
initialClaims: newClaimArray("claim2-4", "pvc-uid2-4", "1Gi", "volume2-4", v1.ClaimBound, &classEmpty),
test: testRemoveSnapshotFinalizerAfterUpdateConflict,
expectSuccess: true,
errors: []reactorError{
{"update", "volumesnapshots", errors.NewConflict(crdv1.Resource("volumesnapshots"), "snap2-4", nil)},
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the error case we're solving for.

Signed-off-by: Tiger Kaovilai <[email protected]>
@kaovilai kaovilai force-pushed the removeUpdateCallsForAdding,GetWhenApplyOutOfDate branch from 0672e8d to 8c61946 Compare February 27, 2024 05:31
@kaovilai
Copy link
Contributor Author

kaovilai commented Feb 27, 2024

Closing due to other priorities as the sense is this isn't going to be approved as is and to see if #876 recently cherrypicked to our nightlies would be sufficient. Feel free to takeover.

Test improvements are moved to #1024

@kaovilai kaovilai closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

snapshot-controller logs report failure frequently
2 participants