Handle null observedGeneration in condition Equal()#906
Handle null observedGeneration in condition Equal()#906jbw976 merged 1 commit intocrossplane:mainfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Thank you for the clear change and tests — would you like me to add a note to the changelog or link this behavior to the related issue ( Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ulucinar
left a comment
There was a problem hiding this comment.
Hi @bobh66,
Thanks for investigating this issue and proposing a fix. Please also see my comment here.
The .metadata.generation starts from 1, so observedGeneration being 0 effectively means it's not set. crossplane-runtime will always set the status conditions with a non-zero observedGeneration (because the resource's .metadata.generation cannot be 0). And if the provider cooperates (sets the observedGeneration, they should again always be non-zero). So only for a non-cooperating provider (a provider that does not set the observedGeneration on the status conditions it sets), the observedGeneration can be 0. And in that case, knowing the provider does not set observedGenerations, we can safely ignore them in comparisons.
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
939d0d7 to
940b552
Compare
|
Successfully created backport PR for |
Description of your changes
Modified the condition
Equial()method to check for unsetObservedGenerationfieldswhen comparing two conditions. If at least one of the
ObservedGenerations is 0 then the comparisonwill ignore the field since it will always be
False.This can happen when a provider does not set the
observedGenerationin aSyncedcondition duringObserve(), which causes it to appear to be different than theSyncedcondition that is set by the managed reconciler.Fixes #902
I have:
earthly +reviewableto ensure this PR is ready for review.- [ ] Linked a PR or a docs tracking issue to document this change.backport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.