-
Notifications
You must be signed in to change notification settings - Fork 98
Add Opt-In KEP-1623 support for existing Conditions #565
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
Open
mallardduck
wants to merge
12
commits into
rancher:main
Choose a base branch
from
mallardduck:kep1623
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Experimental BRO PR: rancher/backup-restore-operator#763 Per feedback from Platform Design meeting I'm using BRO to test what it's like when a CRD definition is updated to use the new KEP based ones in place. I suspect it will drop the |
...this is necessary to keep context of generation
brandond
approved these changes
Apr 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
Since Wrangler's creation around 2019 (when the existing
Cond
was created) a lot has changed. One of those significant changes was KEP-1623 - essentially a standard for Conditions in k8s.The existing Wrangler/Rancher style of Conditons is very similar to the new standard. This allows potential for adding the KEP support in an opt-in manner; when comparing Wrangler and KEP/k8s flavored
Condition
the primary differences are:Status
field type (api/core/v1
vsapimachinery's meta/v1
)LastUpdatedTime
LastTransitionTime
LastTransitionTime
field type ismetav1.Time
Reason
andMessage
to be empty and omitted; k8s requires a non-emptyReason
value, and requiresMessage
but allows empty (""
) values.ObservedGeneration
field to track resource generation.protobuf
annotationsHow to use?
Just like the existing implementation you will create a
Conditions
field on your status. However the first difference will be how you define that fields type and annotations. It should use:Then, when you're in your controller and want to use a condition you do it exactly the same as today - for the most part - but with the addition of one extra call
.ToK8sCondition()
. The main caveat of "for the most part" is that the new implementation doesn't use the exact same interface as the wrangler flavor condition.Specifically:
Message(obj interface{}, msg string)
changed toSetMessage(obj interface{}, msg string)
Reason(obj interface{}, reason string)
changed toSetReason(obj interface{}, reason string)
HasCondition(obj interface{}) bool
Here is a more complete example of using a condition:
If accepted, I also have backport branch ready for V2; and could likely make a backport for V1 as well.
Breaking Changes?
Highly Unlikely. I've come to this conclusion via using golang experimental
apidiff
tool. Note that when I checked this aspect for both main and V2 the results were the same. So I will only show the work for themain
branch checks I did. Here's the steps I did to get this result:Doing the same for
genericcondition
pkg:What if an existing CRD adopts the new KEP based Conditions though?
I have tested with BRO here: rancher/backup-restore-operator#763
The results of my tests are that:
LastUpdatedAt
field is lost as expected - this would be a breaking change likely workaround is just usingLastTransitionedAt
that still introduces behavior changes thoughLastTransitionedAt
updates review: k8s Condition Setting Code and the notes above itSo to be more succinct, the main conditions where you must use caution are:
LastUpdatedAt
time of conditions.Reason
valuesReason
defaults toCreated
- so this will be filled in when Wrangler flavor updated