Skip to content

🐛 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

Closed
wants to merge 1 commit into from

Conversation

d8660091
Copy link

@d8660091 d8660091 commented Aug 30, 2022

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 #

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
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 30, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: d8660091 / name: Xu Deng (22d99c6)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 30, 2022
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 30, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval by writing /assign @fabriziopandini in a comment. For more information see:The Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 30, 2022
@d8660091 d8660091 changed the title Remove omitempty annotation from Taints 🐛 Remove omitempty annotation from Taints Aug 30, 2022
Copy link
Contributor

@killianmuldoon killianmuldoon left a 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.

@d8660091
Copy link
Author

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.

@killianmuldoon
Copy link
Contributor

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?

@d8660091
Copy link
Author

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.

@killianmuldoon
Copy link
Contributor

/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.

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 30, 2022
@k8s-ci-robot
Copy link
Contributor

@d8660091: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-e2e-informing-ipv6-main 22d99c6 link false /test pull-cluster-api-e2e-informing-ipv6-main
pull-cluster-api-e2e-main 22d99c6 link true /test pull-cluster-api-e2e-main
pull-cluster-api-e2e-informing-main 22d99c6 link false /test pull-cluster-api-e2e-informing-main

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.

@d8660091
Copy link
Author

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.

@killianmuldoon
Copy link
Contributor

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!)

@d8660091
Copy link
Author

d8660091 commented Aug 31, 2022

@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".

@d8660091 d8660091 closed this Aug 31, 2022
@killianmuldoon
Copy link
Contributor

If skipPhases does work as the solution it would be awesome if you could report back here! Thanks for raising this @d8660091

@d8660091
Copy link
Author

d8660091 commented Aug 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants