-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🐛 Remove omitempty annotation from Taints #7133
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
As the comment mentioned "set this field to an empty slice, i.e. taints: [].", thus, we should not omit "[]". Context: Step1: edit taints:[] in initConfiguration of KubeadmControlPlane with kubectl, and save Step2: get that KubeadmControlPlane after saving Expecting: taints: [] in initConfiguration Actual: taints field is missing in initConfiguration
|
Hi @d8660091. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
[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 |
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.
Is this causing a bug somewhere?
I think the current version is correct according to the API conventions
Optional fields have the following properties:
An optional field MUST be marked with +optional and include an omitempty JSON tag.
This might be an exception to the API convention. Our team is doing some investigation using cluster-api to create a single-node cluster. But because of this bug, the control plane nodes created by CAPI always have the taint of "node-role.kubernetes.io/master:NoSchedule", there is no way to erase it declaratively. |
My assumption was that marking the control plane was part of the behaviour of Kubeadm - if you remove the omitempty here do you get control plane nodes with no taint created? |
I know that kubeadm take [] taints as a flag to not do the marking. https://github.com/kubernetes/kubernetes/blob/b1aa1bd3088fad184cbb4fe36bd156dde7605ee4/cmd/kubeadm/app/util/config/initconfiguration.go#L107. So it should work in theory. But I haven't test it. Are you able to test it? I don't have a dev environment for cluster-api. Our team only uses cluster-api as a dependency. |
/ok-to-test As I read the linked code Kubeadm should not apply the taint if Taints is nil, i.e. the behaviour you're describing, but I'm not sure what other transformations this field goes through before it reaches that code. |
@d8660091: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Tested in tilt: the change does pass [] "taints" to kubeadm, and kubeadm doesn't taint contro-plane nodes accordingly. However, it has a side effect of making Taints "required", which is not we wanted. |
I think an alternative for your use case is to skip the control plane mark phase in Kubeadm - skip phases support was added here: #5993 If we want to track this issue and best practices around it it might be a good idea to open an issue instead of this PR as it looks like changing the omitempty tag isn't a good solution (though it does work somewhat!) |
@killianmuldoon Skipping mark phases sounds like a good solution to us! We believe it will solve our issue, if not, we'll open an issue. BTW, if we were to go further with this approach, we would need to change it to pointer instead of removing "omitempty". |
If skipPhases does work as the solution it would be awesome if you could report back here! Thanks for raising this @d8660091 |
Skipping mark-control-plane phases was promising, unfortunately, it also has an unwanted side effect of removing the desired label. Without this label, controlPlane will be recognized as notReady, and a lot of consequences. |
As the comment mentioned "set this field to an empty slice, i.e. taints: [].", thus, we should not omit "[]".
What this PR does / why we need it:
Context:
Step1: edit taints:[] in initConfiguration of KubeadmControlPlane with kubectl, and save
Step2: get that KubeadmControlPlane after saving
Expecting:
taints: [] in initConfiguration
Actual:
taints field is missing in initConfiguration
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 #