← Back to Pull requests

fix(controller): check the kube config error before using the config #3333

Closed
unknown closed this pull request without merging on Nov 23, 2026 18:34 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 09:52 UTC
Author

Purpose of this PR

controller start panics with a nil pointer dereference when no kube config can be loaded, instead of logging the error and exiting. start() sets cfg.WarningHandler before it checks the error returned by ctrl.GetConfig(), and the config is nil when that call fails.

Proposed changes:

  • Check the error from ctrl.GetConfig() before cfg.WarningHandler is set, as cmd/operator/webhook/start.go already does.
  • Change Category

  • Bugfix (non-breaking change which fixes an issue)

  • Feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that could affect existing functionality)

  • Documentation update
  • Rationale

    Running controller start with no kubeconfig and outside a cluster, before this change:

    panic: runtime error: invalid memory address or nil pointer dereference
    
    goroutine 1 [running]:
    github.com/kubeflow/spark-operator/v2/cmd/operator/controller.start()
    	cmd/operator/controller/start.go:328 +0x123
    

    After this change the process logs the cause and exits with status 1:

    {"level":"ERROR","caller":"controller/start.go:329","msg":"failed to get kube config","error":"invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable"}
    

    Checklist

  • I have conducted a self-review of my own code.

  • I have updated documentation accordingly.

  • I have added tests that prove my changes are effective or that my feature works.

  • Existing unit tests pass locally with my changes.
  • Additional Notes

  • No unit test is added because start() ends in os.Exit. I checked the change by running the binary before and after it; the output is above.

  • go build ./cmd/operator and go vet ./cmd/operator/... pass. I did not run make unit-test or make go-lint locally (Windows), so the last box is left unticked.

  • I searched issues and PRs for WarningHandler, GetConfig and "failed to get kube config", and read the open PRs that touch cmd/operator/controller/start.go (#3290 and my own #3329). None of them changes these lines.

  • AI disclosure: I used an AI assistant (Claude) to help find and write this change. I reviewed and tested it myself.
  • Diff: 280 lines (+210 / -70) across 3 files Reviewer: nabuskey Review duration: 1961m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.63) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 280 lines diff across 3 files
    0.63
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    57%
    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.337
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #3333"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% 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.8% (MEDIUM) · Higher = larger blast radius
    62.8%
    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: 58.0% · Lower = rushed or shallow review
    58.0%
    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: 26.4% · Safe to merge
    26.4%