Repository navigation
Fixes #36355: apply podLabels and podAnnotations to every k8s pipeline resource - #36354
Conversation
Resources the k8s pipeline client creates at runtime (Jobs, CronJobs, OMJobs, CronOMJobs, ConfigMaps, Secrets) live outside any GitOps manifest, so ArgoCD lists them as orphaned. Not every platform allows the AppProject orphanedResources ignore list, so the server has to stamp the ArgoCD tracking label and annotations itself. podAnnotations only reached pod templates and OMJob objects, and no label parameter existed. - Add podLabels (env K8S_POD_LABELS), parsed like podAnnotations. - Merge configured labels below the built-in labels in buildLabels, buildApplicationLabels and the new buildAutomationLabels, so a configured key can never change a label the client or the operator selects by. - Apply podAnnotations to the metadata of Jobs, CronJobs, job templates, ConfigMaps, Secrets, and to the application and automation pod templates, which had no metadata before. - Record the rule in docs/decisions and the k8s client README.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
The label and annotation tests only exercised the CronJob and CronOMJob paths, so buildAutomationJob or buildApplicationJob could lose the configured metadata unnoticed. The new test runs both flows with podLabels and podAnnotations set and checks the Job and its pod template, including that a built-in label wins over a configured value for the same key. The CronOMJob test now checks the exit-handler pod spec next to the main pod.
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ Approved🟡 Medium risk · Applying configurable labels and annotations to pipeline resources could change ArgoCD ownership, sync comparisons, and pruning behavior. Adds VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
…37047) * fix(k8s): backport operator pod label safety Required by the Kubernetes resource metadata backport (#36354). Backport of #35513, commit 263d763. * feat(k8s): backport pipeline pod metadata Backport #36354 to 2.0 using the original feature and test commits: 5a317d0 eb8484e Skip Kubernetes initialization in the existing bot-token unit tests so JWT assertions do not depend on a local cluster.
Describe your changes:
Fixes #36355
When
pipelineServiceClientConfig.typeisk8s,K8sPipelineClientcreates Jobs, CronJobs, OMJobs, CronOMJobs, ConfigMaps and Secrets at runtime. They come from no GitOps manifest, so ArgoCD lists every one of them as orphaned. The usual remedy (orphanedResources.ignoreon the ArgoCDAppProject) is not allowed on every platform. The alternative is for the resources to carry the ArgoCD tracking labelapp.kubernetes.io/instance=<app>and the annotationsargocd.argoproj.io/compare-options: IgnoreExtraneousandargocd.argoproj.io/sync-options: Prune=false.Today
podAnnotationsreaches only pod templates and OMJob/CronOMJob objects. Plain Jobs, CronJobs, job templates, ConfigMaps and Secrets get none, the application and automation Job pod templates have no metadata at all, and there is no label parameter.This PR:
podLabels(key=value,key=value, envK8S_POD_LABELS) toK8sPipelineClientConfig, parsed likepodAnnotations.buildLabels,buildApplicationLabelsand the newbuildAutomationLabels, so a configured key can never change a label the client or the OMJob operator selects by.podAnnotationsto the metadata of Jobs, CronJobs, job templates, ConfigMaps, Secrets and to the application/automation pod templates.podLabelstoconf/openmetadata.yamlandconf/openmetadata-h2-test.yaml.docs/decisions/2026-10-27-pod-labels-and-annotations-cover-every-spawned-resource.mdand in the k8s client README.Chart side: open-metadata/openmetadata-helm-charts#552 exposes
k8s.podLabelsandK8S_POD_LABELS.Type of change:
High-level design:
K8sPipelineClientConfig: one new field, reusingparseKeyValuePairs.K8sPipelineClient: label builders start fromk8sConfig.getPodLabels()and then put the built-in labels, so built-ins win on clash (the OMJob operator already applies the same precedence for its own identity labels, see ADR:2026-10-15-omjob-pods-are-selected-only-by-operator-owned-labels). A smallpodAnnotations()helper returnsnullfor an empty map, matching the existing call sites, and is used on everyV1ObjectMetathat lacked it.LabelBuilderalready copies OMJob spec labels,PodManagercopies spec annotations, andCronOMJobReconcilercopies CronOMJob labels and annotations onto each OMJob.resourceLabels/resourceAnnotationspair.podAnnotationswas already applied to OMJob object metadata, so its meaning was already "every spawned resource"; a second pair would only add config surface.labeltracking.annotationtracking embeds each resource's own name in the tracking id and is out of scope.Tests:
Use cases covered
podLabelsandpodAnnotations; a CronOMJob and its main/exit-handler pod specs carry them, and a configuredapp.kubernetes.io/componentdoes not override the built-iningestionvalue.podLabelsandpodAnnotationswith the OMJob operator disabled;deployPipelineemits a ConfigMap, Secret and CronJob whose object metadata, job template metadata and pod template metadata all carry them.podLabelsparsing, including the empty default.Unit tests
K8sPipelineClientTest(testConfiguredLabelsAndAnnotationsOnCronOMJobincluding the exit-handler pod,testConfiguredLabelsAndAnnotationsOnPlainCronJobResources,testConfiguredLabelsAndAnnotationsOnAutomationAndApplicationJobswith built-in label precedence),K8sPipelineClientConfigTest(testPodLabelsParser).mvn -pl openmetadata-service -Dtest='K8sPipelineClientTest,K8sPipelineClientConfigTest' test: 101 tests, 0 failures. After the review follow-up,K8sPipelineClientTestalone: 77 tests, 0 failures.mvn spotless:applyrun. Coverage % not measured.Backend integration tests
.github/java-tests/impact-map.jsoncomplete (plan_local_java_tests.py --check-branch).make java_affected_runwas not run locally (no Docker available on the preparing machine).Ingestion integration tests
Playwright (UI) tests
Manual testing performed
helm templateand confirmedK8S_POD_LABELSandK8S_POD_ANNOTATIONSland in the server secret with and without values.UI screen recording:
Not applicable: backend-only change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/2026-10-27-pod-labels-and-annotations-cover-every-spawned-resource.mdadded;check_decision_records.pypasses.New feature


Confidence Score: 5/5
The PR appears safe to merge; the previous test-coverage finding is fully addressed.Summary
Adds
podLabelsand extendspodAnnotationsto Kubernetes resources created by the pipeline client.Reviews (2) · Last reviewed commit: "Cover automation and application jobs in..." · Reviewed by Greptile