Skip to content

CNTRLPLANE-1739: e2e additional tests for pki config - #31491

Open
kaleemsiddiqu wants to merge 1 commit into
openshift:mainfrom
kaleemsiddiqu:pki-config-additional-tests
Open

CNTRLPLANE-1739: e2e additional tests for pki config#31491
kaleemsiddiqu wants to merge 1 commit into
openshift:mainfrom
kaleemsiddiqu:pki-config-additional-tests

Conversation

@kaleemsiddiqu

@kaleemsiddiqu kaleemsiddiqu commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

additional test for pki config covering kube controller manager and machine config operator

Summary by CodeRabbit

  • Tests
    • Added coverage for PKI configurations used by the kube-controller-manager and machine-config operators.
    • Added RSA, ECDSA, and mixed signer/serving configuration scenarios.
    • Verified certificate reconciliation, automatic regeneration after secret deletion, CA status, and key parameters.
    • Added cleanup to restore PKI settings after test execution.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

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

openshift-ci-robot commented Aug 6, 2026

Copy link
Copy Markdown

@kaleemsiddiqu: This pull request references CNTRLPLANE-1739 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

additional test for pki config covering kube controller manager and machine config operator

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.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 8ce1b652-5b9d-484a-9fd8-b8572f2fa749

📥 Commits

Reviewing files that changed from the base of the PR and between 48ea73c and 2d1b82a.

📒 Files selected for processing (2)
  • test/extended/pki/helpers.go
  • test/extended/pki/pki_operator_certs.go

Walkthrough

The change adds PKI validation helpers and extended tests for kube-controller-manager and machine-config-operator certificates. Tests cover RSA, ECDSA, mixed profiles, reconciliation, secret regeneration, CA status, and key parameters.

Changes

Operator PKI certificate coverage

Layer / File(s) Summary
PKI helpers and profile construction
test/extended/pki/helpers.go
Adds CA status and RSA/ECDSA key parameter checks. Mixed profiles now include signer defaults and add serving or client settings only when configured.
Operator scenario registration
test/extended/pki/pki_operator_certs.go
Defines certificate scenarios for both operators and registers uniform and mixed configuration tests with cleanup.
Certificate reconciliation and validation
test/extended/pki/pki_operator_certs.go
Applies RSA-4096 and ECDSA-P384 configurations, verifies reconciliation, deletes managed secrets, checks regeneration, and validates mixed-profile parameters.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 2d1b8

This PR adds e2e coverage without changing production behavior, and no concrete correctness, security, availability, or deployment risk is identified; no actionable merge-blocking risk remains after normal verification.

Sequence Diagram(s)

sequenceDiagram
  participant GinkgoTest
  participant PKIConfiguration
  participant Operator
  participant CertificateSecrets
  GinkgoTest->>PKIConfiguration: Apply uniform or mixed profile
  PKIConfiguration->>Operator: Provide certificate settings
  Operator->>CertificateSecrets: Reconcile managed certificates
  GinkgoTest->>CertificateSecrets: Delete managed certificate secret
  Operator->>CertificateSecrets: Regenerate certificate secret
  GinkgoTest->>CertificateSecrets: Validate UID, CA status, and key parameters
Loading

Suggested reviewers: sjenning, deads2k

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Jira issue and summarizes the main change: adding end-to-end tests for PKI configuration.
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 New Ginkgo titles use only hard-coded scenario sigTag/displayName values; no runtime pod, node, namespace, IP, timestamp, UUID, or generated identifier appears in title construction.
Test Structure And Quality ✅ Passed New tests use the repository's BeforeAll/DeferCleanup pattern, bounded regeneration contexts, contextual assertions, and the established operator wait helper; no explicit quality failure is introdu...
Microshift Test Compatibility ✅ Passed Both new Ginkgo It tests include [Skipped:MicroShift] and [apigroup:config.openshift.io], so MicroShift CI protects them from execution.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added Ginkgo tests only update PKI objects, operator status, and certificate secrets; they contain no multi-node, HA, scheduling, topology, scaling, or failover assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The diff only changes PKI test helpers and adds certificate tests; it introduces no manifests, workload specs, replicas, affinity, selectors, tolerations, or PDBs.
Ote Binary Stdout Contract ✅ Passed Changed files add no stdout, fmt.Print, log, or klog writes; e2e.Logf uses GinkgoWriter, and top-level code only registers Ginkgo nodes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The added Ginkgo tests use Kubernetes/OpenShift API clients and cluster resources only; the diff contains no IPv4 literals, IP parsing, URL construction, public hosts, image pulls, or external down...
No-Weak-Crypto ✅ Passed The changed PKI tests use RSA-4096 and ECDSA P-256/P-384 only; no MD5, SHA-1, DES, RC4, 3DES, Blowfish, ECB, custom crypto, or secret comparisons were introduced.
Container-Privileges ✅ Passed The changed PKI Go files add no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation, or container security-context settings; they only configure PKI objects and inspect e...
No-Sensitive-Data-In-Logs ✅ Passed Added logs emit test names, certificate categories, key parameters, and fixed namespace/secret identifiers; the diff does not log certificate bytes, UIDs, credentials, tokens, PII, or hostnames.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested review from deads2k and sjenning August 6, 2026 16:51

