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 operator startup delay caused by leader election lease not being released correctly #24978

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

giorio94
Copy link
Member

The leader election logic of the operator is currently executed in a separate goroutine started by an OnStart hook, and relies on a context (canceled by the respective OnStop hook) for shutting down. Once this occurs, it will automatically release the lease, to allow the immediate election of a new leader. Yet, we do not explicitly wait for this operation to complete, and the operator might stop before the lease is actually released, introducing a ~15 seconds delay for the next election.

This PR fixes this by introducing a WaitGroup to explicitly wait for the leader election loop to terminate before continuing with the shutdown process.

Fix operator startup delay caused by leader election lease not being released correctly

@giorio94 giorio94 added kind/bug This is a bug in the Cilium logic. release-note/bug This PR fixes an issue in a previous release of Cilium. area/operator Impacts the cilium-operator component needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch labels Apr 19, 2023
@giorio94 giorio94 requested a review from a team as a code owner April 19, 2023 13:07
@giorio94 giorio94 requested a review from joamaki April 19, 2023 13:07
@giorio94
Copy link
Member Author

giorio94 commented Apr 19, 2023

kubernetes-e2e hit #24622. Rerunning

@giorio94
Copy link
Member Author

Travis CI hit unrelated flake #24491

@giorio94
Copy link
Member Author

/test

The leader election logic of the operator is currently executed in a
separate goroutine started by an OnStart hook, and relies on a context
(canceled by the respective OnStop hook) for shutting down. Once this
occurs, it will automatically release the lease, to allow the immediate
election of a new leader. Yet, we do not explicitly wait for this
operation to complete, and the operator might stop before the lease is
actually released, introducing a ~15 seconds delay for the next election.

This commit fixes this by introducing a WaitGroup to explicitly wait for
the leader election loop to terminate before continuing with the
shutdown process.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94 giorio94 force-pushed the mio/operator-fix-release-lease branch from af4c97b to 187bc7f Compare April 20, 2023 14:08
@giorio94
Copy link
Member Author

Rebased onto master since egressgw tests were failing due to #24835 having been merged.

@giorio94
Copy link
Member Author

/test

Copy link
Contributor

@joamaki joamaki left a comment

Choose a reason for hiding this comment

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

Thanks!

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 24, 2023
@michi-covalent
Copy link
Contributor

thank you mlh

@michi-covalent michi-covalent merged commit e7c748f into cilium:main Apr 25, 2023
56 checks passed
@sayboras sayboras mentioned this pull request Apr 26, 2023
7 tasks
@sayboras sayboras added backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. and removed needs-backport/1.13 This PR / issue needs backporting to the v1.13 branch backport-pending/1.13 The backport for Cilium 1.13.x for this PR is in progress. labels Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/operator Impacts the cilium-operator component backport-done/1.13 The backport for Cilium 1.13.x for this PR is done. kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants