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

sched: ensure feature gate is honored when instantiating scheduler #105915

Merged
merged 2 commits into from Nov 2, 2021

Conversation

Huang-Wei
Copy link
Member

@Huang-Wei Huang-Wei commented Oct 26, 2021

What type of PR is this?

/kind regression
/sig scheduling

What this PR does / why we need it:

The logic of binding CLI args to CC fields brings maintenance burden due to the following limitations:

  • instantiation of a CC obj should happen after CLI args parsing (instantiation of some plugins depend on feature gates)
  • some CLI args (leader election ones) are favored over CC fields
  • some CLI args (deprecated options) take precedence from CC fields if --config is specified; otherwise default values are adopted

This has caused bugs (#103440, #105704) and now regressions (#105789). So this PR tries to fix the problem thoroughly by breaking the binding from CLI args to CC field.

Which issue(s) this PR fixes:

Fixes #105704

Special notes for your reviewer:

This PR should be back-ported to 1.22.

Does this PR introduce a user-facing change?

The --leader-elect* CLI args are now honored in scheduler.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/regression Categorizes issue or PR as related to a regression from a prior release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 26, 2021
@k8s-ci-robot
Copy link
Contributor

@Huang-Wei: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 26, 2021
@Huang-Wei
Copy link
Member Author

/cc @ahg-g @alculquicondor

@Huang-Wei
Copy link
Member Author

/priority critical-urgent

@k8s-ci-robot k8s-ci-robot added priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 26, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Huang-Wei

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 Oct 26, 2021
@Huang-Wei
Copy link
Member Author

/retest

fs.BoolVar(&o.EnableContentionProfiling, "contention-profiling", false, "DEPRECATED: enable lock contention profiling, if profiling is enabled. This parameter is ignored if a config file is specified in --config.")
fs.StringVar(&o.Kubeconfig, "kubeconfig", "", "DEPRECATED: path to kubeconfig file with authorization and master location information. This parameter is ignored if a config file is specified in --config.")
fs.StringVar(&o.ContentType, "kube-api-content-type", "", "DEPRECATED: content type of requests sent to apiserver. This parameter is ignored if a config file is specified in --config.")
fs.Float32Var(&o.QPS, "kube-api-qps", 0, "DEPRECATED: QPS to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.")
Copy link
Member

Choose a reason for hiding this comment

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

The default value is not part of the output when doing --help?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point. Updated the code to include default values.

@alculquicondor
Copy link
Member

I wonder if we need a more targeted fix that we can more easily backport. And leave this PR just for 1.23

@ahg-g
Copy link
Member

ahg-g commented Oct 26, 2021

also, I think we should remove all deprecated flags.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2021
@Huang-Wei
Copy link
Member Author

also, I think we should remove all deprecated flags.

Can we remove them in 1.23? If so, I can come up with a followup PR. This one should still be needed, as 1.22 have those deprecated options.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2021
@Huang-Wei
Copy link
Member Author

I wonder if we need a more targeted fix that we can more easily backport. And leave this PR just for 1.23

The bug lay in 1.22 is that leader elect and deprecated options are not honored. A "targeted" fix would be also non-trivial IMO, so I'm not sure it is worth the extra efforts.

@alculquicondor
Copy link
Member

Just checking IIUC: the reason for the regression is that the feature gates are not loaded by the time we create the component config, correct?

@alculquicondor
Copy link
Member

can we first revert #105712 in master (as it's urgent) and then have this PR (to be bakported) have the 2 commits?

I think it would be useful to review the overall delta.

@Huang-Wei
Copy link
Member Author

Just checking IIUC: the reason for the regression is that the feature gates are not loaded by the time we create the component config, correct?

Yes.

can we first revert #105712 in master (as it's urgent) and then have this PR (to be bakported) have the 2 commits?

Do you mean to submit a separate PR to revert #105712, so it resolves the urgent CI failure (#105789). And then update this PR to resolve the leader election issue (#105704) thoroughly?

@alculquicondor
Copy link
Member

alculquicondor commented Oct 26, 2021 via email

@Huang-Wei
Copy link
Member Author

Yes, that's what I mean. Wdyt?

Make sense to me.

@Huang-Wei
Copy link
Member Author

/retest

@ahg-g
Copy link
Member

ahg-g commented Oct 27, 2021

Can we remove them in 1.23? If so, I can come up with a followup PR. This one should still be needed, as 1.22 have those deprecated options.

I think we can, they have been in deprecated status for a long time. We already removed a bunch earlier this cycle.

@Huang-Wei
Copy link
Member Author

I think we can, they have been in deprecated status for a long time. We already removed a bunch earlier this cycle.

SG, I will raise a follow-up PR.

@alculquicondor The reverting PR has been merged. This PR will act as a pure fix and backporting candidate.

// mapped into componentconfig.KubeSchedulerConfiguration.
componentbaseconfig.DebuggingConfiguration
componentbaseconfig.ClientConnectionConfiguration
componentbaseconfig.LeaderElectionConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

So some leader election flags don't take precedence, right?

Can you add a comment?

Copy link
Member Author

@Huang-Wei Huang-Wei Oct 28, 2021

Choose a reason for hiding this comment

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

It's a bit tricky here. Two deprecated flags (--lock-object-name and --lock-object-namespace) overlapped with the regular non-deprecated options, so here LeaderElectionConfiguration only populates the deprecated ones.

Will add a comment here.

o := &Options{
SecureServing: apiserveroptions.NewSecureServingOptions().WithLoopback(),
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
Deprecated: &DeprecatedOptions{},
Metrics: metrics.NewOptions(),
Logs: logs.NewOptions(),
LeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
Copy link
Member

Choose a reason for hiding this comment

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

doesn't componentbaseconfig offer a defaulting function? let's use that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought of it. There are a couple of shortcomings:

  • componentbaseconfigv1alpha1 (not componentbaseconfig) offers a defaulting function to build a versioned obj. We use unversioned obj here, so need extra code to do the conversion bits.
  • the defaulting logic in componentbaseconfigv1alpha1 still uses "endpoints" as the default lock name, however, it should be "leases" in latest k8s versions.

WDYT?

"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
netutils "k8s.io/utils/net"
)

// Options has all the params needed to run a Scheduler
type Options struct {
// The default values.
ComponentConfig kubeschedulerconfig.KubeSchedulerConfiguration
ComponentConfig *kubeschedulerconfig.KubeSchedulerConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

was this change absolutely necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

We better have this as a defaulting CC obj is no longer offered in the very beginning, and hence if needed (like in some tests so far), we can use if cc == nil to compose it. On the other hand, it's aligned with other structs in Options.

@@ -96,15 +89,17 @@ for more information about scheduling and the kube-scheduler component.`,
},
}

opts.InitFlags()
Copy link
Member

Choose a reason for hiding this comment

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

Can we just call this as part of New?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, good suggestion.

@Huang-Wei
Copy link
Member Author

Comments addressed. PTAL.

@alculquicondor
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2021
@alculquicondor
Copy link
Member

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 2, 2021
@k8s-ci-robot k8s-ci-robot merged commit e30f964 into kubernetes:master Nov 2, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 2, 2021
@Huang-Wei Huang-Wei deleted the fix-feature-gate-dep branch November 2, 2021 21:35
@Huang-Wei
Copy link
Member Author

Oops, the unit tests in the reverted weren't added in this PR. I will raise a PR to add those UTs back.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 3, 2021
k8s-ci-robot added a commit that referenced this pull request Nov 13, 2021
…05915-#106105-upstream-release-1.22

Automated cherry pick of #105915: sched: ensure feature gate is honored when instantiating
#106105: Add unit tests to cover scheduler's setup
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sched: --leader-elect flag is not honored well
4 participants