Skip to content

Add support for TLS profiles#1041

Open
ozzywalsh wants to merge 7 commits intorhobs:mainfrom
ozzywalsh:add-tls-profile-support
Open

Add support for TLS profiles#1041
ozzywalsh wants to merge 7 commits intorhobs:mainfrom
ozzywalsh:add-tls-profile-support

Conversation

@ozzywalsh
Copy link
Copy Markdown

@ozzywalsh ozzywalsh commented Mar 25, 2026

Changes

  • Retrieve cluster TLS security profile on operator startup
  • Restart operator when cluster TLS profile changes
  • Inject tls min_version & cipher_suites as args to tracing plugin
  • Unit tests for createDistributedTracingPluginInfo

Reference

Similar PR in opentelemetry-operator open-telemetry/opentelemetry-operator#4669

Dependencies/Questions

The PR below adds the to --tls-min-version & --tls-cipher-suites to the actual console plugin.
https://github.com/openshift/distributed-tracing-console-plugin

It should probably be released first, and the the observability-operator; to avoid a situation where the observability-operator is injecting flags that the plugin doesn't expect; since this would probably throw an error & break things.

Retrieve cluster tls profile on operator startup. Restart the operator
when the cluster tls profile changes.

Pass the tls profile to distributed_tracing console plugin
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 25, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ozzywalsh
Once this PR has been reviewed and has the lgtm label, please assign danielmellado for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f93dff7c-b701-4c85-9d71-73dfc15d6c05

📥 Commits

Reviewing files that changed from the base of the PR and between f4888e8 and b1880c2.

📒 Files selected for processing (2)
  • go.mod
  • pkg/operator/operator.go
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/operator/operator.go

📝 Walkthrough

Walkthrough

The operator now integrates OpenShift TLS profile management with graceful shutdown support. A cancel-derived context is introduced in main.go and passed to the operator, which establishes a TLS profile watcher that triggers cancellation on profile changes. Dependencies are updated, and the scheme conditionally registers OpenShift config/v1 API types.

Changes

Cohort / File(s) Summary
Main Entry Point
cmd/operator/main.go
Wraps controller-runtime signal context with context.WithCancel to produce a derived context and cancel function, passing the cancel function to operator initialization via WithCancelFunc().
Dependency Updates
go.mod
Bumps k8s.io/utils and sigs.k8s.io/controller-runtime to newer versions; adds new direct dependency github.com/openshift/controller-runtime-common and indirect dependency github.com/openshift/library-go.
Operator Core Implementation
pkg/operator/operator.go, pkg/operator/scheme.go
Extends OperatorConfiguration with CancelFunc field and WithCancelFunc() option. Under OpenShift feature gate, adds TLS profile bootstrap and watching via openshifttls.SecurityProfileWatcher, which invokes the cancel function on profile changes. Refactors cache setup into a local variable. Scheme now conditionally installs OpenShift config/v1 API types.

Sequence Diagram(s)

sequenceDiagram
    participant SignalHandler as Signal Handler
    participant Main as main()
    participant Operator as Operator
    participant TLSWatcher as TLS Profile Watcher
    participant Manager as Manager

    SignalHandler->>Main: SetupSignalHandler()
    rect rgba(100, 150, 200, 0.5)
        Main->>Main: context.WithCancel(signalCtx)
        Main->>Main: defer cancel()
    end
    Main->>Operator: New(..., WithCancelFunc(cancel))
    
    rect rgba(100, 150, 200, 0.5)
        Operator->>TLSWatcher: FetchAPIServerTLSProfile()
        Operator->>TLSWatcher: NewSecurityProfileWatcher(OnProfileChange)
        Operator->>Manager: SetupWithManager()
    end
    
    Manager->>Manager: Start()
    
    alt Profile Change Detected
        TLSWatcher->>TLSWatcher: OnProfileChange callback
        TLSWatcher->>Operator: cancel() invoked
        Operator->>Manager: Graceful shutdown
    else Signal Received
        SignalHandler->>Operator: signalCtx cancelled
        Operator->>Manager: Graceful shutdown
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add support for TLS profiles' directly describes the main change: integrating TLS profile support into the operator for retrieving and reacting to TLS profile changes.
Description check ✅ Passed The description is related to the changeset, outlining key changes like retrieving TLS profiles on startup and restarting when profiles change, along with relevant context about dependencies and references.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 25, 2026

Hi @ozzywalsh. Thanks for your PR.

I'm waiting for a rhobs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ozzywalsh ozzywalsh marked this pull request as ready for review March 26, 2026 13:20
@openshift-ci openshift-ci bot requested review from jgbernalp and zhuje March 26, 2026 13:20
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/operator/operator.go`:
- Around line 335-345: The OnProfileChange callback on SecurityProfileWatcher
currently calls cfg.CancelFunc() without checking for nil; update the anonymous
function passed to openshifttls.SecurityProfileWatcher (OnProfileChange) to
first verify cfg.CancelFunc != nil before invoking it, and retain the existing
log message and behavior otherwise; ensure this defensive check is applied where
watcher is configured (before calling watcher.SetupWithManager).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3012d44f-d519-49bb-a4b5-7c654226ed70

📥 Commits

Reviewing files that changed from the base of the PR and between cf377a3 and 9e893a4.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • cmd/operator/main.go
  • go.mod
  • pkg/controllers/uiplugin/controller.go
  • pkg/controllers/uiplugin/distributed_tracing.go
  • pkg/controllers/uiplugin/distributed_tracing_test.go
  • pkg/controllers/uiplugin/plugin_info_builder.go
  • pkg/operator/operator.go
  • pkg/operator/scheme.go

Copy link
Copy Markdown
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as commented over Slack, I'd prefer this PR to focus only on watching the TLS profile. Propagation to UI plugins should be a follow-up.

go.mod Outdated
github.com/rhobs/observability-operator/pkg/apis => ./pkg/apis
)

require (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) can we move this to the top-level require section?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

if cfg.FeatureGates.OpenShift.Enabled {
setupLog := ctrl.Log.WithName("setup")

// Create a temporary client to fetch initial TLS profile before manager starts.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: isn't the manager's client ready to use at this stage?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; i've updated it to use the manager's client.

Separate TLS profile retrieval from passing TLS profile into
the console plugin, so they can be reviewed in independent PRs.
if cfg.FeatureGates.OpenShift.Enabled {
setupLog := ctrl.Log.WithName("setup")

initialTLSProfileSpec, err := openshifttls.FetchAPIServerTLSProfile(ctx, mgr.GetClient())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can any authenticated user read the TLS profile? I'd expect that we need to grant some permission to the operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants