fix: Kubernetes Job Service lifecycle - #368
Open
ethanbates-ez wants to merge 2 commits into
Open
ethanbates-ez wants to merge 2 commits into
ethanbates-ez wants to merge 2 commits into
Conversation
Signed-off-by: Ethan Bates <ethan.bates@shopify.com>
3 tasks
Ark-kun
reviewed
Sep 24, 2026
Contributor
There was a problem hiding this comment.
Maybe, put this test file in launchers sub-directory?
Ark-kun
reviewed
Sep 24, 2026
| labels=_DEFAULT_KUBERNETES_LABELS, | ||
| ), | ||
| spec=k8s_client_lib.V1ServiceSpec( | ||
| # "Headless" service. |
Contributor
There was a problem hiding this comment.
This comment has disappeared during the code move. Did anything else change (outside of the owner reference addition)?
I think I see some subtle changes.
I prefer doing refactorings manually or via IDE source actions such that I can be sure no extra modifications are produced. It could be pretty hard to find differences between two almost identical images or code snippets.
Author
There was a problem hiding this comment.
I will tighten the diff up; the flow here
- Service creation now happens after Job creation
- If Service creation fails, the Job is rolled back so it cannot continue without its required DNS.
- Cleanup explicitly deletes same-named legacy Services and tolerates an already-deleted Job or Service
Ark-kun
approved these changes
Sep 24, 2026
Ark-kun
left a comment
Contributor
There was a problem hiding this comment.
Thank you for this improvement.
I've left a couple of comments.
Signed-off-by: Ethan Bates <ethan.bates@shopify.com>
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.
What
Give each indexed Kubernetes Job's headless Service a Job owner reference so Kubernetes removes the Service and its EndpointSlice with the Job. Cleanup also explicitly deletes the deterministic Service name for executions created before owner references existed. A Job is rolled back if its required Service cannot be created.
Why
Job cleanup deleted only the Job, leaving one permanent headless Service and EndpointSlice per execution. High-throughput installations can accumulate enough orphaned objects to exhaust cluster-wide informer caches and control-plane consumers.
Associated Issue
Fixes #370
Dev Notes
The Job must be created first to obtain the UID required by the Service owner reference. This introduces a short interval before the DNS records exist; the launcher does not return until the Service is created, and a creation failure immediately rolls back the Job.