Skip to content

Conversation

@lentzi90
Copy link
Contributor

What this PR does / why we need it:

Add items to cache immediately after apply to avoid extra no-op patch just for caching.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Part of #12291

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign sbueringer for approval. For more information see the 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 do-not-merge/needs-area PR is missing an area label label Oct 20, 2025
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 20, 2025
@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch from 5e9c698 to 83a129c Compare October 23, 2025 07:21
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 23, 2025
@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch from 83a129c to 3f0d275 Compare October 23, 2025 07:24
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 23, 2025
@lentzi90 lentzi90 changed the title 🌱 WIP: Add items to cache immediately after apply 🌱 Add items to cache immediately after apply Oct 23, 2025
@sbueringer sbueringer added the area/util Issues or PRs related to utils label Oct 23, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Oct 23, 2025
@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch 2 times, most recently from 2355648 to f8f74c5 Compare October 28, 2025 13:50
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 28, 2025
@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch from f8f74c5 to 6b2932e Compare October 29, 2025 07:43
This improves the SSA helper by avoding a second no-op patch just to add
items to the cache. Instead we calculate the new request identifier and
add to the cache directly.

Signed-off-by: Lennart Jern <[email protected]>
@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch from 6b2932e to c0c8c9a Compare October 29, 2025 07:54
@lentzi90
Copy link
Contributor Author

Hmm race detected. I wonder if that could be a genuine issue from the code change 🤔
/test pull-cluster-api-test-main

@sbueringer
Copy link
Member

Should be unrelated to your PR . I'll take a closer look during review. Also very likely the race is just in test code (fake client)

Comment on lines 207 to 210
// Convert to unstructured WITHOUT filtering to preserve server fields (like resourceVersion)
objectAfterApplyUnstructured := &unstructured.Unstructured{}
err = env.GetScheme().Convert(objectAfterApply, objectAfterApplyUnstructured, nil)
g.Expect(err).ToNot(HaveOccurred())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Convert to unstructured WITHOUT filtering to preserve server fields (like resourceVersion)
objectAfterApplyUnstructured := &unstructured.Unstructured{}
err = env.GetScheme().Convert(objectAfterApply, objectAfterApplyUnstructured, nil)
g.Expect(err).ToNot(HaveOccurred())

This is not necessary (anymore), right?
We can just use the resourceVersion from objectAfterApply

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right, fixed

@sbueringer
Copy link
Member

@lentzi90 Thank you very much. Last nit. I also tested it with Tilt and it works perfectly

@lentzi90 lentzi90 force-pushed the lentzi90/ssa-cache-after-apply branch from c0c8c9a to 5d3943e Compare October 31, 2025 07:03
@lentzi90
Copy link
Contributor Author

Thanks! Fixed the last nit. Do you want me to squash the commits? I kept the changes to ComputeRequestIdentifier on a separate commit for now since I wasn't sure if we wanted it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/util Issues or PRs related to utils cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

4 participants