Skip to content
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

Kubelet config: Validate new config against future feature gates #63409

Merged

Conversation

mtaufen
Copy link
Contributor

@mtaufen mtaufen commented May 3, 2018

This fixes an issue with KubeletConfiguration validation, where the
feature gates set by the new config were not taken into account.

Also fixes a validation issue with dynamic Kubelet config, where flag
precedence was not enforced prior to dynamic config validation in the
controller; this prevented rejection of dynamic configs that don't merge
well with values set via legacy flags.

Fixes #63305

NONE

@mtaufen mtaufen added area/kubelet-api sig/node Categorizes an issue or PR as relevant to SIG Node. status/approved-for-milestone do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels May 3, 2018
@mtaufen mtaufen added this to the v1.11 milestone May 3, 2018
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 3, 2018
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels May 3, 2018
@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/new-api labels May 3, 2018
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 16, 2018
@k8s-github-robot k8s-github-robot removed the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label May 16, 2018
@@ -43,9 +43,16 @@ const (
configTrialDuration = 10 * time.Minute
)

type TransformFunc func(kc *kubeletconfig.KubeletConfiguration) error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure if this is the pattern I want, because it looks like a generic utility but we have a very specific use-case: enforce flag precedence so the final config combination is validated before choosing a config.

At the very least, we should warn people in a comment, and maybe change the name to something less generic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could make it something generic, and use it in the e2e tests. https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/util.go#L106 is essentially the same function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more about how it's used in the controller; it's an extension point that we only want to use as a last resort.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I don't see how we get away from it as long as we have to enforce flag precedence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll go with this for now. I added a warning to the comment above the field on the controller and to the NewController constructor.

@mtaufen mtaufen changed the title WIP Kubelet config: Validate new config against future feature gates Kubelet config: Validate new config against future feature gates May 16, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 16, 2018
@mtaufen mtaufen force-pushed the kc-validation-feature-gates branch 2 times, most recently from d7721eb to cc02d3c Compare May 16, 2018 16:43
@mtaufen mtaufen added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label May 16, 2018
@mtaufen mtaufen added this to the v1.11 milestone May 16, 2018
@mtaufen mtaufen removed milestone/removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels May 16, 2018
@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process

@dashpole @dchen1107 @liggitt @mtaufen

Pull Request Labels
  • sig/cluster-lifecycle sig/node: Pull Request will be escalated to these SIGs if needed.
  • priority/important-soon: Escalate to the pull request owners and SIG owner; move out of milestone after several unsuccessful escalation attempts.
  • kind/feature: New functionality.
Help

@@ -31,6 +31,11 @@ import (
func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
allErrors := []error{}

// Make a local copy of the global feature gates and combine it with the gates set by this configuration.
// This allows us to validate the config against the set of gates it will actually run against.
localFeatureGate := utilfeature.DefaultFeatureGate.DeepCopy()
Copy link
Member

@liggitt liggitt May 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we starting with a copy of the global gates? wouldn't kc.FeatureGates be the merged args+config at this point?

edit: hmm, because we don't want to overwrite the global here, and don't have a good way to construct a new default one from scratch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, exactly

@mtaufen
Copy link
Contributor Author

mtaufen commented May 18, 2018

TODO: After this merges, double check validation in case concurrent PRs add more feature gate checks (e.g. #63912).

@mtaufen mtaufen force-pushed the kc-validation-feature-gates branch 2 times, most recently from 934caf8 to 97aa235 Compare May 20, 2018 20:15
This fixes an issue with KubeletConfiguration validation, where the
feature gates set by the new config were not taken into account.

Also fixes a validation issue with dynamic Kubelet config, where flag
precedence was not enforced prior to dynamic config validation in the
controller; this prevented rejection of dynamic configs that don't merge
well with values set via legacy flags.
@mtaufen mtaufen force-pushed the kc-validation-feature-gates branch from 97aa235 to 647e903 Compare May 20, 2018 20:16
@dashpole
Copy link
Contributor

/lgtm
I like all of the warning comments.
Just because I am curious, do we plan to deprecate the feature gates flag in favor of including it in the component configuration? Will we be able to remove the TransformFunc after that, or will we need it to validate flags that may not be in the kubelet configuration object?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2018
@mtaufen
Copy link
Contributor Author

mtaufen commented May 21, 2018

@dashpole yes, the feature-gates flag will go away in favor of componentconfig. The transform func will probably be around until we can stop enforcing flag precedence, which is likely a-long-time™.

@mtaufen
Copy link
Contributor Author

mtaufen commented May 21, 2018

/retest

@dchen1107
Copy link
Member

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dashpole, dchen1107, mtaufen

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 21, 2018
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 63881, 64046, 63409, 63402, 63221). If you want to cherry-pick this change to another branch, please follow the instructions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm area/kubelet-api cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubelet config: Validate new config against future feature gates
6 participants