Skip to content

Fix Kubernetes resource name and label length limits for long pipelin…#27059

Open
Esvanth wants to merge 1 commit intoopen-metadata:mainfrom
Esvanth:fix-27004-pod-name-limit
Open

Fix Kubernetes resource name and label length limits for long pipelin…#27059
Esvanth wants to merge 1 commit intoopen-metadata:mainfrom
Esvanth:fix-27004-pod-name-limit

Conversation

@Esvanth
Copy link
Copy Markdown

@Esvanth Esvanth commented Apr 5, 2026

Refactored Naming Logic: Updated K8sPipelineClient.java to ensure all Kubernetes resource names and labels (Jobs, CronJobs, ConfigMaps, Secrets) strictly adhere to the 63-character limit, even with long pipeline names.
Added Unit Tests: Included new test cases in K8sPipelineClientTest.java that verify the truncation logic for pipeline names up to 95 characters.
Successfully Pushed: Your changes are now live on your repository at https://github.com/Esvanth/OpenMetadata.
Next Steps:
If you are the original author of PR 27012, your PR should now show these new commits.
If you are not the author, you can now open a new Pull Request or ask the original author to pull these fixes from your branch: Esvanth/OpenMetadata:fix-27004-pod-name-limit.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

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!

labels.put(LABEL_COMPONENT, LABEL_VALUE_INGESTION);
labels.put(LABEL_MANAGED_BY, LABEL_VALUE_OPENMETADATA);
labels.put(LABEL_PIPELINE, sanitizeName(pipeline.getName()));
labels.put(LABEL_PIPELINE, buildKubernetesName("", pipeline.getName()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 Bug: Label selector mismatch: query uses raw sanitizeName but labels use buildKubernetesName

The buildLabels() method (line 1998) now uses buildKubernetesName("", pipeline.getName()) for the LABEL_PIPELINE value, which truncates long names to 63 chars. However, several methods that query by label selector still use sanitizeName() directly (which no longer truncates):

  • killIngestion (line 796): LABEL_PIPELINE + "=" + pipelineName
  • getQueuedPipelineStatusInternal (line 898): LABEL_PIPELINE + "=" + pipelineName
  • getLastIngestionLogs (line 1083): labelSelectorMap.put(LABEL_PIPELINE, pipelineName)
  • deleteJobsForPipeline (called from deletePipeline): LABEL_PIPELINE + "=" + pipelineName

For long pipeline names, the label value stored on the resource is truncated but the label selector used in queries is not, so queries will return zero results. This means: kill won't find running jobs, delete won't clean up jobs, queued status returns empty, and logs can't be retrieved.

Suggested fix:

Use buildKubernetesName("", pipeline.getName()) consistently
for label values and selectors, or extract a shared helper:

private String buildPipelineLabel(String name) {
  return buildKubernetesName("", name);
}

Then use it in both buildLabels() and all query methods.

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 5, 2026

Code Review 🚫 Blocked 0 resolved / 1 findings

Fixes Kubernetes resource name and label length limits for long pipeline names but introduces a critical label selector mismatch where queries use raw sanitizeName while labels use buildKubernetesName, causing selector failures.

🚨 Bug: Label selector mismatch: query uses raw sanitizeName but labels use buildKubernetesName

📄 openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:796 📄 openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:898 📄 openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:1083 📄 openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:1998

The buildLabels() method (line 1998) now uses buildKubernetesName("", pipeline.getName()) for the LABEL_PIPELINE value, which truncates long names to 63 chars. However, several methods that query by label selector still use sanitizeName() directly (which no longer truncates):

  • killIngestion (line 796): LABEL_PIPELINE + "=" + pipelineName
  • getQueuedPipelineStatusInternal (line 898): LABEL_PIPELINE + "=" + pipelineName
  • getLastIngestionLogs (line 1083): labelSelectorMap.put(LABEL_PIPELINE, pipelineName)
  • deleteJobsForPipeline (called from deletePipeline): LABEL_PIPELINE + "=" + pipelineName

For long pipeline names, the label value stored on the resource is truncated but the label selector used in queries is not, so queries will return zero results. This means: kill won't find running jobs, delete won't clean up jobs, queued status returns empty, and logs can't be retrieved.

Suggested fix
Use buildKubernetesName("", pipeline.getName()) consistently
for label values and selectors, or extract a shared helper:

private String buildPipelineLabel(String name) {
  return buildKubernetesName("", name);
}

Then use it in both buildLabels() and all query methods.
🤖 Prompt for agents
Code Review: Fixes Kubernetes resource name and label length limits for long pipeline names but introduces a critical label selector mismatch where queries use raw sanitizeName while labels use buildKubernetesName, causing selector failures.

1. 🚨 Bug: Label selector mismatch: query uses raw sanitizeName but labels use buildKubernetesName
   Files: openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:796, openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:898, openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:1083, openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java:1998

   The `buildLabels()` method (line 1998) now uses `buildKubernetesName("", pipeline.getName())` for the `LABEL_PIPELINE` value, which truncates long names to 63 chars. However, several methods that query by label selector still use `sanitizeName()` directly (which no longer truncates):
   
   - `killIngestion` (line 796): `LABEL_PIPELINE + "=" + pipelineName`
   - `getQueuedPipelineStatusInternal` (line 898): `LABEL_PIPELINE + "=" + pipelineName`
   - `getLastIngestionLogs` (line 1083): `labelSelectorMap.put(LABEL_PIPELINE, pipelineName)`
   - `deleteJobsForPipeline` (called from deletePipeline): `LABEL_PIPELINE + "=" + pipelineName`
   
   For long pipeline names, the label value stored on the resource is truncated but the label selector used in queries is not, so queries will return zero results. This means: kill won't find running jobs, delete won't clean up jobs, queued status returns empty, and logs can't be retrieved.

   Suggested fix:
   Use buildKubernetesName("", pipeline.getName()) consistently
   for label values and selectors, or extract a shared helper:
   
   private String buildPipelineLabel(String name) {
     return buildKubernetesName("", name);
   }
   
   Then use it in both buildLabels() and all query methods.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@Esvanth
Copy link
Copy Markdown
Author

Esvanth commented Apr 5, 2026

Summary of what was accomplished:
Refactored Naming Logic: Updated K8sPipelineClient.java to ensure all Kubernetes resource names and labels (Jobs, CronJobs, ConfigMaps, Secrets) strictly adhere to the 63-character limit, even with long pipeline names.

Added Unit Tests: Included new test cases in K8sPipelineClientTest.java that verify the truncation logic for pipeline names up to 95 characters.

Successfully Pushed: Your changes are now live on your repository at https://github.com/Esvanth/OpenMetadata.

Next Steps:
If you are the original author of PR 27012, your PR should now show these new commits.
If you are not the author, you can now open a new Pull Request or ask the original author to pull these fixes from your branch: Esvanth/OpenMetadata:fix-27004-pod-name-limit.

#Please do assign the task to me and add an label to it actually safe to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant