← Back to Pull requests

[ZEPPELIN-5901] Sanitize interpreter pod user label to satisfy Kubernetes label rules #5529

Merged
HwangRock merged 6 files (118 lines) on Oct 05, 2026 05:05 UTC
View on GitHub
HwangRock HwangRock commented on Oct 04, 2026 09:20 UTC
Author

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 the user label 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):

The Pod "jdbc-repro-5901" is invalid: metadata.labels: Invalid value: "Firstname Lastname": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

To-be — same pod with the normalized value "firstnamelastname":

pod/jdbc-repro-5901-fixed created

Tests

  • Unit tests for the sanitizer (space / special chars / over-63-char cut / blank input).

  • Rendered-spec tests that check the user label is normalized, and that the label line is omitted when the principal is blank.

  • All k8s-standard module tests pass (32 tests, 0 failures).
  • Diff: 118 lines (+115 / -3) across 6 files Reviewer: tbonelee Review duration: 1184m
    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
    0.62
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 1 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    85%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    tbonelee tbonelee approved these changes on Oct 04, 2026 16:41 UTC
    Approved Reviewer

    Verified on a real Kubernetes deployment (k3s, official images + k8s/zeppelin-server.yaml, Shiro user alice@example.com):

  • Before (74b51b2): running %sh fails to create the interpreter pod with 422 metadata.labels: Invalid value: "alice@example.com".

  • After (517ad0f): the pod is created with label user=aliceexample.com and the paragraph runs.
  • tbonelee tbonelee commented on Oct 05, 2026 05:05 UTC
    Contributor

    Merged into master

    Reviewers
    Assignees
    HwangRock HwangRock
    Labels
    risk: low confidence: 85.4% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 62.1% (MEDIUM) · Higher = larger blast radius
    62.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 85.4% · Lower = rushed or shallow review
    85.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.1% · Safe to merge
    9.1%