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 comprehensive PKI validation coverage for controller manager and machine configuration components.
    • Verified RSA and ECDSA certificate configurations, including mixed signing, serving, and client certificate setups.
    • Confirmed certificate regeneration after generated secrets are removed.
    • Added checks for certificate authority status, key algorithms, key sizes, and elliptic curves.
    • Ensured cleanup of test configuration after execution.

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

Signed-off-by: Kaleemullah Siddiqui <ksiddiqu@redhat.com>
@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

Walkthrough

Added ordered PKI test suites for kube-controller-manager and machine-config operator. The suites test RSA-4096, ECDSA-P384, and mixed profiles, then verify Secret regeneration and certificate properties.

Changes

PKI operator tests

Layer / File(s) Summary
kube-controller-manager PKI configuration
test/extended/pki/pki_kube_controller_manager.go
Adds ordered setup, cleanup, uniform RSA and ECDSA cases, mixed signer configurations, and reconciliation checks.
kube-controller-manager certificate validation
test/extended/pki/pki_kube_controller_manager.go
Deletes signer Secrets, waits for regeneration, and validates CA status, algorithm, RSA key size, and ECDSA curve.
machine-config operator PKI configuration
test/extended/pki/pki_machine_config_operator.go
Adds ordered setup, cleanup, uniform RSA and ECDSA cases, mixed signer/serving/client configurations, and reconciliation checks.
machine-config operator certificate validation
test/extended/pki/pki_machine_config_operator.go
Deletes serving and signer Secrets, waits for replacement, and validates certificate classification and algorithm-specific properties.

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

Sequence Diagram(s)

sequenceDiagram
  participant Ginkgo
  participant PKIOperator as PKI operator
  participant CertificateSecrets as certificate Secrets
  participant Validation
  Ginkgo->>PKIOperator: apply uniform or mixed PKI configuration
  PKIOperator->>CertificateSecrets: reconcile generated certificates
  Ginkgo->>PKIOperator: wait for reconciliation
  Ginkgo->>CertificateSecrets: delete certificate Secrets
  PKIOperator->>CertificateSecrets: regenerate certificate Secrets
  Ginkgo->>Validation: verify CA status and key properties
Loading
🚥 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 addition of end-to-end tests for PKI configuration, which matches the main changes.
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 All Ginkgo titles in both added files are static string literals and contain no generated names, timestamps, nodes, namespaces, IPs, or other run-dependent values.
Test Structure And Quality ✅ Passed Both ordered suites use the repository's BeforeAll/DeferCleanup pattern, diagnostic messages on assertions, context-bounded regeneration waits, and the same client/wait helpers as existing PKI tests.
Microshift Test Compatibility ✅ Passed All four new g.It specs include [Skipped:MicroShift] and [apigroup:config.openshift.io], protecting their unavailable API and operator-specific behavior from MicroShift.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Both added suites only configure PKI and inspect/regenerate Secrets through OpenShift APIs; they do not assume multiple nodes, HA replicas, scheduling, or failover.
Topology-Aware Scheduling Compatibility ✅ Passed The parent diff contains only two test files. They apply PKI resources and inspect Secrets; no scheduling constraints, workload manifests, replica logic, or topology assumptions were added.
Ote Binary Stdout Contract ✅ Passed The added files have no process-level stdout writes; suite registration and BeforeAll only initialize clients and cleanup, while e2e.Logf calls run inside It-invoked test helpers.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The new Ginkgo tests use Kubernetes/OpenShift API clients, secret watches, and local certificate parsing; they contain no IPv4 literals, IP parsing, URLs, public hosts, or external downloads.
No-Weak-Crypto ✅ Passed Added files use only RSA-4096 and ECDSA P256/P384/P521; scans found no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret/token comparison.
Container-Privileges ✅ Passed The PR changes only two Go test files. Added-line scans found no privileged:true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings, and no manifests were added.
No-Sensitive-Data-In-Logs ✅ Passed New Logf calls emit fixed test names, namespaces, Secret names, certificate type, and algorithm metadata; they do not log secret data, credentials, UIDs, 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 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kaleemsiddiqu
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 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

@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@kaleemsiddiqu: The following test 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/verify 48ea73c link true /test verify

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants