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 default leader election configuration #1598

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

astefanutti
Copy link
Member

@astefanutti astefanutti commented Jan 17, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

The leader election section of the Kueue configuration is not defaulted.

Kubernetes components, like the scheduler, usually delegate to component-base to set sensible defaults:

https://github.com/kubernetes/component-base/blob/d5ddea0e47af10468dcd90e09768b2661caf23f7/config/v1alpha1/defaults.go#L35

Implementing that recommended defaulting has been suggested in the following discussion: #1554 (comment).

Does this PR introduce a user-facing change?

The leaderElection field in the Configuration API is now defaulted.
Leader election is now enabled by default.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Jan 17, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 17, 2024
Copy link

netlify bot commented Jan 17, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 21a2512
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/65a8f09e35ed320008d7e4a9

@k8s-ci-robot
Copy link
Contributor

Hi @astefanutti. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 17, 2024
@tenzen-y
Copy link
Member

/ok-to-test

@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 Jan 17, 2024
Copy link
Contributor

@mimowo mimowo left a comment

Choose a reason for hiding this comment

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

LGTM overall

apis/config/v1beta1/groupversion_info.go Show resolved Hide resolved
LeaderElection: true,
LeaderElectionID: configapi.DefaultLeaderElectionID,
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
LeaseDuration: ptr.To(15 * time.Second),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of the magic values refer to values in defaultControlOption, so that is easier to identify which fields deviate from 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.

Good idea. Updated.

if len(cfg.LeaderElection.ResourceLock) == 0 {
// Default to Lease as component-base still defaults to endpoint resources
// until core components migrate to using Leases. See k/k #80289 for more details.
cfg.LeaderElection.ResourceLock = resourcelock.LeasesResourceLock
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a change compared to what is happening on the main branch? I'm wondering if this deserves a release note explaining what are the user-facing differences when using 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.

No, it doesn't change the default value compared to main. It's necessary so we can delegate to RecommendedDefaultLeaderElectionConfiguration, but that still defaults to endpoints as resource lock, because some Kubernetes components haven't migrated yet, and maintain the current default value for Kueue.
This can be removed once kubernetes/kubernetes#80289 is fixed.

cfg.LeaderElection.ResourceLock = resourcelock.LeasesResourceLock
}
// Use the default LeaderElectionConfiguration options
configv1alpha1.RecommendedDefaultLeaderElectionConfiguration(cfg.LeaderElection)
Copy link
Contributor

Choose a reason for hiding this comment

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

As before, question about user-facing consequences of setting the 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.

With the values already set in the default Kueue configuration, i.e.:

leaderElection:
leaderElect: true
resourceName: c1f6bfd2.kueue.x-k8s.io

That PR is "idem-potent".

The only change would be if an existing user would use a configuration with .leaderElection or .leaderElection.leaderElect not defined, then the new default would be true, instead of false.

But I'd be inclined to think enabling leader election by default is desirable.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about the values of LeaseDuration, RenewDeadline, RetryPeriod, as the values are now generated, are they ignored, or their values are as implicit defaults used before?

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, the latter, their values are equal to the implicit defaults used before.

@@ -43,13 +44,6 @@ const (
DefaultClusterQueuesMaxCount int32 = 10
)

func addDefaultingFuncs(scheme *runtime.Scheme) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice win

Copy link
Contributor

@mimowo mimowo left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @tenzen-y @alculquicondor

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

LGTM label has been added.

Git tree hash: d17270b277bc93330482b2f483ade14d255eea37

@alculquicondor
Copy link
Contributor

/release-note-edit

The leaderElection field in the Configuration API is now defaulted.
Leader election is now enabled by default.

@alculquicondor
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, astefanutti

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 Jan 18, 2024
@k8s-ci-robot k8s-ci-robot merged commit 94ec795 into kubernetes-sigs:main Jan 18, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.6 milestone Jan 18, 2024
@alculquicondor
Copy link
Contributor

/kind api-change

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Feb 13, 2024
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 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

None yet

5 participants