Skip to content

ACM-30174: inherit central TLS profile from APIServer for PQC readiness - #358

Merged
openshift-merge-bot[bot] merged 1 commit into
stolostron:mainfrom
yiraeChristineKim:ACM-30174
Jun 11, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
stolostron:mainfrom
yiraeChristineKim:ACM-30174

Conversation

@yiraeChristineKim

@yiraeChristineKim yiraeChristineKim commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fetches the cluster's TLS security profile from apiservers.config.openshift.io/cluster at startup and applies it to all TLS servers (webhook port 9443, metrics port 8443) and outbound HTTP clients (Thanos, ACM Search API)
  • Falls back to the Intermediate profile (TLS 1.2+) gracefully when the APIServer resource is not available (e.g. kind clusters used in e2e tests)
  • Registers a SecurityProfileWatcher that triggers a graceful manager restart when the cluster TLS profile changes at runtime
  • Removes hardcoded MinVersion: tls.VersionTLS13 from buildHTTPClient; TLS settings now come from the cluster's central configuration source
  • Adds get/list/watch on config.openshift.io/apiservers to both Helm and Kustomize ClusterRole files

Changes

File Change
go.mod Add github.com/openshift/api, github.com/openshift/controller-runtime-common, github.com/openshift/library-go
cmd/main.go getInitialTLSProfile(), setupTLSProfileWatcher(), cancellable context, apply profile to tlsOpts
controllers/migrationadvisor/httpclient.go Replace hardcoded MinVersion: tls.VersionTLS13 with variadic tlsOpts ...func(*tls.Config)
controllers/migrationadvisor/{handler,search_client,observability_client}.go Add TLSOpts func(*tls.Config) field, thread through to buildHTTPClient
charts/templates/mtv-integrations-clusterrole.yaml Add config.openshift.io/apiservers get/list/watch
config/rbac/role.yaml Mirror the same RBAC rule

Test plan

  • go build ./... — clean
  • golangci-lint run ./... — 0 issues
  • go test ./controllers/migrationadvisor/... ./webhook/... — all pass
  • Webhook e2e (make run-webhook-test) — not affected; fallback to Intermediate profile on kind (no config.openshift.io API group)
  • Deploy to hub cluster and verify TLS profile is loaded from apiservers.config.openshift.io/cluster on startup log

References

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Application now loads and monitors OpenShift cluster TLS security profiles at startup, automatically restarting gracefully when profiles change
    • Added ability to disable HTTP/2 for TLS connections via configuration flag
    • Updated permissions to access cluster TLS configuration
  • Chores

    • Added OpenShift API and controller runtime dependencies

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@yiraeChristineKim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 31 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ad5c37a5-e777-4945-84a6-f18565d344a4

📥 Commits

Reviewing files that changed from the base of the PR and between fc0d737 and 67b0a30.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • charts/templates/mtv-integrations-clusterrole.yaml
  • cmd/main.go
  • config/rbac/role.yaml
  • controllers/migrationadvisor/handler.go
  • controllers/migrationadvisor/httpclient.go
  • controllers/migrationadvisor/observability_client.go
  • controllers/migrationadvisor/search_client.go
  • go.mod

Walkthrough

This PR integrates OpenShift TLS security profile support into mtv-integrations by loading the hub cluster's APIServer TLS configuration at startup and applying it to outbound HTTP clients. A watcher monitors profile changes and triggers graceful restarts via context cancellation.

Changes

TLS Profile Loading and Application

