[ZEPPELIN-5901] Sanitize interpreter pod user label to satisfy Kubernetes label rules #5529
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.62) × (1 − Review Confidence (0.85)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.62 · 118 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.286
Sensitive Paths
sensitive_paths
0.062
Real PR Conversation Timeline
3 items
Approved
Verified on a real Kubernetes deployment (k3s, official images + k8s/zeppelin-server.yaml, Shiro user alice@example.com):
%sh fails to create the interpreter pod with 422 metadata.labels: Invalid value: "alice@example.com".user=aliceexample.com and the paragraph runs.Merged into master
tbonelee
HwangRock
What this fixes
When a user's name has special characters (like a space), the interpreter pod fails to launch because the value breaks the Kubernetes label rules.
This shows up with external auth like Shiro + OIDC/JWT, where the principal is a display name / username / email — so it can easily contain spaces or other special chars.
JIRA: https://issues.apache.org/jira/browse/ZEPPELIN-5901
Why it happened
The pod name already gets normalized through
K8sUtils.generateK8sName, but theuserlabel didn't go through anything — the principal was put into the label almost as-is (only.trim()). So Kubernetes rejected the pod.The root cause was basically an asymmetry: the pod name was sanitized, the user label wasn't.
How I fixed it
I added a label-specific sanitizer
K8sUtils.generateK8sLabelValue, following the same removal rule as the existing pod-name normalization, but capping the length at 63 (the K8s label limit). The user label now goes through it before being set, and if nothing usable is left (e.g. a blank principal) the label is just omitted instead of writing an empty/"null"value.Reproduction
I reproduced it on a local kind cluster by mimicking the interpreter pod's label block.
As-is — user label
"Firstname Lastname"(contains a space):To-be — same pod with the normalized value
"firstnamelastname":Tests
userlabel is normalized, and that the label line is omitted when the principal is blank.k8s-standardmodule tests pass (32 tests, 0 failures).