@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: 6

🧹 Nitpick comments (4)
test/extended/pki/pki_kube_controller_manager.go (2)

92-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The mixed configuration sets serving and client profiles that no assertion checks.

applyMixedPKIConfig writes ServingCertificates as ECDSA P256 and ClientCertificates as ECDSA P521 (see test/extended/pki/helpers.go lines 152-203). testMixedKCMCertificates only inspects csr-signer and csr-signer-signer, and both expect the signer profile. The test therefore never proves that per-category overrides take effect, which is the purpose of the mixed case.

Add a serving or client certificate Secret from the kube-controller-manager operator to the test table, or state in a comment why only signers are observable here.

🤖 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 `@test/extended/pki/pki_kube_controller_manager.go` around lines 92 - 102,
Update the mixedPKITestConfig entry used by testMixedKCMCertificates to include
an observable serving or client certificate Secret whose expected algorithm and
curve match the configured ECDSA P256 or ECDSA P521 override, so the test
validates category-specific profiles rather than only signer certificates.

178-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Both key-size assertions narrow newCert.KeySize to int32. Static analysis flags each conversion as a possible truncation. Widen the expected value instead of narrowing the observed value; the assertion result does not change.

  • test/extended/pki/pki_kube_controller_manager.go#L178-L178: compare newCert.KeySize against int(tc.rsaSize).
  • test/extended/pki/pki_kube_controller_manager.go#L255-L255: compare newCert.KeySize against int(testCase.expectedRSASize).
🤖 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 `@test/extended/pki/pki_kube_controller_manager.go` at line 178, The key-size
assertions narrow the observed value and may truncate it. In
test/extended/pki/pki_kube_controller_manager.go at lines 178-178 and 255-255,
update both assertions to compare newCert.KeySize against widened expected
values using int(tc.rsaSize) and int(testCase.expectedRSASize), respectively.

Source: Linters/SAST tools

test/extended/pki/pki_machine_config_operator.go (2)

190-190: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Explain or remove the trailing sleeps.

time.Sleep(5 * time.Second) runs after each certificate is verified. The purpose is not clear. If the sleep lets the operator settle before the next Secret deletion, add a short comment that states why. Otherwise remove it.

Also applies to: 271-271

🤖 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 `@test/extended/pki/pki_machine_config_operator.go` at line 190, Remove the
5-second time.Sleep calls following certificate verification in the affected
test flow, unless they are required for operator settling; if retained, add a
concise comment explaining that purpose.

197-276: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared regeneration and validation loop.

testMixedMCOCertificates repeats testMCOCertificates almost line for line. Only the source of the expected algorithm, RSA size, and curve differs. Extract one helper that accepts a certificate plus its expected key properties, then call it from both functions. The kube-controller-manager suite in this stack looks similar, so the helper can likely serve both files.

