Add annotation for pod template#16772
Conversation
kfaraz
left a comment
There was a problem hiding this comment.
Changes look good, left minor suggestions.
| * @return The pod template that should be used to run the task. | ||
| */ | ||
| @NotNull PodTemplate getPodTemplateForTask(Task task, Map<String, PodTemplate> templates); | ||
| @NotNull Pair<String, PodTemplate> getPodTemplateForTask(Task task, Map<String, PodTemplate> templates); |
There was a problem hiding this comment.
For code hygiene and readability, I would advise creating a dedicated class PodTemplateWithKey rather than use a Pair, as pairs are often difficult to interpret.
Also, the javadoc needs to be updated.
| public Pair<String, PodTemplate> getPodTemplateForTask(Task task, Map<String, PodTemplate> templates) | ||
| { | ||
| return templates.getOrDefault(task.getType(), templates.get("base")); | ||
| String templateKey = templates.containsKey(task.getType()) ? task.getType() : "base"; |
There was a problem hiding this comment.
Should "base" be kept as a constant somewhere?
| .editTemplate() | ||
| .editOrNewMetadata() | ||
| .addToAnnotations(getPodTemplateAnnotations(task)) | ||
| .addToAnnotations(DruidK8sConstants.TASK_JOB_TEMPLATE, podTemplatePair.lhs) |
There was a problem hiding this comment.
one line is adding it to the job spec and one to the pod template spec (which will become the created pod).
There was a problem hiding this comment.
Ah, thanks for the clarification, I had missed the editTemplate() invocation.
kfaraz
left a comment
There was a problem hiding this comment.
Looks good to me 🚀
Can be merged once CI passes.
* Add annotation for pod template * pr comments * add test cases * add tests
* Add annotation for pod template * pr comments * add test cases * add tests
* Add annotation for pod template * pr comments * add test cases * add tests
* Add annotation for pod template * pr comments * add test cases * add tests
* Add annotation for pod template * pr comments * add test cases * add tests
Add the template name as a annotation on the pod spec to tell which pods are running which templates in metrics.
Description
It can be useful to group k8s pods launched by mmless ingestion based on the template they used for metrics, logs, etc. To do this we can add the template name as a annotation.
Release note
Key changed/added classes in this PR
PodTemplateTaskAdapterThis PR has: