Skip to content

Comments

Add pod name to TaskLocation for easier observability and debugging.#14758

Merged
suneet-s merged 7 commits intoapache:masterfrom
georgew5656:addPodNameToLocation
Aug 7, 2023
Merged

Add pod name to TaskLocation for easier observability and debugging.#14758
suneet-s merged 7 commits intoapache:masterfrom
georgew5656:addPodNameToLocation

Conversation

@georgew5656
Copy link
Contributor

Adds pod name to the TaskLocation object for Kubernetes task scheduling to make debugging easier.

Description

Since the task id <-> kubernetse pod name mapping is not direct and hard to figure out, its helpful for debugging to show the pod name in the druid console. I think it makes sense to add this to task location since the pod the task is running on is sort of like the location when running tasks in K8s.

I also added a log message on the overlord when the task location is set because this is useful for forensics (taskLocation is cleared when the task finishes)

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...

I thought about just putting the pod name into the task object itself, but i liked the idea of having it in taskLocation in case we ever have some concept of retrying tasks on pods (which would result in a task running as a different pod name)

Release note

  • Surface kubernetes pod name in the K8sTaskRunner to improve visibility and forensics.
Key changed/added classes in this PR
  • TaskLocation
  • KubernetesPeonLifecycle

This is what the task location looks like in the druid console now.
Screenshot 2023-08-04 at 10 54 24 AM

If the field is null (e.g. when not running the k8s task runner) nothing will show up under k8sPodName.

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Contributor

@YongGang YongGang left a comment

Choose a reason for hiding this comment

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

LGTM

private final int tlsPort;

@Nullable
private final String k8sPodName;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use a more generic field name here instead of named it after k8s? Maybe just name it jobName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, is there another use case for using this field? it doesn't show up in the console if its not set so i figured its okay to leave it as more specific

Copy link
Contributor

Choose a reason for hiding this comment

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

I think k8sJobName will be a good name here as this is what it is called in the code in K8sTaskId

Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

Nice!

private final int tlsPort;

@Nullable
private final String k8sPodName;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think k8sJobName will be a good name here as this is what it is called in the code in K8sTaskId

Assert.assertNull(noK8sJobName.getK8sPodName());

TaskLocation k8sJobName = TaskLocation.create("foo", 1, 2, false, "job-name");
Assert.assertEquals("job-name", k8sJobName.getK8sPodName());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it would be better to split this test into 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

k8sJobName != k8sPodName, in this case i think the pod name is more useful but we could add both if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed the tests

georgew5656 and others added 3 commits August 7, 2023 09:36
…a/org/apache/druid/k8s/overlord/KubernetesPeonLifecycle.java

Co-authored-by: Suneet Saldanha <suneet@apache.org>
@georgew5656 georgew5656 requested a review from suneet-s August 7, 2023 14:28
@suneet-s suneet-s merged commit 14940dc into apache:master Aug 7, 2023
@LakshSingla LakshSingla added this to the 28.0 milestone Oct 12, 2023
FrankChen021 pushed a commit that referenced this pull request Feb 3, 2025
…14758)

* Add pod name to location

* Add log

* fix style

* Update extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesPeonLifecycle.java

Co-authored-by: Suneet Saldanha <suneet@apache.org>

* Fix unit tests

---------

Co-authored-by: Suneet Saldanha <suneet@apache.org>
GabrielCWT pushed a commit to GabrielCWT/druid that referenced this pull request Sep 9, 2025
…pache#14758)

* Add pod name to location

* Add log

* fix style

* Update extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesPeonLifecycle.java

Co-authored-by: Suneet Saldanha <suneet@apache.org>

* Fix unit tests

---------

Co-authored-by: Suneet Saldanha <suneet@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants