← Back to Pull requests

feat: add SecurityProfileWatcher for TLS profile change detection #156

Closed
unknown closed this pull request without merging on Aug 11, 2026 16:00 UTC
View on GitHub
unknown unknown commented on Jul 29, 2026 21:41 UTC
Author

Purpose of this PR

Add a SecurityProfileWatcher to both controller and webhook that detects changes to the OpenShift APIServer TLS security profile and triggers a graceful restart. This brings spark-operator in line with the TLS adherence requirements (RHOAIENG-79437, RHOAIENG-79005).

Proposed changes:

  • Extract shared TLS profile fetch logic from webhook into pkg/tls/profile.go (was duplicated inline)

  • Add pkg/tls/watcher.go with an unstructured controller that watches the APIServer cluster object and fires a cancel callback on profile changes

  • Wire both controller and webhook to use the shared TLS profile fetch + watcher with the cancel-context restart pattern

  • Move config.openshift.io/apiservers RBAC to ODH/RHOAI overlay (not needed in upstream base), add list/watch verbs for the informer

  • Add ALPN NextProtos (h2, http/1.1) to controller (matches upstream kubeflow/spark-operator#2990)

  • Remove downstream-only --enable-http2 flag from webhook (already removed upstream in kubeflow/spark-operator#2990)

  • Remove dead Provider.TLSConfig() method from pkg/certificate/certificate.go (upstream PR: kubeflow/spark-operator#3062)

  • Move TLS profile tests to pkg/tls/ and add comprehensive watcher unit tests (35 tests)
  • 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

    OCP 5 TLS compliance requires operators to respect the cluster-wide TLS security profile and restart when it changes. The webhook already fetched the profile at startup but neither component watched for changes. The controller didn't fetch the profile at all (used CLI flags only).

    The --enable-http2 flag was a downstream-only addition that was never in upstream. It was already removed upstream in #2990 as dead code after CVE-2023-44487 was fixed in Go 1.21.3+.

    The Provider.TLSConfig() method was introduced upstream in #2072 but never called. It creates a bare tls.Config without honoring the cluster TLS profile, which gets flagged by tls-lint.

    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

    Ref: RHOAIENG-79437, RHOAIENG-79005

    Upstream PRs:

  • kubeflow/spark-operator#2990 (removed --enable-http2, merged)

  • kubeflow/spark-operator#3062 (remove dead TLSConfig(), open)
  • [RHOAIENG-79437]: https://redhat.atlassian.net/browse/RHOAIENG-79437?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    [RHOAIENG-79005]: https://redhat.atlassian.net/browse/RHOAIENG-79005?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    [RHOAIENG-79437]: https://redhat.atlassian.net/browse/RHOAIENG-79437?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added automatic integration with OpenShift TLS security profiles.
    TLS settings now support profile-based versions and cipher suites, with HTTP/2 and HTTP/1.1 enabled.
    Added automatic detection of TLS profile changes, triggering service reconfiguration.
    Added required permissions for monitoring TLS profile updates.

    Bug Fixes
    * Improved handling of missing, malformed, and temporarily unavailable TLS profiles with safer fallbacks.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 533 lines (+399 / -134) across 6 files Reviewer: RobuRishabh Review duration: 18379m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 533 lines diff across 6 files
    0.71
    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%
    60%
    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.376
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    1 comments
    "Review active on #156"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.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: 71.1% (HIGH) · Higher = larger blast radius
    71.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: 60.5% · Lower = rushed or shallow review
    60.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: 28.1% · Safe to merge
    28.1%