Skip to content

Make Kubernetes task Jobs execution-scoped#78

Merged
ianhodge merged 2 commits into
mainfrom
oz-agent/k8s-execution-job-identity
May 29, 2026
Merged

Make Kubernetes task Jobs execution-scoped#78
ianhodge merged 2 commits into
mainfrom
oz-agent/k8s-execution-job-identity

Conversation

@ianhodge

Copy link
Copy Markdown
Member

Summary

  • Add execution_id to task assignments and backend task params.
  • Make Kubernetes Job names, execution labels, pod watches, and log/failure pod lookups use the concrete execution identity.
  • Keep logical run IDs unchanged for --task-id, OZ_RUN_ID, and task completed/failed messages, with task ID fallback when older servers do not send execution_id.

Validation

  • go test ./internal/worker
  • go test ./...

Notes

  • This is worker-side support; the full end-to-end path still requires the server to populate execution_id in task assignment messages.

Co-Authored-By: Oz oz-agent@warp.dev

Conversation: https://staging.warp.dev/conversation/919550f0-b403-4e10-bf5d-8896304796bd
Run: https://oz.staging.warp.dev/runs/019e739f-ab1c-75a6-a800-619fc2c6bef6
This PR was generated with Oz.

Co-Authored-By: Oz <oz-agent@warp.dev>
@ianhodge ianhodge marked this pull request as ready for review May 29, 2026 15:27
@ianhodge ianhodge requested review from bnavetta and captainsafia May 29, 2026 16:09

@captainsafia captainsafia left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems sensible overall! Had one question inline about how we want to handle the transition to this new label format if executions are still inflight when the user upgrades.

}

func (b *KubernetesBackend) watchTaskPods(ctx context.Context, taskID string) (watch.Interface, error) {
func (b *KubernetesBackend) watchTaskPods(ctx context.Context, executionID string) (watch.Interface, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In here and in listTaskPods below, do we need to be concerned about the handling existing tasks if the upgrade happens in flight?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Right now, if the worker's restarted it'll detach from existing tasks and won't try to re-watch them, so we should be fine. Ideally it would rediscover existing tasks though

Comment thread internal/worker/kubernetes.go Outdated
fmt.Sprintf("OZ_WORKSPACE_ROOT=%s", defaultWorkspaceMountPath),
"OZ_WORKER_BACKEND="+kubernetesBackendTypeName,
fmt.Sprintf("OZ_RUN_ID=%s", params.TaskID),
fmt.Sprintf("OZ_EXECUTION_ID=%s", executionID),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We probably don't need this in the container environment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in 953104c by omitting OZ_EXECUTION_ID from the Kubernetes task/setup container env and updating the tests to assert it stays out of the container environment.

}

func (b *KubernetesBackend) watchTaskPods(ctx context.Context, taskID string) (watch.Interface, error) {
func (b *KubernetesBackend) watchTaskPods(ctx context.Context, executionID string) (watch.Interface, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Right now, if the worker's restarted it'll detach from existing tasks and won't try to re-watch them, so we should be fine. Ideally it would rediscover existing tasks though

Co-Authored-By: Oz <oz-agent@warp.dev>
@ianhodge ianhodge merged commit 3cd547b into main May 29, 2026
8 checks passed
@ianhodge ianhodge deleted the oz-agent/k8s-execution-job-identity branch May 29, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants