- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.4k
🌱 Add items to cache immediately after apply #12877
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
base: main
Are you sure you want to change the base?
🌱 Add items to cache immediately after apply #12877
Conversation
| [APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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  | 
5e9c698    to
    83a129c      
    Compare
  
    83a129c    to
    3f0d275      
    Compare
  
    2355648    to
    f8f74c5      
    Compare
  
    f8f74c5    to
    6b2932e      
    Compare
  
    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]>
6b2932e    to
    c0c8c9a      
    Compare
  
    | Hmm race detected. I wonder if that could be a genuine issue from the code change 🤔 | 
| 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) | 
        
          
                internal/util/ssa/patch_test.go
              
                Outdated
          
        
      | // 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()) | 
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.
| // 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
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.
Yes you are right, fixed
| @lentzi90 Thank you very much. Last nit. I also tested it with Tilt and it works perfectly | 
Signed-off-by: Lennart Jern <[email protected]>
c0c8c9a    to
    5d3943e      
    Compare
  
    | Thanks! Fixed the last nit. Do you want me to squash the commits? I kept the changes to  | 
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