-
Notifications
You must be signed in to change notification settings - Fork 498
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
Add generation to all component statuses #5684
base: master
Are you sure you want to change the base?
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 |
Welcome @ari-e! It looks like this is your first PR to pingcap/tidb-operator 🎉 |
0008610
to
44c6e1a
Compare
Thanks for your contribution, but as our |
Hi @csuzhangxc thanks for the comment. Is not registering status as a subresource intentional? I can easily convert it to a subresource but then that would of course affect backwards compatibility. I still think that's the right thing to do though as it's more canonical k8s. |
How about using the name of |
44c6e1a
to
37657f4
Compare
@csuzhangxc sure I updated it to observedGeneration and I also changed the annotations on TidbCluster to make it register status as a subresource. |
will it break any existing clusters after chaning it to subresources? |
The only behavior change should be this difference with the generation number. So if someone is depending on generation being incremented whenever the status changes that will break. But that seems like depending on undefined behavior to me. Generation is meant for spec changes. This could be included in the next major version release if that's a concern. |
37657f4
to
04e87ce
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5684 +/- ##
==========================================
+ Coverage 61.47% 61.48% +0.01%
==========================================
Files 235 235
Lines 30653 30741 +88
==========================================
+ Hits 18843 18902 +59
- Misses 9920 9942 +22
- Partials 1890 1897 +7
|
I still think the change of subresource is too critical. Can you make this change only to one CRD and do more tests to ensure it works correctly, especially for upgrading from a previous version of TiDB Operator. BTW, the |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@csuzhangxc thanks for the feedback. I'll do some more testing and fix the e2e. And again this can go in the next major version release if the compatibility change is a big concern. I'm busy with other projects for the next week or so but will pick this up after. |
What problem does this PR solve?
tidb-operator currently does not propagate the CR object meta's generation to the status. This is problematic because it means external systems cannot always tell whether the status corresponds to the current version of the CRD spec, or if it is an old status. For example consider the series of events
Here, process B will think that the status corresponds to the updated spec as written by process A, when in reality it is a stale status belonging to a previous version of the CR. This is exacerbated if the operator has high latency or is briefly unavailable due to deploys or other reasons.
What is changed and how does it work?
Each component status within the overarching TidbClusterStatus now has a
generation
field in addition to its other fields likephase
. Whenever thephase
is updated by the respective controllers, the generation is also set to be equal to the current CR's generation. Kubernetes increments this generation anytime the spec for the CR is updated, so this provides a consistent way to indicate the status reflects the current version of the CR spec.Note this practice of passing the generation through to the status is standard practice and is how Kubernetes deployments work, and Kubernetes source code even indicates that all custom operators should do this.
Code changes
Tests
Side effects
TidbCluster now registers status as a subresource, meaning changes to status do not increment the CR's generation number.
CRD changes need to be deployed to clusters
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.