Skip to content

Use the real pod hostname in RenderedTaskInstanceFields for the Kubernetes executor - #72481

Open
dheerenmohta wants to merge 1 commit into
apache:mainfrom
dheerenmohta:fix-issue-28186
Open

Use the real pod hostname in RenderedTaskInstanceFields for the Kubernetes executor#72481
dheerenmohta wants to merge 1 commit into
apache:mainfrom
dheerenmohta:fix-issue-28186

Conversation

@dheerenmohta

Copy link
Copy Markdown
Contributor

RenderedTaskInstanceFields renders its stored pod spec via PodGenerator.construct_pod(), which assigns a brand-new random name — independent of the real name Kubernetes already gave the pod. So the pod name shown in RTIF's rendered spec almost never matched the actual running pod.

Since RTIF is written from inside the real pod, and Kubernetes sets a pod's hostname to its own metadata.name by default, this substitutes socket.gethostname() in on that in-pod rendering path only — the separate on-demand/preview path (used before a pod exists) is left untouched.

Includes a regression test with a negative control confirming it fails on the pre-fix code.

closes: #28186


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

Generated-by: Claude Code (Sonnet 5) following the guidelines

RenderedTaskInstanceFields' k8s pod spec is stamped by the task itself,
after Kubernetes has already created and named the real pod. However,
render_k8s_pod_yaml() rebuilds the pod spec from scratch and assigns it
a brand new random name via create_unique_id(), so the pod name shown
in RTIF's rendered spec almost never matches the pod actually running
the task, confusing anyone trying to correlate the two.

Since we are running inside that real pod by the time RTIF is written,
and Kubernetes sets a pod's hostname to its own metadata.name by
default, socket.gethostname() gives us the real name. Substitute it in
only for that in-pod path, leaving the on-demand preview path (used
when no real pod exists yet) untouched.

Closes: apache#28186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pod name incorrect in RenderedTaskInstanceFields

1 participant