Allow users to differentiate task pods from different namespaces in multi-namespace settings - #17749
Conversation
|
the name |
|
hi @FrankChen021, I will work on documentation and changes after #17738 is merged. Since this PR will not make sense without it. |
Hi @FrankChen021, I have changed the name to |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Kubernetes task naming functionality by allowing users to specify an alias prefix for task pods via the new configuration property "druid.indexer.runner.k8sTaskPodNamePrefix". The changes update the way K8s job names are generated—incorporating a user-defined alias (when provided)—and adjust the related tests, utilities, and documentation to support the new behavior.
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Test Files (PodTemplateTaskAdapterTest, K8sTaskAdapterTest, etc.) | Modified tests to use the new K8sTaskId constructors with an added prefix parameter. |
| KubernetesOverlordUtils.java | Updated job name conversion to incorporate the task pod name prefix with truncation to 30 characters. |
| KubernetesTaskRunnerConfig.java | Added new configuration property and updated builder methods to support specifying a task pod name prefix. |
| KubernetesPeonLifecycle and related classes | Updated constructors and method calls to pass the new K8sTaskId with the optional alias prefix. |
| docs/development/extensions-core/k8s-jobs.md | Updated documentation explaining the new property and its effect on task pod naming. |
Comments suppressed due to low confidence (2)
extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunnerConfig.java:385
- [nitpick] Consider renaming the method 'withk8sTaskPodNamePrefix' to 'withK8sTaskPodNamePrefix' to follow standard camel case conventions for method names.
public Builder withk8sTaskPodNamePrefix(String k8sTaskPodNamePrefix)
docs/development/extensions-core/k8s-jobs.md:772
- [nitpick] Ensure that the naming and description in the documentation exactly match the implementation details in the code to avoid any configuration mismatches.
| `druid.indexer.runner.k8sTaskPodNamePrefix` | `String` | Use this if you want to change your task name to contain a more human-readable prefix. Maximum 30 characters. Special characters `: - . _` will be ignored. | `""` | No |
FrankChen021
left a comment
There was a problem hiding this comment.
LGTM with a minor document description suggestion
Co-authored-by: Frank Chen <frankchen@apache.org>
…rg/apache/druid/k8s/overlord/KubernetesTaskRunnerConfig.java Co-authored-by: Frank Chen <frankchen@apache.org>
…ulti-namespace settings (apache#17749) * Add alias function to K8sTasks * Unit testing for alias system * Pass all unit test for peon-alias * Task ID abstraction in unit tests * Change alias config to k8sTaskNamePrefix * Add documentation for peon-alias * Add documentation for peon-alias * Fix spellcheck * Update docs/development/extensions-core/k8s-jobs.md Co-authored-by: Frank Chen <frankchen@apache.org> * Update extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunnerConfig.java Co-authored-by: Frank Chen <frankchen@apache.org> * Fix spelling mistake * Fix method call in test file --------- Co-authored-by: Frank Chen <frankchen@apache.org>
…ulti-namespace settings (apache#17749) * Add alias function to K8sTasks * Unit testing for alias system * Pass all unit test for peon-alias * Task ID abstraction in unit tests * Change alias config to k8sTaskNamePrefix * Add documentation for peon-alias * Add documentation for peon-alias * Fix spellcheck * Update docs/development/extensions-core/k8s-jobs.md Co-authored-by: Frank Chen <frankchen@apache.org> * Update extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunnerConfig.java Co-authored-by: Frank Chen <frankchen@apache.org> * Fix spelling mistake * Fix method call in test file --------- Co-authored-by: Frank Chen <frankchen@apache.org> (cherry picked from commit f9553f7)
Yeah, @GWphua , I am not sure if this is a real improvement over what we had earlier. That said, using the substring of the task name was not all that great either. Side note: |
Hi @kfaraz, unfortunately there will be disruptions to rolling upgrades. The old tasks (without configured On our side, we need to notify our users to expect this to happen. |
Oh, this is problematic, @GWphua , as the Overlord is losing track of those tasks and re-launching them, even though the original tasks are still running and will finish normally. This will lead to duplicate data and possibly metadata inconsistency errors in case of streaming ingestion. Is there any way to mitigate this? |
|
This is the same as the other newly introduced Currently I think we can add some text to the doc to give a guidance on changing of this property which requires users to stop all running tasks first. |
Yes, let's update the docs and we should also clearly call this out in the release notes and upgrade notes for this feature (just adding it in the PR description should suffice). cc: @GWphua |
…ces in multi-namespace settings (apache#17749)" This reverts commit f9553f7.
…ulti-namespace settings (apache#17749) * Add alias function to K8sTasks * Unit testing for alias system * Pass all unit test for peon-alias * Task ID abstraction in unit tests * Change alias config to k8sTaskNamePrefix * Add documentation for peon-alias * Add documentation for peon-alias * Fix spellcheck * Update docs/development/extensions-core/k8s-jobs.md Co-authored-by: Frank Chen <frankchen@apache.org> * Update extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunnerConfig.java Co-authored-by: Frank Chen <frankchen@apache.org> * Fix spelling mistake * Fix method call in test file --------- Co-authored-by: Frank Chen <frankchen@apache.org>
Description
Related to #17738.
When we have task pods running in multiple namespaces, it will be difficult to tell which task pods are being started by which cluster, especially when we have very similar job names.
Added an alias prefix tag to allow Kubernetes operators to identify which cluster the task pods are created from.
Here are some of the things I have considered when implementing the change:
Intuition:
k8sJobNameis currently broken down into 2 segments: {taskId}-{hash(taskId)}. The hashing will take up 32 characters, and is needed to maintain uniqueness. Hence, we can only work with making changes to thetaskIdpart. The first thought is to changetaskIdto namespace, so that we at least know which namespace a task pod belongs in. However, I encountered cases where namespace have long names, and similar prefix (Thinkdata-infra-druid-cluster-ns1,data-infra-druid-cluster-ns2). This is not a good solution, given that there's a character limit to the job name and there is quite a lot of redundant information.So, I introduced a new
druid.indexer.runner. k8sTaskPodNamePrefixconfig to allow users to provide an alias prefix instead. Now,k8sJobNamewill be of the form {alias}-{hash(taskId)}. Ifk8sTaskPodNamePrefixis not provided, we will default to using the current {taskId}-{hash(taskId)} naming convention.Note that this solution will not allow us to differentiate between tasks in Kubernetes. However, we can still see our tasks and their corresponding taskID via the Web Console.
Note: My approach involves changing the method of K8sTaskId, prompting change in a lot other classes. This may not be the best way, please advise if there's a more elegant solution.
Release note
You can now name your K8s job names using
druid.indexer.runner. k8sTaskPodNamePrefixKey changed/added classes in this PR
Test Files
This PR has: