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

Set leader-elect for kube-scheduler to true / Adds new configuration types and rework how we set defaults #59732

Conversation

dims
Copy link
Member

@dims dims commented Feb 11, 2018

What this PR does / why we need it:
Thanks to some great sleuthing by ikruglov!

kube-controller-manager defaults --leader-elect to true. We should
do the same for kube-scheduler. kube-scheduler used to have this
set to true, but it got lost during refactoring in:
efb2bb7

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 #59729

Special notes for your reviewer:

Release note:

kube-scheduler has been fixed to use `--leader-elect` option back to true (as it was in previous versions)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 11, 2018
@dims
Copy link
Member Author

dims commented Feb 12, 2018

/assign @timothysc

@timothysc timothysc added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Feb 12, 2018
Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 12, 2018
@@ -150,6 +150,7 @@ func NewOptions() (*Options, error) {
return nil, err
}

o.config.LeaderElection.LeaderElect = true
Copy link
Member

Choose a reason for hiding this comment

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

seems like defaults should be applied in defaults.go, not here (and options round-tripped through those defaults)

Copy link
Member Author

Choose a reason for hiding this comment

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

@liggitt
Copy link
Member

liggitt commented Feb 12, 2018

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2018
@liggitt
Copy link
Member

liggitt commented Feb 12, 2018

why is this default different than all the other defaults for the scheduler config, applied in the api defaulting path? the setting here won't get applied when reading from file

@timothysc timothysc removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 12, 2018
@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from e1f6935 to d85f8df Compare February 12, 2018 16:54
@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2018
@dims
Copy link
Member Author

dims commented Feb 12, 2018

@liggitt looks like we need to do both ... cmd/kube-scheduler/app/server.go and pkg/apis/componentconfig/v1alpha1/defaults.go if i don't patch up server.go, then the command line default is still false.

@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from d85f8df to 0f2280a Compare February 12, 2018 17:19
@liggitt
Copy link
Member

liggitt commented Feb 12, 2018

if i don't patch up server.go, then the command line default is still false.

that means the internal config is not being round tripped and defaulted... that seems like it should be fixed as well

@dims
Copy link
Member Author

dims commented Feb 12, 2018

@liggitt can you point me to an existing pattern/files where this is done please?

@liggitt
Copy link
Member

liggitt commented Feb 12, 2018

@liggitt can you point me to an existing pattern/files where this is done please?

for kubeproxy:

func (o *Options) ApplyDefaults(in *kubeproxyconfig.KubeProxyConfiguration) (*kubeproxyconfig.KubeProxyConfiguration, error) {
external, err := o.scheme.ConvertToVersion(in, v1alpha1.SchemeGroupVersion)
if err != nil {
return nil, err
}
o.scheme.Default(external)
internal, err := o.scheme.ConvertToVersion(external, kubeproxyconfig.SchemeGroupVersion)
if err != nil {
return nil, err
}
out := internal.(*kubeproxyconfig.KubeProxyConfiguration)
return out, nil
}
// NewProxyCommand creates a *cobra.Command object with default parameters
func NewProxyCommand() *cobra.Command {
opts := NewOptions()
cmd := &cobra.Command{
Use: "kube-proxy",
Long: `The Kubernetes network proxy runs on each node. This
reflects services as defined in the Kubernetes API on each node and can do simple
TCP and UDP stream forwarding or round robin TCP and UDP forwarding across a set of backends.
Service cluster IPs and ports are currently found through Docker-links-compatible
environment variables specifying ports opened by the service proxy. There is an optional
addon that provides cluster DNS for these cluster IPs. The user must create a service
with the apiserver API to configure the proxy.`,
Run: func(cmd *cobra.Command, args []string) {
verflag.PrintAndExitIfRequested()
cmdutil.CheckErr(opts.Complete())
cmdutil.CheckErr(opts.Validate(args))
cmdutil.CheckErr(opts.Run())
},
}
var err error
opts.config, err = opts.ApplyDefaults(opts.config)

for kubelet:

// NewKubeletConfiguration will create a new KubeletConfiguration with default values
func NewKubeletConfiguration() (*kubeletconfig.KubeletConfiguration, error) {
scheme, _, err := kubeletscheme.NewSchemeAndCodecs()
if err != nil {
return nil, err
}
versioned := &v1alpha1.KubeletConfiguration{}
scheme.Default(versioned)
config := &kubeletconfig.KubeletConfiguration{}
if err := scheme.Convert(versioned, config, nil); err != nil {
return nil, err
}
return config, nil
}

@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from 0f2280a to 630f6e1 Compare February 12, 2018 18:38
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 12, 2018
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Feb 12, 2018
@dims
Copy link
Member Author

dims commented Feb 12, 2018

Thanks @liggitt looks like it was already setup. but there was a mismatch in bool vs *bool for LeaderElect (in the 2 types.go file) and a hard coding of LeaderElect to false in DefaultLeaderElectionConfiguration.

@dims dims changed the title Set leader-elect for kube-scheduler to true [WIP] Set leader-elect for kube-scheduler to true Feb 12, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 12, 2018
@dims
Copy link
Member Author

dims commented Mar 6, 2018

/milestone clear

@k8s-ci-robot k8s-ci-robot removed this from the v1.10 milestone Mar 6, 2018
@dims
Copy link
Member Author

dims commented Mar 6, 2018

we merged a small change and pushing this PR off to v1.11

@timothysc timothysc added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2018
@bsalamat bsalamat modified the milestones: v1.10, v1.11 Mar 12, 2018
@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from a86e3f7 to b68dbf8 Compare March 16, 2018 12:01
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2018
@dims
Copy link
Member Author

dims commented Mar 20, 2018

@mtaufen @liggitt let's get this in please? now that master is open for 1.11. thanks!

@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Removed From Pull Request

@deads2k @dims @mtaufen @timothysc

Important: This pull request was missing labels required for the v1.11 milestone for more than 3 days:

kind: Must specify exactly one of kind/bug, kind/cleanup or kind/feature.
priority: Must specify exactly one of priority/critical-urgent, priority/important-longterm or priority/important-soon.

Help

@k8s-github-robot k8s-github-robot removed this from the v1.11 milestone Mar 20, 2018
@dims
Copy link
Member Author

dims commented Mar 27, 2018

@liggitt now that master is open and it's early in the cycle, let's please get this in.

// LeaderElectionConfiguration defines the configuration of leader election
// clients for components that can run with leader election enabled.
type LeaderElectionConfiguration struct {
metav1.TypeMeta `json:",inline"`
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need type info? It's not a top level type, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

@liggitt some of the tests fail without it

Copy link
Member

Choose a reason for hiding this comment

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

unless this is serialized in standalone way (which I'm not aware of), this should not have type info. tests that fail without that should be fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack removing it

@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from b68dbf8 to 512b3b8 Compare March 30, 2018 02:34
@dims
Copy link
Member Author

dims commented Mar 30, 2018

Ready and all green now @liggitt . thanks!


// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type KubeControllerManagerConfiguration struct {
Copy link
Member

Choose a reason for hiding this comment

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

these should probably end up in controllermanager.config.k8s.io under pkg/controller/apis, similar to kubelet. can you move them in a follow up?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes i can

@dims dims force-pushed the set-kube-scheduler-leader-elect-to-true branch from 512b3b8 to ba2778b Compare March 30, 2018 14:51
Thanks to some great sleuthing by ikruglov!

kube-controller-manager defaults --leader-elect to true. We should
do the same for kube-scheduler. kube-scheduler used to have this
set to true, but it got lost during refactoring in:
efb2bb7
@liggitt
Copy link
Member

liggitt commented Mar 30, 2018

thanks
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, dims, liggitt, timothysc, wlan0

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-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@bsalamat
Copy link
Member

Could you please update the title of this PR and state that it adds new configuration types?

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit a44c6a8 into kubernetes:master Mar 30, 2018
@dims dims changed the title Set leader-elect for kube-scheduler to true Set leader-elect for kube-scheduler to true / Adds new configuration types and rework how we set defaults Mar 30, 2018
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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. milestone/removed 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-scheduler defaults --lead-elect to false whereas kube-controller-manager defaults to true