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

Fix the default LeaderElectionID and make it an argument #1639

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

goyalankit
Copy link
Contributor

@goyalankit goyalankit commented Jul 28, 2022

What this PR does / why we need it:
This PR fixes the default leader election ID which has an invalid format. If one enables leader election through leader-elect=true, the operator fails to start with the following error:

Before:

> go run ./cmd/training-operator.v1/main.go -leader-elect=true --namespace kubeflow
1.6589798403535447e+09  INFO    controller-runtime.metrics      Metrics server is starting to listen    {"addr": ":8080"}
1.6589798403555276e+09  INFO    setup   starting manager
1.6589798403558226e+09  INFO    Starting server {"path": "/metrics", "kind": "metrics", "addr": "[::]:8080"}
1.6589798403558557e+09  INFO    Starting server {"kind": "health probe", "addr": "[::]:8081"}
I0727 20:44:00.356108 1889297 leaderelection.go:248] attempting to acquire leader lease kubeflow/1ca428e5....
E0727 20:44:00.360526 1889297 leaderelection.go:334] error initially creating leader election record: Lease.coordination.k8s.io "1ca428e5." is invalid: metadata.name: Invalid value: "1ca428e5.": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
E0727 20:44:04.107669 1889297 leaderelection.go:334] error initially creating leader election record: Lease.coordination.k8s.io "1ca428e5." is invalid: metadata.name: Invalid value: "1ca428e5.": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Fails to acquire lease:

E0727 20:44:04.107669 1889297 leaderelection.go:334] error initially creating leader election record: Lease.coordination.k8s.io "1ca428e5." is invalid: metadata.name: Invalid value: "1ca428e5.": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

After:

> go run ./cmd/training-operator.v1/main.go -leader-elect=true --namespace kubeflow
1.6589798807258694e+09  INFO    controller-runtime.metrics      Metrics server is starting to listen    {"addr": ":8080"}
1.6589798807272537e+09  INFO    setup   starting manager
1.6589798807275426e+09  INFO    Starting server {"path": "/metrics", "kind": "metrics", "addr": "[::]:8080"}
1.6589798807275436e+09  INFO    Starting server {"kind": "health probe", "addr": "[::]:8081"}
I0727 20:44:40.727719 1890098 leaderelection.go:248] attempting to acquire leader lease kubeflow/1ca428e5.training-operator.kubeflow.org...
I0727 20:44:57.469968 1890098 leaderelection.go:258] successfully acquired lease kubeflow/1ca428e5.training-operator.kubeflow.org
1.6589798974700997e+09  DEBUG   events  Normal  {"object": {"kind":"Lease","namespace":"kubeflow","name":"1ca428e5.training-operator.kubeflow.org","uid":"bea108c0-01ba-4759-bdd4-d55accfa7596","apiVersion":"coordination.k8s.io/v1","resourceVersion":"16304"}, "reason": "LeaderElection", "message": "angoyal-ld5.linkedin.biz_a24fbed3-c23d-4d3d-922b-407b342e23d8 became leader"}
1.6589798974702497e+09  INFO    Starting EventSource    {"controller": "mxjob-controller", "source": "kind source: *v1.MXJob"}
1.6589798974702735e+

Successfully acquires lease:

I0727 20:44:40.727719 1890098 leaderelection.go:248] attempting to acquire leader lease kubeflow/1ca428e5.training-operator.kubeflow.org... I0727 20:44:57.469968 1890098 leaderelection.go:258] successfully acquired lease kubeflow/1ca428e5.training-operator.kubeflow.org

Which issue(s) this PR fixes (optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged):
Fixes #1640

Checklist:

  • Docs included if any changes are user facing

Copy link
Member

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@gaocegege
Copy link
Member

/ok-to-test

/lgtm
/approve

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaocegege, goyalankit

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

@coveralls
Copy link

coveralls commented Jul 28, 2022

Pull Request Test Coverage Report for Build 2751166096

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 39.914%

Files with Coverage Reduction New Missed Lines %
pkg/controller.v1/mpi/mpijob_controller.go 6 77.46%
Totals Coverage Status
Change from base Build 2735722547: 0.0%
Covered Lines: 2331
Relevant Lines: 5840

💛 - Coveralls

@google-oss-prow google-oss-prow bot merged commit 32db9b9 into kubeflow:master Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default LeaderElectionID is invalid
3 participants