← Back to Pull requests

fix(helm): support per-server credentials for Spark History Servers #227

Merged
nothariharan merged 7 files (506 lines) on Oct 14, 2026 16:55 UTC
View on GitHub
nothariharan nothariharan commented on Oct 13, 2026 03:15 UTC
Author

Description

Fixes #94.

The chart could only express one credential set (auth.secret), so a deployment with several Spark History Servers could not authenticate to more than one of them. On top of that, the injected env vars (SPARK_USERNAME, SPARK_PASSWORD, SPARK_TOKEN, MCP_PORT, MCP_DEBUG) no longer match the names the server reads since the SHS_ config refactor, so credentials configured through auth.secret never reached the server at all.

This adds per-server credentials and wires every credential through the env vars the current server actually reads (SHS_SERVERS__<SERVER>__AUTH__):

auth:
  enabled: true
  secret:            # shared, applies to every server without its own entry
    create: true
    username: "shared-user"
    password: "shared-pass"
  servers:
    staging:         # the chart creates this Secret
      secret:
        create: true
        username: "staging-user"
        password: "staging-pass"
    production:      # an existing Secret (keys: username, password, token)
      secret:
        name: "prod-spark-auth"

Servers without an auth.servers entry keep using the shared secret (including externalsecret and csisecretstore, which are unchanged). Existing shared-secret values start working for the first time, and auth.secret.name with create: false is now wired too (previously it injected nothing).

Rendering fails with a clear message when:

  • an auth.servers key does not match any config.servers entry

  • per-server credentials are set without create: true or name

  • a server name is not lowercase while auth is enabled (the server lowercases env-derived keys, so a mixed-case name would otherwise create a second, url-less server entry and crash at startup)
  • Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Testing

  • All existing tests pass (task test)

  • Tested with MCP Inspector

  • Tested with sample Spark data

  • Tested with real Spark History Server (if applicable)
  • Test Commands Run

    helm lint ./deploy/kubernetes/helm/mcp-apache-spark-history-server/
    helm unittest ./deploy/kubernetes/helm/mcp-apache-spark-history-server/
    

  • helm lint: 0 chart(s) failed

  • helm unittest: 5 suites, 28 tests passed (8 new covered in tests/auth_test.yaml, including the three validation errors)

  • Python suite unchanged: 168 passed
  • Rendered proof, three servers with a shared secret plus one created and one existing per-server secret:

    Before (current main):

    # helm template | grep -E "SPARK_|MCP_"
    - name: MCP_PORT
    - name: MCP_DEBUG
    - name: SPARK_USERNAME
    - name: SPARK_PASSWORD
    - name: SPARK_TOKEN
    

    One Secret rendered, and none of those env names are read by the server.

    After:

    SHS_SERVERS__DEFAULT__AUTH__USERNAME    -> spark-auth (shared)
    SHS_SERVERS__PRODUCTION__AUTH__USERNAME -> prod-spark-auth (existing secret)
    SHS_SERVERS__STAGING__AUTH__USERNAME    -> staging-spark-auth (created)
    

    Secrets rendered: staging-spark-auth (created), spark-auth (shared).

    Checklist

  • Code follows project style guidelines

  • Added tests for new functionality

  • Updated documentation (chart README and values comments)

  • Pre-commit hygiene hooks pass for the changed files (trailing whitespace, end of file, JSON, line endings; the repo excludes Helm YAML from check-yaml)

  • Added entry to CHANGELOG.md (the file is empty, so it was skipped)
  • Related Issues

    Fixes #94

    Diff: 506 lines (+492 / -14) across 7 files Reviewer: nabuskey Review duration: 2260m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.72) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 506 lines diff across 7 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.85 · 2 substantive comment(s)
    0.85
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    87%
    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.373
    Sensitive Paths sensitive_paths
    0.072
    Real PR Conversation Timeline
    5 items
    nabuskey nabuskey commented on Oct 13, 2026 18:42 UTC
    Reviewer

    Thank you very much for the PR!

    As it is, it adds the same secret value even when there's an in-line value like so:

    config:
      servers:
        default:
          default: true
          url: "http://spark-history-server:18080"
          auth:                  
            username: "u"
            password: "p"
    

    So we want to skip the shared secret for a server that has inline auth.

    nothariharan nothariharan commented on Oct 14, 2026 02:26 UTC
    Author

    @nabuskey thanks for the review. yeah you're right, the shared secret was being applied to every server without an auth.servers entry so it was silently overriding the inline creds, env vars win over the config file. fixed now, shared secret is skipped for any server that has inline auth under config.servers.<name>.auth. added a test with one inline server and one shared secret server too, helm lint and all 29 chart tests pass

    nabuskey nabuskey approved these changes on Oct 14, 2026 16:51 UTC
    Approved Reviewer

    /approve

    Thank you very much!

    google-oss-prow[bot] google-oss-prow[bot] commented on Oct 14, 2026 16:52 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubeflow/mcp-apache-spark-history-server/pull/227#pullrequestreview-5521498007" title="Approved">nabuskey</a>

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [nabuskey]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    nothariharan nothariharan
    Labels
    risk: low confidence: 87.5% 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: 72.2% (HIGH) · Higher = larger blast radius
    72.2%
    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: 87.5% · Lower = rushed or shallow review
    87.5%
    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% · Safe to merge
    9%