Layer / File(s) Summary
RBAC permissions and module dependencies
charts/templates/mtv-integrations-clusterrole.yaml, config/rbac/role.yaml, go.mod
Grants mtv-integrations-manager-role permissions to read apiservers from config.openshift.io, and adds github.com/openshift/api and github.com/openshift/controller-runtime-common dependencies.
HTTP client TLS configuration infrastructure
controllers/migrationadvisor/httpclient.go, controllers/migrationadvisor/observability_client.go, controllers/migrationadvisor/search_client.go
buildHTTPClient now accepts variadic TLS option functions applied after CA pool setup. ObservabilityClient and SearchClient each expose a TLSOpts field for injected TLS customization.
Handler TLS injection wiring
controllers/migrationadvisor/handler.go
Handler gains a TLSOpts field and wires it into both ObservabilityClient and SearchClient during cluster data refresh.
TLS profile loading and watcher registration
cmd/main.go (lines 37–53, 78, 310–363, 439–456)
Loads OpenShift APIServer TLS configuration via getInitialTLSProfile with fallback defaults. setupTLSProfileWatcher monitors profile changes and cancels a derived context to trigger graceful restarts.
Main startup integration and context wiring
cmd/main.go (lines 251–277, 567–584, 613)
setupAdvisorServer accepts TLS options and passes them to the handler. Startup fetches the initial profile, derives a cancellable context, registers the watcher, and switches manager startup to use that context for watcher-driven restarts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Assertion messages missing in 72-100% of assertions across all test files, violating requirement #4. Httpclient_test lacks proper cleanup for temporary servers. Add assertion messages to all require/assert calls. Ensure all httptest servers are deferred/closed. Split tests with 3+ unrelated assertions into separate test functions for single responsibility.
✅ Passed checks (9 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main change: inheriting the central TLS profile from the APIServer for PQC readiness, which is the core objective reflected throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed This PR does not modify any test files. The existing Ginkgo tests in the repository have stable, deterministic names with no dynamic content (timestamps, UUIDs, pod names, IP addresses).
No-Weak-Crypto ✅ Passed No weak cryptography patterns found: no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB usage, no custom crypto implementations, no unsafe secret comparisons. Uses standard crypto/tls with OpenShift TLS profiles.
Container-Privileges ✅ Passed PR does not modify container manifests; existing deployments have proper security contexts with privileged: false, allowPrivilegeEscalation: false, and all capabilities dropped.
No-Sensitive-Data-In-Logs ✅ Passed PR adds TLS profile logging that exposes only non-sensitive metadata (minTLSVersion, cipher names); no passwords, tokens, keys, PII, or certificate content are logged.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/main.go (1)

310-345: 💤 Low value

Consider logging at error level when fallback produces an error.

In the fallback() closure (lines 314-320), if GetTLSProfileSpec(nil) returns an error, it's logged but an empty/zero-value TLSProfileSpec may be returned. While this is unlikely in practice (the Intermediate profile is well-defined), consider whether the returned spec is valid when err != nil.

The overall fallback design is sound for graceful degradation on non-OpenShift clusters.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/main.go` around lines 310 - 345, The fallback() closure must ensure a
valid, explicit default TLSProfileSpec is returned when
tlspkg.GetTLSProfileSpec(nil) errors: update fallback so that on err it logs the
error (setupLog.Error) and then constructs or obtains a known-safe default TLS
profile (an explicit Intermediate/TLS1.2+ spec) instead of returning a
zero-value spec; ensure getInitialTLSProfile still calls
tlspkg.NewTLSConfigFromProfile(profileSpec) with that valid spec and
logs/handles any returned unsupported ciphers as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/main.go`:
- Around line 310-345: The fallback() closure must ensure a valid, explicit
default TLSProfileSpec is returned when tlspkg.GetTLSProfileSpec(nil) errors:
update fallback so that on err it logs the error (setupLog.Error) and then
constructs or obtains a known-safe default TLS profile (an explicit
Intermediate/TLS1.2+ spec) instead of returning a zero-value spec; ensure
getInitialTLSProfile still calls tlspkg.NewTLSConfigFromProfile(profileSpec)
with that valid spec and logs/handles any returned unsupported ciphers as
before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 441738ec-0c2f-4557-bab1-afa0f3d1e7d9

📥 Commits

Reviewing files that changed from the base of the PR and between 73dd8a3 and fc0d737.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • charts/templates/mtv-integrations-clusterrole.yaml
  • cmd/main.go
  • config/rbac/role.yaml
  • controllers/migrationadvisor/handler.go
  • controllers/migrationadvisor/httpclient.go
  • controllers/migrationadvisor/observability_client.go
  • controllers/migrationadvisor/search_client.go
  • go.mod

Fetches the cluster's TLS security profile from
apiservers.config.openshift.io/cluster at startup and applies it to all
TLS servers (webhook port 9443, metrics port 8443) and outbound HTTP
clients (Thanos, ACM Search API). Falls back to the Intermediate profile
(TLS 1.2+) gracefully when the APIServer resource is not available (e.g.
kind clusters used in e2e tests).

Key changes:
- Add github.com/openshift/controller-runtime-common dependency for the
  SecurityProfileWatcher and TLS profile utilities
- Register apiconfigv1 in the scheme so the manager can watch APIServer
- getInitialTLSProfile(): fetch TLS profile at startup, fall back to
  Intermediate on error
- setupTLSProfileWatcher(): cancel manager context (graceful restart) on
  TLS profile change; non-fatal if APIServer CRD is absent
- Remove hardcoded MinVersion: tls.VersionTLS13 from buildHTTPClient;
  accept variadic tlsOpts to apply the cluster profile to outbound clients
- Add TLSOpts func(*tls.Config) field to Handler, SearchClient, and
  ObservabilityClient so the profile is threaded through to HTTP clients
- Add get/list/watch on config.openshift.io/apiservers to both
  charts/templates/mtv-integrations-clusterrole.yaml and
  config/rbac/role.yaml

Jira: https://redhat.atlassian.net/browse/ACM-30174
Signed-off-by: yiraeChristineKim <yikim@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: yiraeChristineKim <yikim@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@yiraeChristineKim

Copy link
Copy Markdown
Collaborator Author

/cc @kurwang

@openshift-ci
openshift-ci Bot requested a review from kurwang June 11, 2026 15:38

@kurwang kurwang left a comment

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.

/lgtm

@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kurwang, yiraeChristineKim

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:

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

@openshift-merge-bot
openshift-merge-bot Bot merged commit 4048bc5 into stolostron:main Jun 11, 2026
18 checks passed
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