Skip to content

WINC-1988: TLS profile adherence - #4340

Draft
mansikulkarni96 wants to merge 2 commits into
openshift:masterfrom
mansikulkarni96:tls_profile
Draft

WINC-1988: TLS profile adherence#4340
mansikulkarni96 wants to merge 2 commits into
openshift:masterfrom
mansikulkarni96:tls_profile

Conversation

@mansikulkarni96

@mansikulkarni96 mansikulkarni96 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Add TLS strict obedience for PQC readiness
Fetch TLS configuration from cluster APIServer and apply to metrics server.
Watch for TLS profile changes and restart pod to reload config.
Uses SecurityProfileWatcher from controller-runtime-common following the pattern from machine-api-operator. Satisfies OpenShift 5.0 TLS.
Strict Obedience requirement for centralized TLS management.

Summary by CodeRabbit

  • New Features

    • Added support for configuring the operator’s metrics server with the cluster’s TLS security profile.
    • Added automatic detection of TLS configuration changes, enabling updated settings after restart.
    • Startup logs now report whether TLS enforcement is active.
  • Bug Fixes

    • Improved handling and reporting of unsupported TLS cipher suites and cluster configuration errors.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Excluded labels (none allowed) (2)
  • do-not-merge/work-in-progress
  • do-not-merge/hold

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c6b0b08f-6efe-44a8-bf73-70bfb3ffc762

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The operator reads the cluster APIServer TLS profile and adherence policy. It applies the resulting TLS configuration to the metrics server and logs unsupported cipher suites. A security profile watcher cancels the operator context when TLS settings change. RBAC permissions and the ClusterServiceVersion allow access to config.openshift.io/apiservers. The cluster configuration interface exposes the TLS settings.

Suggested reviewers: jrvaldes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (2 errors, 1 warning)

Check name Status Explanation Resolution
No-Weak-Crypto ❌ Error The added TLS path accepts RC4 and 3DES mappings, and assigns profile cipher codes to tls.Config; OpenShift's Old profile includes DES-CBC3-SHA. Reject or filter weak cipher suites before assigning tls.Config.CipherSuites, including DES/3DES and RC4; permit only approved AEAD suites.
Container-Privileges ❌ Error Kubernetes manifests set hostNetwork: true in config/manager/manager.yaml and the CSV deployment; hostNetwork is explicitly prohibited by this check. Remove hostNetwork: true from the deployment manifests, or obtain an approved exception and isolate the requirement.
Go Best Practices & Build Tags ⚠️ Warning The Linux build uses GOOS=linux, but cmd/operator/main.go and controller sources lack required !windows tags; new config code also dereferences apiServer without a nil check. Add //go:build !windows to Linux-only operator/controller files and guard apiServer before accessing Spec.
✅ Passed checks (17 passed)
Check name Status Explanation
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.
Security: Secrets, Ssh & Csr ✅ Passed The PR only adds APIServer TLS reads, metrics TLS configuration, and a watcher; its diffs add no secret, SSH/SFTP, CSR, PGP, or credential handling/logging.
Kubernetes Controller Patterns ✅ Passed The added watcher returns errors for API/profile failures, compares and persists state idempotently, filters all event types to APIServer cluster, and has no status, finalizer, or owner-reference l...
Windows Service Management ✅ Passed PASS: The PR changes only TLS configuration, RBAC, and operator startup code; it does not modify Windows service priorities, dependencies, descriptions, cleanup, reboot handling, or SCM interactions.
Platform-Specific Requirements ✅ Passed PR is platform-agnostic. Existing docs cover vSphere limits and AWS EC2LaunchV2; Azure service and GCP hostname paths remain implemented and tested.
Stable And Deterministic Test Names ✅ Passed The pull request changes no test files and introduces no Ginkgo or other test-title changes against origin/master.
Test Structure And Quality ✅ Passed The PR adds no test files or Ginkgo tests; repository tests use standard Go testing, so the stated Ginkgo quality checks are not applicable.
Microshift Test Compatibility ✅ Passed The pull request changes no test files and adds no Ginkgo e2e declarations, so the MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds no Ginkgo e2e tests and changes no *_test.go or test/e2e files, so no SNO multi-node compatibility issue applies.
Topology-Aware Scheduling Compatibility ✅ Passed The PR adds TLS loading, a watcher, and APIServer RBAC only. Its diff adds no replicas, affinity, spread, toleration, node selector, or PDB scheduling constraints.
Ote Binary Stdout Contract ✅ Passed OTE main has no stdout writes; it only initializes component-base logs, whose klog default is logtostderr=true. New operator logs use zap, and added crypto warnings target os.Stderr.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The implementation commit changes only manifests, operator code, RBAC, and cluster config; it adds no Ginkgo declarations or e2e test files.
No-Sensitive-Data-In-Logs ✅ Passed New logs contain only TLS versions, cipher names/counts, and enum adherence policies; no passwords, tokens, API keys, PII, session IDs, hostnames, or customer data are logged.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: applying TLS profile adherence to the operator.
✨ 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.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2026
@mansikulkarni96 mansikulkarni96 changed the title TLS profile adherence WINC-1988: TLS profile adherence Jul 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 17, 2026