🤖 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 `@test/extended/pki/pki_machine_config_operator.go` around lines 197 - 276,
Extract the repeated certificate deletion, regeneration, retrieval, CA
validation, and key-property validation logic from testMixedMCOCertificates and
testMCOCertificates into a shared helper that accepts an operatorCertificate and
expected algorithm, RSA size, and ECDSA curve. Replace both functions’
duplicated loops with calls to this helper while preserving their existing
expectations, logging, and verification counts; structure it for reuse by the
kube-controller-manager certificate tests where compatible.
🤖 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 `@test/extended/pki/pki_kube_controller_manager.go`:
- Around line 176-185: The algorithm verification chains in testKCMCertificates
(test/extended/pki/pki_kube_controller_manager.go:176-185) and
testMixedKCMCertificates
(test/extended/pki/pki_kube_controller_manager.go:253-262) must reject
unsupported algorithm values. Add a final failing branch after the RSA and ECDSA
cases in both locations, so unexpected tc.algorithm or
testCase.expectedAlgorithm values cannot increment verifiedCount or report
success without assertions.
- Around line 73-77: In
test/extended/pki/pki_kube_controller_manager.go#L73-L77, update
testUniformKCMPKIConfigurations to remove the fixed sleep and wait for the
kube-controller-manager operator status to reflect the applied PKI generation
before calling WaitForOperatorProgressingFalse. Apply the same change in
test/extended/pki/pki_kube_controller_manager.go#L112-L116 within
testMixedKCMPKIConfigurations.
- Around line 95-100: Run gofmt on the struct literal containing
signerAlgorithm, servingAlgorithm, and clientAlgorithm so all contiguous
key-value fields, including servingECDSACurve and clientECDSACurve, are aligned
consistently.

In `@test/extended/pki/pki_machine_config_operator.go`:
- Around line 68-78: Replace the fixed time.Sleep after applyPKIConfig with a
generation-based wait that confirms the machine-config operator has observed the
newly applied PKI configuration before calling WaitForOperatorProgressingFalse.
Apply the same change to the corresponding flow around lines 112-116, reusing
the existing operator generation/status wait helpers and preserving the
subsequent reconciliation check.
- Around line 92-102: The mixedConfigs client profile is not covered by
validation. Update testMixedMCOCertificates to include the expected client
certificate Secret in its validation table, using clientAlgorithm and
clientECDSACurve, so the configured client profile is verified alongside the
signer and serving profiles.
- Around line 177-186: Add a terminal else branch to the algorithm validation
blocks at test/extended/pki/pki_machine_config_operator.go lines 177-186 and
258-267, failing the test when tc.algorithm or testCase.expectedAlgorithm is
neither RSA nor ECDSA. Ensure unexpected or empty values cannot increment
verifiedCount without performing a key assertion.

---

Nitpick comments:
In `@test/extended/pki/pki_kube_controller_manager.go`:
- Around line 92-102: Update the mixedPKITestConfig entry used by
testMixedKCMCertificates to include an observable serving or client certificate
Secret whose expected algorithm and curve match the configured ECDSA P256 or
ECDSA P521 override, so the test validates category-specific profiles rather
than only signer certificates.
- Line 178: The key-size assertions narrow the observed value and may truncate
it. In test/extended/pki/pki_kube_controller_manager.go at lines 178-178 and
255-255, update both assertions to compare newCert.KeySize against widened
expected values using int(tc.rsaSize) and int(testCase.expectedRSASize),
respectively.

In `@test/extended/pki/pki_machine_config_operator.go`:
- Line 190: Remove the 5-second time.Sleep calls following certificate
verification in the affected test flow, unless they are required for operator
settling; if retained, add a concise comment explaining that purpose.
- Around line 197-276: Extract the repeated certificate deletion, regeneration,
retrieval, CA validation, and key-property validation logic from
testMixedMCOCertificates and testMCOCertificates into a shared helper that
accepts an operatorCertificate and expected algorithm, RSA size, and ECDSA
curve. Replace both functions’ duplicated loops with calls to this helper while
preserving their existing expectations, logging, and verification counts;
structure it for reuse by the kube-controller-manager certificate tests where
compatible.
🪄 Autofix

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: Enterprise

Run ID: e9ea2fdc-8bfa-472e-81d2-bf206dc3b804

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7ae27 and 48ea73c.

📒 Files selected for processing (2)
  • test/extended/pki/pki_kube_controller_manager.go
  • test/extended/pki/pki_machine_config_operator.go

Comment on lines +73 to +77
time.Sleep(10 * time.Second)

