-
Notifications
You must be signed in to change notification settings - Fork 1.3k
✨ Add pre-start hook support to manager #3429
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
base: main
Are you sure you want to change the base?
Conversation
When implementing a controller that uses leader election, there maybe be work that needs to be done after winning the election but before processing enqueued requests. For example, a controller may need to build up an internal mapping of the current state of the cluster before it can begin reconciling. This changeset adds support for adding prestart hooks to controller-runtime's manager implementation. This hook runs after the manager has been elected leader, immediately before the leader election controllers are started. Related kubernetes-sigs#607
…into prestart-hook
feat(manager): add prestart hook support See merge request asylum/upstream/controller-runtime!1
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: leontappe The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @leontappe! |
|
Hi @leontappe. 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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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-sigs/prow repository. |
|
/ok-to-test |
|
@leontappe: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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-sigs/prow repository. I understand the commands that are listed here. |
I have a use case similar to the one described in a previous PR and this issue.
My controller needs to consume job status files on start, that would normally be worked on by a custom runnable during runtime. With vanilla controller-runtime this is currently not possible as any code that is run before reconciliation, has no access to a running manager.
This PR provides a way to register runnables as hooks that you can supply to your manager.
This PR is based on a fork of https://github.com/terinjokes/controller-runtime/tree/prestart-hook which is in turn a fork of this repo. I rebased the current master onto the latest development state of the original PR and implemented some of the proposals made by @JoelSpeed