Copy link
Copy Markdown

@mansikulkarni96: This pull request references WINC-1988 which is a valid jira issue.

Details

In response to this:

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 17, 2026
@mansikulkarni96

Copy link
Copy Markdown
Member Author

@code-rabbit review

@mansikulkarni96

Copy link
Copy Markdown
Member Author

@code-rabbit full review

@mansikulkarni96

Copy link
Copy Markdown
Member Author

/test aws-e2e-operator

@mansikulkarni96
mansikulkarni96 requested a review from jrvaldes July 17, 2026 16:38
@jrvaldes

Copy link
Copy Markdown
Contributor

/test lint

@openshift-ci

openshift-ci Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@mansikulkarni96: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/aws-e2e-operator 527f1be link true /test aws-e2e-operator
ci/prow/lint 527f1be link true /test lint

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@jrvaldes jrvaldes 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.

@mansikulkarni96 thanks for working on this, mostly LGTM.

PTAL at the comments.

Comment thread cmd/operator/main.go Outdated
Comment thread cmd/operator/main.go Outdated
Comment thread cmd/operator/main.go Outdated
Comment thread cmd/operator/main.go Outdated
Comment thread cmd/operator/main.go Outdated

// Convert TLS profile to config function
tlsConfigFn, unsupportedCiphers := tlspkg.NewTLSConfigFromProfile(tlsProfile)
if len(unsupportedCiphers) > 0 {

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.

should this log a WARN instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is no log level for WARN with logr, do you expect this to be less visible than info?

Comment thread cmd/operator/main.go Outdated
}

setupLog.Info("TLS configuration loaded",
"minVersion", tlsProfile.MinTLSVersion,

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.

windows-exporter may need min_version and cipher_suites on it TLS configuration
as it serve metrics over HTTPS

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.

not a blocker, consider a separate PR/jira for this.

Comment thread cmd/operator/main.go
// cache type.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{

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.

the proposal only sets MinVersion and CipherSuites. It does not set NextProtos. Without this, the metrics server falls back to Go's default
ALPN behavior (which is implementation-defined per Go version).

The doc reference explicitly states:
▎ Set NextProtos / ALPN yourself — the cluster profile does not set it.

https://docs.google.com/document/d/1NoHP2nZdg-xUkcB2y2BtI8469-iicdSG7xJwRad4kF0/edit?tab=t.d6wz8lyxdzg1#heading=h.y3v2qj7yid7t

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

controller-runtime's metrics server already sets NextProtos: []string{"h2"} in server.go:279 before calling our TLSOpts function. Since NewTLSConfigFromProfile only sets MinVersion and CipherSuites, the
existing NextProtos is preserved. No additional setting needed on our side.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jrvaldes can I resolve this comment?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There was a major issue identified with http2 (rapid reset CVE) a few years ago. The mitigation most teams pursued was to disable http2 entirely.

See openshift/controller-runtime-common#21 (just merged)

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 I resolve this comment?

@mansikulkarni96 do not resolve/close comments in PRs where you are the author, just reply with your feedback, and leave the resolution of the comment to the owner of the comment.

cc @openshift/openshift-team-windows-containers

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jrvaldes rest of the comments resolved were addressed and pending resolution by you. Do you want me to unresolve all of them for you to take a look?

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.

no need to, reviewing. Thanks @mansikulkarni96

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated

Comment thread cmd/operator/main.go Outdated
Comment thread cmd/operator/main.go
SecureServing: true,
FilterProvider: filters.WithAuthenticationAndAuthorization,
TLSOpts: []func(*tls.Config){tlsConfigFn}, // Apply cluster TLS profile
},

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.

curve preferences PR merged, consider setting CurvePreferences to include X25519MLKEM768 for post-quantum key exchange

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

only the enhancement merged, implementation is pending https://github.com/openshift/controller-runtime-common/pull/22/changes

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.

Add TLS strict obedience for PQC readiness

consider re-wording the PR description, the one thing that actually matters for post-quantum readiness is the hybrid KEM group X25519MLKEM768 and isn't applied in this change.

the MinVersion and CipherSuites don't get PQC on their own.

I'd rather see the description say plainly "lays the groundwork, curve preferences to follow once controller-runtime-common#22 lands" and get a Jira follow-up filed and linked now while the context's fresh

Comment thread cmd/operator/main.go
@jrvaldes

jrvaldes commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@cmd/operator/main.go`:
- Line 148: Update the TLS setup around NewTLSConfigFromProfile so the returned
tls.Config applies the profile’s CurvePreferences, including X25519MLKEM768 when
supported by the repository’s Go version. Handle FIPS mode by excluding
unsupported or disallowed groups while preserving the profile’s MinVersion and
CipherSuites and existing unsupported-cipher behavior.

In `@pkg/cluster/config.go`:
- Around line 138-154: Add adjacent table-driven tests covering the config
initialization path around APIServer retrieval and TLS setup: assert successful
storage of the resolved TLS profile and TLS adherence policy, require an error
when APIServers().Get fails, and require an error for an invalid custom profile
from tlspkg.GetTLSProfileSpec. Use testify/assert and require consistently, and
keep the tests focused on the APIServer TLS contract.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 8196c4ee-2f0b-4d00-a9cb-6bedc8de9483

📥 Commits

Reviewing files that changed from the base of the PR and between e472c7e and 41253d6.

⛔ Files ignored due to path filters (12)
  • go.sum is excluded by !**/*.sum, !go.sum
  • vendor/github.com/openshift/controller-runtime-common/LICENSE is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/controller-runtime-common/pkg/tls/controller.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/controller-runtime-common/pkg/tls/tls.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/OWNERS is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/cert_config.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/crypto.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/keygen.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/options.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/rotation.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/library-go/pkg/crypto/tls_adherence.go is excluded by !vendor/**, !**/vendor/**
  • vendor/modules.txt is excluded by !vendor/**, !**/vendor/**
📒 Files selected for processing (5)
  • bundle/manifests/windows-machine-config-operator.clusterserviceversion.yaml
  • cmd/operator/main.go
  • config/rbac/role.yaml
  • go.mod
  • pkg/cluster/config.go

Comment thread cmd/operator/main.go Outdated
"adherencePolicy", tlsAdherence)

// Convert TLS profile to config function
tlsConfigFn, unsupportedCiphers := tlspkg.NewTLSConfigFromProfile(tlsProfile)

@coderabbitai coderabbitai Bot Aug 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major

Apply TLS profile groups before claiming strict profile adherence.

NewTLSConfigFromProfile sets MinVersion and CipherSuites, but it does not set CurvePreferences. The current OpenShift TLS profile includes allowed groups, including the PQC hybrid group X25519MLKEM768. The metrics server can therefore retain Go default groups instead of the cluster profile. Update the helper dependency or configure supported curve preferences, with FIPS handling. (github.com)

For the Go version declared by this repository, verify which crypto/tls CurveID values support X25519MLKEM768 and how FIPS mode affects its availability.
🤖 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/operator/main.go` at line 148, Update the TLS setup around
NewTLSConfigFromProfile so the returned tls.Config applies the profile’s
CurvePreferences, including X25519MLKEM768 when supported by the repository’s Go
version. Handle FIPS mode by excluding unsupported or disallowed groups while
preserving the profile’s MinVersion and CipherSuites and existing
unsupported-cipher behavior.

Source: MCP tools

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.

this is related to #4340 (comment) PTAL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="openshift/windows-machine-config-operator"
pr="4340"

echo "== Relevant PR review comments =="
gh api --paginate "repos/${repo}/pulls/${pr}/comments?per_page=100" \
  --jq '.[] | select(.id == 3708467856 or .id == 3609640829) | {id, user: .user.login, path, line, body, html_url}'

echo
echo "== Go version and pinned controller-runtime-common dependency =="
rg -n -C 2 '(^go |controller-runtime-common)' go.mod

echo
echo "== TLS helper source availability and relevant API references =="
fd -a 'tls\.go$' . | while IFS= read -r f; do
  if rg -q 'NewTLSConfigFromProfile|SecurityProfileWatcher' "$f"; then
    echo "--- $f"
    rg -n -C 4 'NewTLSConfigFromProfile|SecurityProfileWatcher|CurvePreferences' "$f"
  fi
done

echo
echo "== TLS profile use in current PR =="
rg -n -C 4 'NewTLSConfigFromProfile|TLSProfileSpec|TLSAdherencePolicy|CurvePreferences' \
  cmd/operator/main.go pkg/cluster/config.go 2>/dev/null || true

Length of output: 10974