e2e.Logf("Waiting for kube-controller-manager operator to reconcile PKI config...")
err = exutil.WaitForOperatorProgressingFalse(ctx, configClient, "kube-controller-manager")
o.Expect(err).NotTo(o.HaveOccurred(), "kube-controller-manager operator did not reconcile PKI config %s", tc.name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Both suites sleep for a fixed time before they wait for the operator, so the wait can observe a stale condition. time.Sleep(10 * time.Second) does not guarantee that the kube-controller-manager operator has reacted to the new PKI spec. If the operator has not yet set Progressing=True, WaitForOperatorProgressingFalse returns at once on the pre-change condition, the test deletes the signer Secrets under the old profile, and the algorithm assertions fail intermittently.

  • test/extended/pki/pki_kube_controller_manager.go#L73-L77: remove the sleep in testUniformKCMPKIConfigurations and wait until the operator status reflects the applied PKI generation before you wait for Progressing=False.
  • test/extended/pki/pki_kube_controller_manager.go#L112-L116: apply the same wait in testMixedKCMPKIConfigurations.
📍 Affects 1 file
  • test/extended/pki/pki_kube_controller_manager.go#L73-L77 (this comment)
  • test/extended/pki/pki_kube_controller_manager.go#L112-L116
🤖 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 `@test/extended/pki/pki_kube_controller_manager.go` around lines 73 - 77, In
test/extended/pki/pki_kube_controller_manager.go#L73-L77, update
testUniformKCMPKIConfigurations to remove the fixed sleep and wait for the
kube-controller-manager operator status to reflect the applied PKI generation
before calling WaitForOperatorProgressingFalse. Apply the same change in
test/extended/pki/pki_kube_controller_manager.go#L112-L116 within
testMixedKCMPKIConfigurations.

Comment on lines +95 to +100
signerAlgorithm: configv1alpha1.KeyAlgorithmRSA,
signerRSASize: 4096,
servingAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
servingECDSACurve: configv1alpha1.ECDSACurveP256,
clientAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
clientECDSACurve: configv1alpha1.ECDSACurveP521,

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 | 🟡 Minor | ⚡ Quick win

Run gofmt on this struct literal.

The keys in this literal are not aligned consistently. servingECDSACurve and clientECDSACurve use a different column than the neighboring keys. gofmt aligns all values in a contiguous key-value run, so make verify will report a diff.

♻️ Proposed formatting
 		{
-			name:             "RSA4096-signers",
-			signerAlgorithm:  configv1alpha1.KeyAlgorithmRSA,
-			signerRSASize:    4096,
-			servingAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
-			servingECDSACurve: configv1alpha1.ECDSACurveP256,
-			clientAlgorithm:  configv1alpha1.KeyAlgorithmECDSA,
-			clientECDSACurve: configv1alpha1.ECDSACurveP521,
+			name:              "RSA4096-signers",
+			signerAlgorithm:   configv1alpha1.KeyAlgorithmRSA,
+			signerRSASize:     4096,
+			servingAlgorithm:  configv1alpha1.KeyAlgorithmECDSA,
+			servingECDSACurve: configv1alpha1.ECDSACurveP256,
+			clientAlgorithm:   configv1alpha1.KeyAlgorithmECDSA,
+			clientECDSACurve:  configv1alpha1.ECDSACurveP521,
 		},

As per coding guidelines: "Run make verify for lint and generated-file checks".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
signerAlgorithm: configv1alpha1.KeyAlgorithmRSA,
signerRSASize: 4096,
servingAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
servingECDSACurve: configv1alpha1.ECDSACurveP256,
clientAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
clientECDSACurve: configv1alpha1.ECDSACurveP521,
{
name: "RSA4096-signers",
signerAlgorithm: configv1alpha1.KeyAlgorithmRSA,
signerRSASize: 4096,
servingAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
servingECDSACurve: configv1alpha1.ECDSACurveP256,
clientAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
clientECDSACurve: configv1alpha1.ECDSACurveP521,
},
🤖 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 `@test/extended/pki/pki_kube_controller_manager.go` around lines 95 - 100, Run
gofmt on the struct literal containing signerAlgorithm, servingAlgorithm, and
clientAlgorithm so all contiguous key-value fields, including servingECDSACurve
and clientECDSACurve, are aligned consistently.

Source: Coding guidelines

Comment on lines +176 to +185
if tc.algorithm == configv1alpha1.KeyAlgorithmRSA {
o.Expect(newCert.Algorithm).To(o.Equal("RSA"), "expected RSA algorithm for %s/%s", cert.Namespace, cert.SecretName)
o.Expect(int32(newCert.KeySize)).To(o.Equal(tc.rsaSize), "expected RSA key size %d for %s/%s", tc.rsaSize, cert.Namespace, cert.SecretName)
e2e.Logf(" Certificate verified: RSA-%d", newCert.KeySize)
} else if tc.algorithm == configv1alpha1.KeyAlgorithmECDSA {
o.Expect(newCert.Algorithm).To(o.Equal("ECDSA"), "expected ECDSA algorithm for %s/%s", cert.Namespace, cert.SecretName)
expectedCurve := string(tc.ecdsaCurve)
o.Expect(newCert.Curve).To(o.Equal(expectedCurve), "expected ECDSA curve %s for %s/%s", expectedCurve, cert.Namespace, cert.SecretName)
e2e.Logf(" Certificate verified: ECDSA-%s", newCert.Curve)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Both assertion chains lack a final branch, so an unexpected algorithm passes with no verification. Each if/else if chain covers only KeyAlgorithmRSA and KeyAlgorithmECDSA. For any other value, no property assertion runs, verifiedCount still increments, and the spec reports success.

  • test/extended/pki/pki_kube_controller_manager.go#L176-L185: add a failing final branch for tc.algorithm in testKCMCertificates.
  • test/extended/pki/pki_kube_controller_manager.go#L253-L262: add the same failing final branch for testCase.expectedAlgorithm in testMixedKCMCertificates.
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 177-177: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: int32(newCert.KeySize)
Note: [CWE-190] Integer Overflow or Wraparound.

(integer-overflow-narrowing-conversion-go)

📍 Affects 1 file
  • test/extended/pki/pki_kube_controller_manager.go#L176-L185 (this comment)
  • test/extended/pki/pki_kube_controller_manager.go#L253-L262
🤖 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 `@test/extended/pki/pki_kube_controller_manager.go` around lines 176 - 185, The
algorithm verification chains in testKCMCertificates
(test/extended/pki/pki_kube_controller_manager.go:176-185) and
testMixedKCMCertificates
(test/extended/pki/pki_kube_controller_manager.go:253-262) must reject
unsupported algorithm values. Add a final failing branch after the RSA and ECDSA
cases in both locations, so unexpected tc.algorithm or
testCase.expectedAlgorithm values cannot increment verifiedCount or report
success without assertions.

Comment on lines +68 to +78
err := applyPKIConfig(ctx, configClient, tc)
o.Expect(err).NotTo(o.HaveOccurred(), "error applying PKI config %s", tc.name)

e2e.Logf("PKI configuration %s applied successfully", tc.name)

time.Sleep(10 * time.Second)

e2e.Logf("Waiting for machine-config operator to reconcile PKI config...")
err = exutil.WaitForOperatorProgressingFalse(ctx, configClient, "machine-config")
o.Expect(err).NotTo(o.HaveOccurred(), "machine-config operator did not reconcile PKI config %s", tc.name)
e2e.Logf("Operator has reconciled PKI configuration")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Replace the fixed sleep with a generation-based wait.

time.Sleep(10 * time.Second) at Line 73 assumes the machine-config operator starts to report Progressing=True within 10 seconds. If the operator is slower, WaitForOperatorProgressingFalse observes the stale Progressing=False state from before the config change and returns immediately. The test then deletes Secrets before the new PKI profile is in effect, which produces flakes.

Wait for the operator status to observe the new config generation, then wait for Progressing=False. The same pattern exists at Lines 112-116.

🤖 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 `@test/extended/pki/pki_machine_config_operator.go` around lines 68 - 78,
Replace the fixed time.Sleep after applyPKIConfig with a generation-based wait
that confirms the machine-config operator has observed the newly applied PKI
configuration before calling WaitForOperatorProgressingFalse. Apply the same
change to the corresponding flow around lines 112-116, reusing the existing
operator generation/status wait helpers and preserving the subsequent
reconciliation check.

Comment on lines +92 to +102
mixedConfigs := []mixedPKITestConfig{
{
name: "RSA4096-signer-P256-serving",
signerAlgorithm: configv1alpha1.KeyAlgorithmRSA,
signerRSASize: 4096,
servingAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
servingECDSACurve: configv1alpha1.ECDSACurveP256,
clientAlgorithm: configv1alpha1.KeyAlgorithmECDSA,
clientECDSACurve: configv1alpha1.ECDSACurveP521,
},
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

The client profile in the mixed config is never validated.

clientAlgorithm and clientECDSACurve are set, but testMixedMCOCertificates only validates the serving and signer Secrets. The mixed test therefore does not prove that the client profile is applied. Add a client certificate Secret to the validation table, or remove the unused fields to avoid a false impression of coverage.

🤖 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 `@test/extended/pki/pki_machine_config_operator.go` around lines 92 - 102, The
mixedConfigs client profile is not covered by validation. Update
testMixedMCOCertificates to include the expected client certificate Secret in
its validation table, using clientAlgorithm and clientECDSACurve, so the
configured client profile is verified alongside the signer and serving profiles.

Comment on lines +177 to +186
if tc.algorithm == configv1alpha1.KeyAlgorithmRSA {
o.Expect(newCert.Algorithm).To(o.Equal("RSA"), "expected RSA algorithm for %s/%s", cert.Namespace, cert.SecretName)
o.Expect(int32(newCert.KeySize)).To(o.Equal(tc.rsaSize), "expected RSA key size %d for %s/%s", tc.rsaSize, cert.Namespace, cert.SecretName)
e2e.Logf(" Certificate verified: RSA-%d", newCert.KeySize)
} else if tc.algorithm == configv1alpha1.KeyAlgorithmECDSA {
o.Expect(newCert.Algorithm).To(o.Equal("ECDSA"), "expected ECDSA algorithm for %s/%s", cert.Namespace, cert.SecretName)
expectedCurve := string(tc.ecdsaCurve)
o.Expect(newCert.Curve).To(o.Equal(expectedCurve), "expected ECDSA curve %s for %s/%s", expectedCurve, cert.Namespace, cert.SecretName)
e2e.Logf(" Certificate verified: ECDSA-%s", newCert.Curve)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a terminal else to the algorithm assertions. Both validation blocks branch on RSA and then ECDSA with no final else. If the expected algorithm is empty or a new value, no key assertion runs, verifiedCount still increments, and the test passes without validating anything.

  • test/extended/pki/pki_machine_config_operator.go#L177-L186: add an else that fails the test for an unexpected tc.algorithm value.
  • test/extended/pki/pki_machine_config_operator.go#L258-L267: add the same else for an unexpected testCase.expectedAlgorithm value.
🛡️ Proposed fix for the uniform case
 	} else if tc.algorithm == configv1alpha1.KeyAlgorithmECDSA {
 		o.Expect(newCert.Algorithm).To(o.Equal("ECDSA"), "expected ECDSA algorithm for %s/%s", cert.Namespace, cert.SecretName)
 		expectedCurve := string(tc.ecdsaCurve)
 		o.Expect(newCert.Curve).To(o.Equal(expectedCurve), "expected ECDSA curve %s for %s/%s", expectedCurve, cert.Namespace, cert.SecretName)
 		e2e.Logf("    Certificate verified: ECDSA-%s", newCert.Curve)
+	} else {
+		g.Fail(fmt.Sprintf("unexpected key algorithm %q in test config %s", tc.algorithm, tc.name))
 	}
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 178-178: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: int32(newCert.KeySize)
Note: [CWE-190] Integer Overflow or Wraparound.

(integer-overflow-narrowing-conversion-go)

📍 Affects 1 file
  • test/extended/pki/pki_machine_config_operator.go#L177-L186 (this comment)
  • test/extended/pki/pki_machine_config_operator.go#L258-L267
🤖 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 `@test/extended/pki/pki_machine_config_operator.go` around lines 177 - 186, Add
a terminal else branch to the algorithm validation blocks at
test/extended/pki/pki_machine_config_operator.go lines 177-186 and 258-267,
failing the test when tc.algorithm or testCase.expectedAlgorithm is neither RSA
nor ECDSA. Ensure unexpected or empty values cannot increment verifiedCount
without performing a key assertion.

@kaleemsiddiqu

Copy link
Copy Markdown
Contributor Author

/test e2e-gcp-ovn-techpreview-pkiconfig

@kaleemsiddiqu

Copy link
Copy Markdown
Contributor Author

/test verify

@kaleemsiddiqu

Copy link
Copy Markdown
Contributor Author

/retest

expectedAlgorithm: tc.signerAlgorithm,
expectedRSASize: tc.signerRSASize,
expectedECDSACurve: tc.signerECDSACurve,
},

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.


verifiedCount++

time.Sleep(5 * time.Second)

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.

Is this sleep necessary? If it is, can we add a comment explaining it's necessary?


verifiedCount++

time.Sleep(5 * time.Second)

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.


verifiedCount++

time.Sleep(5 * time.Second)

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.


verifiedCount++

time.Sleep(5 * time.Second)

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.

additional test for pki config covering kube controller manager
and machine config operator

Signed-off-by: Kaleemullah Siddiqui <ksiddiqu@redhat.com>
@kaleemsiddiqu
kaleemsiddiqu force-pushed the pki-config-additional-tests branch from 48ea73c to 2d1b82a Compare August 14, 2026 14:31
@openshift-ci-robot

openshift-ci-robot commented Aug 14, 2026

Copy link
Copy Markdown

@kaleemsiddiqu: This pull request references CNTRLPLANE-1739 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.

Details

In response to this:

additional test for pki config covering kube controller manager and machine config operator

Summary by CodeRabbit

  • Tests
  • Added coverage for PKI configurations used by the kube-controller-manager and machine-config operators.
  • Added RSA, ECDSA, and mixed signer/serving configuration scenarios.
  • Verified certificate reconciliation, automatic regeneration after secret deletion, CA status, and key parameters.
  • Added cleanup to restore PKI settings after test execution.

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 openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Aug 14, 2026
@kaleemsiddiqu

Copy link
Copy Markdown
Contributor Author

/test e2e-gcp-ovn-techpreview-pkiconfig

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@sanchezl

sanchezl commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Verification Analysis — CNTRLPLANE-1739

Change under test: New e2e coverage in test/extended/pki/ validating ConfigurablePKI certificate regeneration for the kube-controller-manager and machine-config operators. Pure test code (helpers.go + new pki_operator_certs.go); no product code changes.

Evidence

  • e2e-gcp-ovn-techpreview-pkiconfig (build 2088273483283828736) exercised the new tests on commit 2d1b82a.
    • e2e test results: 70/70 passed, 0 failed (junit_e2e failure summary empty). The new [Suite:openshift/pkiconfig] PKI Configuration specs for both operators ran and passed.

New tests verified

  • PKI Configuration ... should validate uniform PKI configurations and certificate regeneration for kube-controller-manager (RSA-4096, ECDSA-P384)
  • PKI Configuration ... should validate mixed PKI configurations and certificate regeneration for kube-controller-manager
  • PKI Configuration ... should validate uniform PKI configurations and certificate regeneration for machine-config-operator
  • PKI Configuration ... should validate mixed PKI configurations and certificate regeneration for machine-config-operator

Each test applies a PKI profile, deletes the managed secret, waits for regeneration, and asserts the new cert's CA flag (category-based) and key algorithm/size/curve. Unknown algorithms now hard-fail (g.Fail) rather than silently skipping.

Red checks — both unrelated to this change (infra/flake)

Job Cause Related?
e2e-gcp-ovn-techpreview-pkiconfig Cluster monitor invariants only (OLM packageserver generation=350, kubelet anon-auth log noise, console-operator back-off known-BZ, etcd dropped Raft msgs). All 70 e2e tests passed. No — environmental
e2e-aws-ovn-microshift-serial infra-pcp/infra-pmlogs steps failed on libvirt socket error (virtqemud-sock-ro: No such file or directory). PKI tests are [Skipped:MicroShift] and never run here. No — infra

Caveats

  • KCM's "mixed" config is signer-only (KCM exposes no serving/client PKI secrets) — documented in-code; adds little over the uniform case but is correct for KCM's cert surface.
  • Both red checks are safe to /retest.

Verified by: e2e-gcp-ovn-techpreview-pkiconfig — the new tests passed 70/70 in this suite.

@sanchezl

Copy link
Copy Markdown
Contributor

/lgtm
/approve
/verified by "e2e-gcp-ovn-techpreview-pkiconfig"

@openshift-ci-robot

Copy link
Copy Markdown

@sanchezl: This PR has been marked as verified by "e2e-gcp-ovn-techpreview-pkiconfig".

Details

In response to this:

/lgtm
/approve
/verified by "e2e-gcp-ovn-techpreview-pkiconfig"

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 verified Signifies that the PR passed pre-merge verification criteria label Aug 14, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2026
@openshift-ci

openshift-ci Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kaleemsiddiqu, sanchezl
Once this PR has been reviewed and has the lgtm label, please assign dgoodwin 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

@openshift-ci

openshift-ci Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@kaleemsiddiqu: 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/e2e-gcp-ovn 2d1b82a link true /test e2e-gcp-ovn
ci/prow/e2e-aws-ovn-fips 2d1b82a link true /test e2e-aws-ovn-fips
ci/prow/e2e-gcp-ovn-techpreview-pkiconfig 2d1b82a link false /test e2e-gcp-ovn-techpreview-pkiconfig
ci/prow/e2e-aws-ovn-microshift-serial 2d1b82a link true /test e2e-aws-ovn-microshift-serial
ci/prow/e2e-vsphere-ovn 2d1b82a link true /test e2e-vsphere-ovn
ci/prow/e2e-vsphere-ovn-upi 2d1b82a link true /test e2e-vsphere-ovn-upi
ci/prow/e2e-gcp-ovn-upgrade 2d1b82a link true /test e2e-gcp-ovn-upgrade

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.

@openshift-trt

openshift-trt Bot commented Aug 14, 2026

Copy link
Copy Markdown

Risk analysis has seen new tests most likely introduced by this PR.
Please ensure that new tests meet guidelines for naming and stability.

New Test Risks for sha: 2d1b82a

Job Name New Test Risk
pull-ci-openshift-origin-main-e2e-gcp-ovn-techpreview-pkiconfig Medium - "[sig-kube-controller-manager][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate mixed PKI configurations and certificate regeneration for kube-controller-manager [apigroup:config.openshift.io][Skipped:MicroShift]" is a new test, and was only seen in one job.
pull-ci-openshift-origin-main-e2e-gcp-ovn-techpreview-pkiconfig Medium - "[sig-kube-controller-manager][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate uniform PKI configurations and certificate regeneration for kube-controller-manager [apigroup:config.openshift.io][Skipped:MicroShift]" is a new test, and was only seen in one job.
pull-ci-openshift-origin-main-e2e-gcp-ovn-techpreview-pkiconfig Medium - "[sig-mco][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate mixed PKI configurations and certificate regeneration for machine-config-operator [apigroup:config.openshift.io][Skipped:MicroShift]" is a new test, and was only seen in one job.
pull-ci-openshift-origin-main-e2e-gcp-ovn-techpreview-pkiconfig Medium - "[sig-mco][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate uniform PKI configurations and certificate regeneration for machine-config-operator [apigroup:config.openshift.io][Skipped:MicroShift]" is a new test, and was only seen in one job.

New tests seen in this PR at sha: 2d1b82a

  • "[sig-kube-controller-manager][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate mixed PKI configurations and certificate regeneration for kube-controller-manager [apigroup:config.openshift.io][Skipped:MicroShift]" [Total: 1, Pass: 1, Fail: 0, Flake: 0]
  • "[sig-kube-controller-manager][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate uniform PKI configurations and certificate regeneration for kube-controller-manager [apigroup:config.openshift.io][Skipped:MicroShift]" [Total: 1, Pass: 1, Fail: 0, Flake: 0]
  • "[sig-mco][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate mixed PKI configurations and certificate regeneration for machine-config-operator [apigroup:config.openshift.io][Skipped:MicroShift]" [Total: 1, Pass: 1, Fail: 0, Flake: 0]
  • "[sig-mco][OCPFeatureGate:ConfigurablePKI][Serial][Disruptive][Suite:openshift/pkiconfig] PKI Configuration should validate uniform PKI configurations and certificate regeneration for machine-config-operator [apigroup:config.openshift.io][Skipped:MicroShift]" [Total: 1, Pass: 1, Fail: 0, Flake: 0]

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants