job: Manage job lifecycles individually instead of as groups (attempt 2)#67
Merged
job: Manage job lifecycles individually instead of as groups (attempt 2)#67
Conversation
Refactor job groups so registry owns the lifecycle. This ensures that jobs are always started in the order they're added and not in the order the job groups are created. - move lifecyle hooks onto the registry type and keep start/stop logic centralized - drop group-level context/wait-group management and route Group.Add through the registry - adjust job implementations/tests and all callers to the simplified API
In the Cilium operator we use two lifecycles in the application, one is always started and the other (LeaderLifecycle) is started when the operator is elected leader. In order to create jobs that are started when elected leader we need a way of constructing a job registry that uses the custom leader lifecycle. For this purpose add the [Registry.WithLifecycle] method that returns a new registry that uses the given lifecycle. This can be then used by the operator in the [WithLeaderLifecycle] method to also provide the job registry with the proper lifecycle. Signed-off-by: Jussi Maki <jussi@isovalent.com>
b5eb30b to
b0f80dc
Compare
dylandreimerink
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We reverted #62 as we were missing the ability to create a new job registry with a different lifecycle for use cases such as the "LeaderLifecycle" in the Cilium Operator.
This PR brings back the reverted commits from #62 and adds the
Registry.WithLifecycle. We're also now doing proper releases of cilium/hive so we can roll out the breaking API change (Registry.NewGroupno longer takes a lifecycle) in a controlled manner. Plan is to release hive v1.0 after this is merged (renovate bumps minor&patch versions of cilium/hive automatically so releasing major will require manual bump) and then fix&bump cilium/hive version in cilium/statedb and release v0.7, and finally bump both versions in cilium/cilium.cilium/cilium PR to validate that tests pass after bumping: cilium/cilium#44182