🏁 Script executed:

#!/bin/bash
set -euo pipefail

helper_url="https://raw.githubusercontent.com/openshift/controller-runtime-common/64ee174f5e2ebc630fbb554dd114d7a7a878693f/pkg/tls/tls.go"
helper_file="$(mktemp)"

curl --fail --silent --show-error --location "$helper_url" -o "$helper_file"

echo "== Pinned controller-runtime-common TLS helper =="
rg -n -C 8 'NewTLSConfigFromProfile|ShouldHonorClusterTLSProfile|CurvePreferences|TLSAdherence|FIPS' "$helper_file"

echo
echo "== TLS types and adherence-policy helpers in declared OpenShift API module cache =="
module_dir="$(go env GOPATH 2>/dev/null)/pkg/mod/github.com/openshift/api@v0.0.0-20260729135743-72624b98ff3d"
if [ -d "$module_dir" ]; then
  rg -n -C 5 'type TLSProfileSpec|type TLSProfile|TLSAdherencePolicy|ShouldHonorClusterTLSProfile|CurvePreferences' \
    "$module_dir/config" "$module_dir/config/v1" 2>/dev/null || true
else
  echo "OpenShift API module source is unavailable in the sandbox."
fi

Length of output: 4428


@jrvaldes, reviewed. The two comments are related, but they are not duplicates.

The linked discussion identifies the required TLSAdherencePolicy gate. cmd/operator/main.go currently applies tlsConfigFn unconditionally.

This finding identifies incomplete profile application after enforcement is enabled. The pinned NewTLSConfigFromProfile explicitly does not set tls.Config.CurvePreferences:

// TODO: add curve preferences from profile once https://github.com/openshift/api/pull/2583 merges.
// tlsConf.CurvePreferences <<<<<< profile.Curves

Therefore, the implementation needs both controls:

  1. Apply the TLS profile only when ShouldHonorClusterTLSProfile(tlsAdherence) requires it.
  2. When it applies the profile, configure supported curve preferences, including the permitted PQC group where available and allowed by FIPS.

I will keep this finding open because the gate does not address the missing TLS group configuration.


🧬 Code Graph Analysis Results

pkg/cluster/config.go:51-62, 97-103, 106-156, 185-194, 360-362
Defines the cluster.Config interface and its TLS, network, validation, and proxy-related methods. NewConfig retrieves cluster network, platform, and APIServer TLS configuration, returning wrapped errors. Validate validates Kubernetes version and network configuration.

pkg/nodeconfig/payload/payload.go:310-320, 366-380
PopulateSHAMap reads and parses /payload/sha256sum; PopulateNetworkConfScript generates the network configuration script, records its SHA256 checksum, creates the target archive, and returns wrapped file-creation errors.

pkg/nodeconfig/payload/payload.go:21-84
Defines the payload file-path constants used by checkIfRequiredFilesExist in cmd/operator/main.go.

pkg/logconfig/logconfig.go:64-72, 78-103
ValidateLogConfig validates log rotation environment variables and returns aggregated errors; LogConfig logs configured values when present.

pkg/certificatesigningrequests_controller.go:58-74, 134-152
Creates the CSR reconciler using manager dependencies and cluster service CIDR, then configures its controller watch predicates for pending CSRs.

You are interacting with an AI system.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will be addressed in a follow-up when controller-runtime-common#22 merges

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment thread pkg/cluster/config.go
Comment on lines +138 to +154
// Fetch TLS configuration from APIServer
apiServer, err := oclient.ConfigV1().APIServers().Get(ctx, "cluster", meta.GetOptions{})
if err != nil {
return nil, fmt.Errorf("error getting APIServer configuration: %w", err)
}
tlsProfileSpec, err := tlspkg.GetTLSProfileSpec(apiServer.Spec.TLSSecurityProfile)
if err != nil {
return nil, fmt.Errorf("error getting TLS profile from APIServer: %w", err)
}

return &config{
oclient: oclient,
operatorClient: operatorClient,
network: network,
platform: platformStatus.Type,
oclient: oclient,
operatorClient: operatorClient,
network: network,
platform: platformStatus.Type,
tlsProfileSpec: tlsProfileSpec,
tlsAdherencePolicy: apiServer.Spec.TLSAdherence,

@coderabbitai coderabbitai Bot Aug 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Add table-driven tests for the APIServer TLS contract.

Test successful profile and policy storage. Test APIServer retrieval failure. Test invalid custom profile handling. This startup path now controls manager TLS behavior.

As per path instructions, “Add or update adjacent table-driven tests using testify/assert and require.”

🤖 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 `@pkg/cluster/config.go` around lines 138 - 154, Add adjacent table-driven
tests covering the config initialization path around APIServer retrieval and TLS
setup: assert successful storage of the resolved TLS profile and TLS adherence
policy, require an error when APIServers().Get fails, and require an error for
an invalid custom profile from tlspkg.GetTLSProfileSpec. Use testify/assert and
require consistently, and keep the tests focused on the APIServer TLS contract.

Source: Path instructions

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.

+1,

PTAL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '=== Relevant Go files ==='
fd -t f -e go . pkg/cluster | sort

printf '%s\n' '=== Production file outline ==='
ast-grep outline pkg/cluster/config.go --items all --type function,interface,struct --match 'NewConfig|Config|config' || true

printf '%s\n' '=== Relevant test symbols and assertions ==='
rg -n -C 4 -g '*_test.go' \
  'NewConfig\s*\(|APIServers\(\)\.Get\s*\(|TLSProfileSpec\s*\(|TLSAdherencePolicy\s*\(|GetTLSProfileSpec\s*\(' \
  pkg/cluster || true

printf '%s\n' '=== Current PR diff for cluster config and tests ==='
git diff --no-ext-diff --unified=60 'origin/main...HEAD' -- pkg/cluster/config.go pkg/cluster/*_test.go 2>/dev/null || \
git diff --no-ext-diff --unified=60 -- pkg/cluster/config.go pkg/cluster/*_test.go

Length of output: 1814


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '=== Test file outline ==='
ast-grep outline pkg/cluster/config_test.go --items all --type function --view expanded

printf '%s\n' '=== Test file content ==='
cat -n pkg/cluster/config_test.go

printf '%s\n' '=== Repository state ==='
git status --short
printf '%s\n' '=== HEAD metadata ==='
git show -s --format='%H%n%s%n%D' HEAD
printf '%s\n' '=== Changed paths relative to HEAD parent ==='
git diff-tree --no-commit-id --name-status -r HEAD

Length of output: 12324


@jrvaldes, I reviewed the current test coverage.

The finding remains valid. pkg/cluster/config_test.go has no tests for the NewConfig APIServer TLS path.

Please add table-driven tests that cover:

  • successful storage of TLSProfileSpec() and TLSAdherencePolicy();
  • an error from APIServers().Get;
  • an invalid custom TLS profile returned to tlspkg.GetTLSProfileSpec.

This path configures the metrics server TLS behavior at operator startup.

You are interacting with an AI system.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated added tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated, added tests

@jrvaldes jrvaldes 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

@mansikulkarni96 thanks for working on this. LGTM so far.

Did you considered added a e2e test to check that the metrics server actually negotiates with the expected MinVersion/CipherSuites, or that the pod actually restarts when the APIServer CR changes?

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2026
@jrvaldes

jrvaldes commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@rphillips is this something you can help reviewing from the Staff Eng standpoint?

cc @dominikholler

@jrvaldes

jrvaldes commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

/remove-approve

for Staff Eng sign-off

Comment thread cmd/operator/main.go Outdated
@jrvaldes

jrvaldes commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

/remove-approve

@jrvaldes

jrvaldes commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

/approve cancel

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2026
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

Comment thread cmd/operator/main.go

// Get TLS configuration from cluster config (fetched from APIServer during NewConfig)
tlsProfile := clusterConfig.TLSProfileSpec()
tlsAdherence := clusterConfig.TLSAdherencePolicy()

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.

@mansikulkarni96 are you planning squash this commit?

@jrvaldes

jrvaldes commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@mansikulkarni96 please post a comment with /remove-approve to remove the approval, so that @joelanford can stamp it after reviewing.

@mansikulkarni96

Copy link
Copy Markdown
Member Author

/remove-approve

@openshift-ci openshift-ci Bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
Enforce the cluster-wide TLS security profile on the WMCO metrics server,
gated on the TLS adherence policy. WMCO was not previously honoring the
cluster TLS profile, so enforcement only applies when the adherence policy
is StrictAllComponents, per the centralized TLS config enhancement.

Changes:
- Fetch TLS profile and adherence policy from apiserver.config.openshift.io/cluster
- Gate enforcement using library-go's ShouldHonorClusterTLSProfile
- Disable HTTP/2 (HTTP/1.1 only) as defense-in-depth against CVE-2023-44487
- Watch for TLS profile and adherence policy changes, restart on change
- Add controller-runtime-common to hack/update_submodules.sh

CurvePreferences with X25519MLKEM768 for post-quantum key exchange will be
added in a follow-up once openshift/controller-runtime-common#22 lands.
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jrvaldes. 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

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants