Skip to content

Fixes #36355: apply podLabels and podAnnotations to every k8s pipeline resource - #36354

Merged
pmbrull merged 4 commits into
open-metadata:mainfrom
traagel:k8s-pipeline-pod-labels
Nov 4, 2026
Merged

pmbrull merged 4 commits into
open-metadata:mainfrom
traagel:k8s-pipeline-pod-labels

Conversation

@traagel

@traagel traagel commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36355

When pipelineServiceClientConfig.type is k8s, K8sPipelineClient creates 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.ignore on the ArgoCD AppProject) is not allowed on every platform. The alternative is for the resources to carry the ArgoCD tracking label app.kubernetes.io/instance=<app> and the annotations argocd.argoproj.io/compare-options: IgnoreExtraneous and argocd.argoproj.io/sync-options: Prune=false.

Today podAnnotations reaches 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:

  • Adds podLabels (key=value,key=value, env K8S_POD_LABELS) to K8sPipelineClientConfig, parsed like podAnnotations.
  • Merges the 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 OMJob operator selects by.
  • Applies podAnnotations to the metadata of Jobs, CronJobs, job templates, ConfigMaps, Secrets and to the application/automation pod templates.
  • Adds podLabels to conf/openmetadata.yaml and conf/openmetadata-h2-test.yaml.
  • Records the rule in docs/decisions/2026-10-27-pod-labels-and-annotations-cover-every-spawned-resource.md and in the k8s client README.

Chart side: open-metadata/openmetadata-helm-charts#552 exposes k8s.podLabels and K8S_POD_LABELS.

Type of change:

  • New feature

High-level design:

  • K8sPipelineClientConfig: one new field, reusing parseKeyValuePairs.
  • K8sPipelineClient: label builders start from k8sConfig.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 small podAnnotations() helper returns null for an empty map, matching the existing call sites, and is used on every V1ObjectMeta that lacked it.
  • The OMJob operator needs no change: LabelBuilder already copies OMJob spec labels, PodManager copies spec annotations, and CronOMJobReconciler copies CronOMJob labels and annotations onto each OMJob.
  • Alternative rejected: a separate resourceLabels/resourceAnnotations pair. podAnnotations was already applied to OMJob object metadata, so its meaning was already "every spawned resource"; a second pair would only add config surface.
  • Rollout: additive and backward compatible. Both parameters default to empty. Existing CronJobs/CronOMJobs pick up the new metadata on the next pipeline redeploy.
  • Limitation: static values only work with ArgoCD label tracking. annotation tracking embeds each resource's own name in the tracking id and is out of scope.

Tests:

Use cases covered

  • Operator sets podLabels and podAnnotations; a CronOMJob and its main/exit-handler pod specs carry them, and a configured app.kubernetes.io/component does not override the built-in ingestion value.
  • Operator sets podLabels and podAnnotations with the OMJob operator disabled; deployPipeline emits a ConfigMap, Secret and CronJob whose object metadata, job template metadata and pod template metadata all carry them.
  • podLabels parsing, including the empty default.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: K8sPipelineClientTest (testConfiguredLabelsAndAnnotationsOnCronOMJob including the exit-handler pod, testConfiguredLabelsAndAnnotationsOnPlainCronJobResources, testConfiguredLabelsAndAnnotationsOnAutomationAndApplicationJobs with built-in label precedence), K8sPipelineClientConfigTest (testPodLabelsParser).
  • mvn -pl openmetadata-service -Dtest='K8sPipelineClientTest,K8sPipelineClientConfigTest' test: 101 tests, 0 failures. After the review follow-up, K8sPipelineClientTest alone: 77 tests, 0 failures. mvn spotless:apply run. Coverage % not measured.

Backend integration tests

  • Not applicable (no API changes). The branch leaves .github/java-tests/impact-map.json complete (plan_local_java_tests.py --check-branch). make java_affected_run was not run locally (no Docker available on the preparing machine).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Rendered the companion chart change with helm template and confirmed K8S_POD_LABELS and K8S_POD_ANNOTATIONS land in the server secret with and without values.
  2. Not yet exercised against a live cluster with ArgoCD.

UI screen recording:

Not applicable: backend-only change.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (No schema changes.)
  • For a UI feature or feature task: not applicable, backend-only.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: docs/decisions/2026-10-27-pod-labels-and-annotations-cover-every-spawned-resource.md added; check_decision_records.py passes.

New feature

  • The issue properly describes why the new feature is needed, what's the goal, and how we are building it.
  • I have updated the documentation (k8s client README, decision record, chart README in the companion PR).
  • I have added tests around the new logic.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous test-coverage finding is fully addressed.

Summary

Adds podLabels and extends podAnnotations to Kubernetes resources created by the pipeline client.

  • Ingestion resources carry configured labels and annotations.
  • Application and automation jobs carry configured labels and annotations.

Reviews (2) · Last reviewed commit: "Cover automation and application jobs in..." · Reviewed by Greptile

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.
@traagel
traagel requested a review from a team as a code owner October 27, 2026 12:51
@traagel
traagel requested a review from mohityadav766 October 27, 2026 12:51
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This 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 skip-pr-checks label.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@traagel traagel changed the title feat(k8s): apply podLabels and podAnnotations to every pipeline resource Fixes #36355: apply podLabels and podAnnotations to every k8s pipeline resource Oct 27, 2026
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.
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@pmbrull pmbrull added the safe to test Add this label to run secure Github workflows on PRs label Nov 3, 2026
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@pmbrull pmbrull added the safe to test Add this label to run secure Github workflows on PRs label Nov 3, 2026
@pmbrull
pmbrull added this pull request to the merge queue Nov 3, 2026
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Applying configurable labels and annotations to pipeline resources could change ArgoCD ownership, sync comparisons, and pruning behavior.

Adds podLabels configuration and extends podAnnotations to every Kubernetes resource spawned by the K8s pipeline client, including Jobs, CronJobs, ConfigMaps, Secrets, and application/automation pod templates, so ArgoCD stops flagging them as orphaned. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@pmbrull pmbrull added safe to test Add this label to run secure Github workflows on PRs 2.1 labels Nov 4, 2026
@pmbrull
pmbrull merged commit 45ce442 into open-metadata:main Nov 4, 2026
131 of 138 checks passed
pmbrull added a commit that referenced this pull request Nov 4, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

K8s pipeline client: configurable labels and annotations on every spawned resource (ArgoCD marks them orphaned)

3 participants