-
Notifications
You must be signed in to change notification settings - Fork 218
Refactor to adopt k8s standardized Condition type #195
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
Conversation
api/v1beta1/bucket_types.go
Outdated
| // SetBucketCondition sets the given condition with the given status, reason and | ||
| // message on the Bucket. | ||
| func SetBucketCondition(bucket *Bucket, conditionType string, status corev1.ConditionStatus, reason, message string) { | ||
| func SetBucketCondition(bucket *Bucket, conditionType string, status metav1.ConditionStatus, reason, message string) { |
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.
Can we remove this method (and the corresponding methods for the other types) and just use metav1.SetStatusCondition() instead? That would give us the correct lastTransitionTime handling, and would allow setting the observedGeneration on the passed condition.
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.
Or perhaps use metav1.SetStatusCondition() within these methods. Or if possible add a convenience method to pkg/runtime which has the same signature as these methods, except with a loosely typed first argument and gets the metadata generation and status conditions, and then calls metav1.SetStatusCondition().
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.
Makes sense to me. Will follow-up with the changes.
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.
I think we can also remove FilterOutCondition from fluxcd/pkg now that we have meta.RemoveStatusCondition()?
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.
I think we can also remove
FilterOutConditionfromfluxcd/pkgnow that we havemeta.RemoveStatusCondition()?
If that was its intended purpose then sure. From the implementation (and name) it was not that clear, to be honest.
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.
I missed this during my review. But they behave indeed the same, except that the one in fluxcd/pkg returns a new slice and the one from the Kubernetes upstream modifies the given slice. The latter is more Kubernetes idiomatic, and has my preference (we should work with pointers as much as we can actually (that being: when we modify state)).
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.
Here's the removal of FilterOutCondition: fluxcd/pkg#47
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.
Or perhaps use
metav1.SetStatusCondition()within these methods. Or if possible add a convenience method topkg/runtimewhich has the same signature as these methods, except with a loosely typed first argument and gets the metadata generation and status conditions, and then callsmetav1.SetStatusCondition().
I suppose having a dedicated convenience method in pkg would be nice if we actually do want to handle updating the observedGeneration of the conditions as well during.
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.
On a side note, looks like updating the ObservedGeneration in the SetStatusCondition func was added quite recently to v1.20.
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.
Or perhaps use
metav1.SetStatusCondition()within these methods. Or if possible add a convenience method topkg/runtimewhich has the same signature as these methods, except with a loosely typed first argument and gets the metadata generation and status conditions, and then callsmetav1.SetStatusCondition().
Implemented here: fluxcd/pkg#48
Never mind that, it's not gonna work because there's no common type I can use between the different resource types we use in the apis.
1845434 to
ec975d3
Compare
|
|
Yes, I'm working on that. Already did the suggested changes and I'm working to resolve the conflicts now :) |
29e5432 to
239b514
Compare
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.
The changes look good to me, but this needs to be merged at a strategic moment.
Thanks @relu 🌻
Definitely. I'm going to continue with these changes in the other dependent controllers and submit draft PRs pointing the dependencies to pseudo-versions. After you decide when these changes will go out, they can be merged in order with minimal changes (version bumps for deps basically). |
stefanprodan
left a comment
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.
LGTM
I'm ok with merging this tomorrow and do a release of all controllers
Updates to use metav1.Condition type and removes references for deprecated corev1.Condition* constants and uses the new k8s api/meta helpers in place of the old pkg/apis/meta types. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
Change to rely on the upstream k8s api/meta SetStatusCondition to set/update the resources status conditions rather than FilterOutCondition from apis/meta which is due to be removed. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
Use SetResourceCondition as a generic method to set conditions for CRs, implmeneting the ObjectWithStatusConditions interface used as input type. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
239b514 to
b80f450
Compare
Updates to use metav1.Condition type and removes references for
deprecated corev1.Condition* constants and uses the new k8s api/meta
helpers in place of the old pkg/apis/meta types.
Relates to fluxcd/flux2#225
NB: This will be a blocker for other components that depend on the source-controller. We'll need to release a new version of the source-controller before proceeding to update the other components that depend on it: