Skip to content

Enforced compliance of the id used in kubernetes annotations#488

Open
plup wants to merge 2 commits intoTheHive-Project:masterfrom
plup:master
Open

Enforced compliance of the id used in kubernetes annotations#488
plup wants to merge 2 commits intoTheHive-Project:masterfrom
plup:master

Conversation

@plup
Copy link
Copy Markdown

@plup plup commented Apr 1, 2026

What

Sanitize Cortex job and worker identifiers before using them as Kubernetes label values and in the
Job name in K8sJobRunnerSrv.

Why

Kubernetes rejects label values that don’t start and end with an alphanumeric character (max 63
chars). Some job IDs end with _, which produced 400 Bad Request on operations using labelSelector
(e.g. wait/delete on Jobs).

How

• Add kubernetesLabelValue() to trim invalid leading/trailing characters, cap length at 63, and
fall back to "0" only if nothing valid remains.
• Use it for cortex-job-id, cortex-worker-id, and for neuron-job-* name construction (aligned
with valid RFC 1123-style names).

Risk / follow-up

• Low for normal Cortex IDs.
• Old Job objects in-cluster may still have pre-sanitization labels; new Jobs use the new values.
Update any dashboards/alerts that assumed raw IDs on labels if applicable.

Testing

• ./sbt compile (not run in agent environment; please run locally).
• Deploy and run an analysis whose job ID ends with _; confirm Job create, wait, and delete
succeed without label parse errors.

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