Use the real pod hostname in RenderedTaskInstanceFields for the Kubernetes executor - #72481
Open
dheerenmohta wants to merge 1 commit into
Open
Use the real pod hostname in RenderedTaskInstanceFields for the Kubernetes executor#72481dheerenmohta wants to merge 1 commit into
dheerenmohta wants to merge 1 commit into
Conversation
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
dheerenmohta
requested review from
hussein-awala,
jedcunningham and
jscheffl
as code owners
September 3, 2026 13:40
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.
RenderedTaskInstanceFieldsrenders its stored pod spec viaPodGenerator.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.nameby default, this substitutessocket.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?
Generated-by: Claude Code (Sonnet 5) following the guidelines