Skip to content

CNTRLPLANE-3237: key controller schedules a preflight check - #2392

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
p0lyn0mial:kms-key-controller-preflight-gate
Aug 6, 2026
Merged

CNTRLPLANE-3237: key controller schedules a preflight check#2392
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
p0lyn0mial:kms-key-controller-preflight-gate

Conversation

@p0lyn0mial

@p0lyn0mial p0lyn0mial commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added KMS preflight validation before encryption keys are created or persisted.
    • Encryption configuration changes now use referenced Secret and ConfigMap data to verify readiness.
    • Added automatic retry behavior while preflight checks are pending.
  • Bug Fixes
    • Prevented key creation when KMS preflight validation fails.
    • Improved reporting of KMS preflight failures and status changes.

@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 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 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 30, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Encryption controller construction now injects KMS status and preflight dependencies. KMS key creation computes referenced-resource hashes, waits for matching successful preflight status, and avoids persistence while pending or failed. Tests cover the new gate and integration setup.

Changes

KMS preflight integration

Layer / File(s) Summary
Controller dependency wiring
pkg/operator/apiserver/controllerset/apiservercontrollerset.go, pkg/operator/encryption/controllers.go
Constructors accept and propagate the KMS status provider and preflight deployer.
Typed KMS hash clients
pkg/operator/encryption/controllers/kms_preflight_controller.go, pkg/operator/encryption/controllers/kms_preflight_controller_test.go
KMS hashing uses separate typed Secret and ConfigMap getter clients.
Key creation preflight gate
pkg/operator/encryption/controllers/key_controller.go
The key controller hashes referenced resources, updates observed hashes, waits for preflight status, and persists keys only after success.
Preflight gate validation
pkg/operator/encryption/controllers/key_controller_test.go, test/e2e-encryption/encryption_test.go
Tests cover pending and successful preflight states, migrations, and integration setup with no-op status and successful preflight implementations.

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

Sequence Diagram(s)

sequenceDiagram
  participant keyController
  participant SecretsAndConfigMaps
  participant encryptionStatusProvider
  participant Kubernetes API
  keyController->>SecretsAndConfigMaps: Fetch referenced Secret and ConfigMap
  keyController->>encryptionStatusProvider: Read encryption status
  keyController->>encryptionStatusProvider: Update observed configuration hash
  encryptionStatusProvider-->>keyController: Return pending, failure, or success
  keyController->>Kubernetes API: Persist key after successful preflight
Loading

Possibly related PRs

Suggested reviewers: dgrisonnet

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: the key controller schedules and gates key creation on a KMS preflight 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 Modified test files use standard Go testing, not Ginkgo. All test scenario names are static and descriptive with no dynamic content.
Test Structure And Quality ✅ Passed The PR uses standard Go testing (testing.T) with table-driven tests and t.Run subtests, not Ginkgo. The custom check targets Ginkgo test code; the check is not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests added in this PR. The PR modifies standard Go tests and controller code; the custom check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The pull request does not add any new Ginkgo e2e tests. The file test/e2e-encryption/encryption_test.go contains only one test function (TestEncryptionIntegration) that uses the standard Go testing...
Topology-Aware Scheduling Compatibility ✅ Passed The aggregate PR diff adds no affinity, topology spread, replica, node selector/affinity, toleration, or PDB constraints; it only wires controllers and hashes resources.
Ote Binary Stdout Contract ✅ Passed All fmt.Printf calls in test file are within test function bodies (allowed); all klog calls are in controller methods (not process-level); no stdout writes in main, init, or suite setup.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR changes an existing standard Go test (TestEncryptionIntegration); no new Ginkgo declarations or IPv4/external-connectivity code were added.
No-Weak-Crypto ✅ Passed The PR adds no MD5, SHA-1, DES, RC4, Blowfish, or ECB usage. New comparisons cover config hashes and status, not secrets or tokens; FNV usage predates this PR.
Container-Privileges ✅ Passed PR contains only Go source code, not Kubernetes manifests. Container-privileges check applies to manifests only. No privileged configurations exist in the codebase changes.
No-Sensitive-Data-In-Logs ✅ Passed PR adds error handling and preflight validation logic without exposing sensitive data; error messages log only resource names, namespaces, and configuration hashes, not credential values.
✨ 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 30, 2026

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

🧹 Nitpick comments (6)
pkg/operator/encryption/controllers/kms_preflight_controller.go (1)

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

Struct field alignment is not gofmt-clean, and the field name stutters.

gofmt aligns struct field names/types, so provider kmsProviderConfig next to the longer field will be reformatted. Also consider naming the field resources (the type already carries the full name).

♻️ Proposed fix
 type kmsConfigHasher struct {
-	provider         kmsProviderConfig
-	kmsConfigHasherResourceProvider kmsConfigHasherResourceProvider
+	provider  kmsProviderConfig
+	resources kmsConfigHasherResourceProvider
 	// namespace is the namespace where the referenced Secrets and ConfigMaps are stored (e.g., openshift-config).
 	namespace string
 }
 
 // newKMSConfigHasher creates a hasher for a KMS provider config and its referenced resources.
 // namespace is the namespace where the referenced Secrets and ConfigMaps are stored (e.g., openshift-config).
-func newKMSConfigHasher(provider kmsProviderConfig, kmsConfigHasherResourceProvider kmsConfigHasherResourceProvider, namespace string) *kmsConfigHasher {
-	return &kmsConfigHasher{provider: provider, kmsConfigHasherResourceProvider: kmsConfigHasherResourceProvider, namespace: namespace}
+func newKMSConfigHasher(provider kmsProviderConfig, resources kmsConfigHasherResourceProvider, namespace string) *kmsConfigHasher {
+	return &kmsConfigHasher{provider: provider, resources: resources, namespace: namespace}
 }

Update the two call sites at lines 95 and 128 accordingly (h.resources.getSecret(...) / h.resources.getConfigMap(...)).

🤖 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/operator/encryption/controllers/kms_preflight_controller.go` around lines
53 - 63, Rename the kmsConfigHasher field kmsConfigHasherResourceProvider to
resources and update its constructor assignment plus both call sites in the
hasher methods to use h.resources. Run gofmt so the struct field declarations
are properly aligned.
pkg/operator/encryption/controllers/key_controller_test.go (2)

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

Composite-literal keys here are misaligned for gofmt.

expectedActions: retains the old two-space padding while the neighbouring keys were widened, so gofmt will rewrite this block.

♻️ Proposed fix
 			apiServerObjects:         []runtime.Object{apiServerWithKMS},
 			targetNamespace:          "kms",
 			encryptionStatusProvider: kmsCreateKeyStatusProvider,
-			expectedActions:  []string{"list:pods:kms", "get:secrets:kms", "list:secrets:openshift-config-managed", "get:secrets:openshift-config", "get:configmaps:openshift-config", "create:secrets:openshift-config-managed", "create:events:kms"},
+			expectedActions:          []string{"list:pods:kms", "get:secrets:kms", "list:secrets:openshift-config-managed", "get:secrets:openshift-config", "get:configmaps:openshift-config", "create:secrets:openshift-config-managed", "create:events:kms"},
🤖 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/operator/encryption/controllers/key_controller_test.go` around lines 550
- 553, Align the expectedActions composite-literal key with the surrounding
fields in the test case containing apiServerObjects, targetNamespace, and
encryptionStatusProvider, so the struct literal is gofmt-compliant without
changing its value.

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

Consider a subtest for the preflight-pending-with-stale-result case.

TestKMSPreflightGate covers hash-write/backoff, pending, succeeded, and failed. One uncovered branch of ensureKMSPreflightPassed: ObservedConfigHash matches but Result.ConfigHash belongs to an older config (stale Succeeded/Failed) — should back off, not create a key or error.

🤖 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/operator/encryption/controllers/key_controller_test.go` around lines 1062
- 1211, Add a subtest to TestKMSPreflightGate covering a matching
ObservedConfigHash with a stale Result.ConfigHash from an older configuration,
using both succeeded and failed result statuses if practical. Assert Sync backs
off without creating a key or returning the preflight failure error, and without
updating status; reuse computeExpectedHash, buildController, and
actionsWithoutKey.
pkg/operator/encryption/controllers/key_controller.go (2)

426-438: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Guard the prefetched objects against nil before dereferencing.

p.secret/p.configMap are nil whenever the provider config has no referenced Secret/ConfigMap. Today the hasher short-circuits on an empty name so these are unreachable, but the coupling is implicit — a future change in referencedSecretName/referencedConfigMapName handling turns this into a panic.

🛡️ Proposed fix
 func (p *prefetchedKMSConfigHasherResourceProvider) getSecret(_ context.Context, namespace, name string) (*corev1.Secret, error) {
+	if p.secret == nil {
+		return nil, fmt.Errorf("no prefetched secret available for requested %s/%s", namespace, name)
+	}
 	if p.secret.Namespace != namespace || p.secret.Name != name {
 		return nil, fmt.Errorf("prefetched secret %s/%s does not match requested %s/%s", p.secret.Namespace, p.secret.Name, namespace, name)
 	}
 	return p.secret, nil
 }
 
 func (p *prefetchedKMSConfigHasherResourceProvider) getConfigMap(_ context.Context, namespace, name string) (*corev1.ConfigMap, error) {
+	if p.configMap == nil {
+		return nil, fmt.Errorf("no prefetched configmap available for requested %s/%s", namespace, name)
+	}
 	if p.configMap.Namespace != namespace || p.configMap.Name != name {
🤖 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/operator/encryption/controllers/key_controller.go` around lines 426 -
438, Update getSecret and getConfigMap to check p.secret and p.configMap for nil
before accessing Namespace or Name; return the existing mismatch error (or an
equivalent safe error) when the prefetched object is absent, while preserving
the current matching-object return behavior.

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

Requeue interval is a magic value.

30*time.Second for the preflight backoff would read better as a named constant next to the existing 2*time.Minute progressing backoff, and makes it tunable in one place.

🤖 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/operator/encryption/controllers/key_controller.go` around lines 245 -
259, The preflight requeue in the key-generation flow uses an inline 30-second
duration. Define a named constant alongside the existing 2-minute
progressing-backoff constant, then use that constant in the
syncContext.Queue().AddAfter call after generateKeySecret reports
!preconditionMet.
pkg/operator/apiserver/controllerset/apiservercontrollerset.go (1)

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

Trim the alignment padding and extra blank line

gofmt will collapse the parameter alignment here and remove the extra blank line below.

♻️ Proposed formatting fix
-	resourceSyncer           *resourcesynccontroller.ResourceSyncController,
+	resourceSyncer *resourcesynccontroller.ResourceSyncController,
🤖 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/operator/apiserver/controllerset/apiservercontrollerset.go` around lines
372 - 373, Run gofmt on the function signature containing resourceSyncer and
encryptionStatusProvider, removing the manual alignment padding and extra blank
line while preserving the parameter declarations.
🤖 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 `@pkg/operator/encryption/controllers/key_controller.go`:
- Around line 370-376: Guard the KMS preflight path around
ensureKMSPreflightPassed so a nil encryptionStatusProvider is detected before
the call and returned as a clear configuration error. Preserve the existing
preflightPassed handling when the provider is present, and avoid changing
non-KMS behavior.

---

Nitpick comments:
In `@pkg/operator/apiserver/controllerset/apiservercontrollerset.go`:
- Around line 372-373: Run gofmt on the function signature containing
resourceSyncer and encryptionStatusProvider, removing the manual alignment
padding and extra blank line while preserving the parameter declarations.

In `@pkg/operator/encryption/controllers/key_controller_test.go`:
- Around line 550-553: Align the expectedActions composite-literal key with the
surrounding fields in the test case containing apiServerObjects,
targetNamespace, and encryptionStatusProvider, so the struct literal is
gofmt-compliant without changing its value.
- Around line 1062-1211: Add a subtest to TestKMSPreflightGate covering a
matching ObservedConfigHash with a stale Result.ConfigHash from an older
configuration, using both succeeded and failed result statuses if practical.
Assert Sync backs off without creating a key or returning the preflight failure
error, and without updating status; reuse computeExpectedHash, buildController,
and actionsWithoutKey.

In `@pkg/operator/encryption/controllers/key_controller.go`:
- Around line 426-438: Update getSecret and getConfigMap to check p.secret and
p.configMap for nil before accessing Namespace or Name; return the existing
mismatch error (or an equivalent safe error) when the prefetched object is
absent, while preserving the current matching-object return behavior.
- Around line 245-259: The preflight requeue in the key-generation flow uses an
inline 30-second duration. Define a named constant alongside the existing
2-minute progressing-backoff constant, then use that constant in the
syncContext.Queue().AddAfter call after generateKeySecret reports
!preconditionMet.

In `@pkg/operator/encryption/controllers/kms_preflight_controller.go`:
- Around line 53-63: Rename the kmsConfigHasher field
kmsConfigHasherResourceProvider to resources and update its constructor
assignment plus both call sites in the hasher methods to use h.resources. Run
gofmt so the struct field declarations are properly aligned.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3b5f281c-38c1-4dbd-8ce6-386a2453eadf

📥 Commits

Reviewing files that changed from the base of the PR and between 26e4f37 and 5195e17.

📒 Files selected for processing (7)
  • pkg/operator/apiserver/controllerset/apiservercontrollerset.go
  • pkg/operator/encryption/controllers.go
  • pkg/operator/encryption/controllers/key_controller.go
  • pkg/operator/encryption/controllers/key_controller_test.go
  • pkg/operator/encryption/controllers/kms_preflight_controller.go
  • pkg/operator/encryption/controllers/kms_preflight_controller_test.go
  • test/e2e-encryption/encryption_test.go

Comment thread pkg/operator/encryption/controllers/key_controller.go

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

🤖 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/e2e-encryption/encryption_test.go`:
- Around line 1045-1057: Update noopKMSEncryptionStatusProvider so
GetKMSEncryptionStatus returns persisted status and UpdateKMSEncryptionStatus
applies the provided mutation to that status. Protect reads and mutations with
synchronization because key and preflight controllers access the provider
concurrently; keep ApplyKMSEncryptionStatus behavior unchanged unless required
for status persistence.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5d0755b6-0594-4061-afb2-066a87421e69

📥 Commits

Reviewing files that changed from the base of the PR and between 5195e17 and 2036220.

📒 Files selected for processing (8)
  • pkg/operator/apiserver/controllerset/apiservercontrollerset.go
  • pkg/operator/encryption/controllers.go
  • pkg/operator/encryption/controllers/key_controller_test.go
  • pkg/operator/encryption/controllers/kms_preflight_controller.go
  • pkg/operator/encryption/controllers/kms_preflight_controller_test.go
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer.go
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer_test.go
  • test/e2e-encryption/encryption_test.go

Comment thread test/e2e-encryption/encryption_test.go Outdated

@ardaguclu ardaguclu left a 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.

Just dropped a minor comment. Overall mechanism looks really nice to me.

// NewAlwaysSucceedKMSPreflightDeployer returns a KMSPreflightDeployer that
// always reports a successful preflight without running any real check.
// Use as a temporary stand-in until a real pod-based deployer is available.
func NewAlwaysSucceedKMSPreflightDeployer() *AlwaysSucceedKMSPreflightDeployer {

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.

Would it be better moving this under test/e2e-encryption?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was planning to use it tmp in production, for example openshift/cluster-kube-apiserver-operator@c65f8ca

The benefit would be that we would be testing the entire stack except the deployers.

WDYT ?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/operator/encryption/controllers/kms_preflight_controller_test.go (1)

936-959: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert that the identity path skips KMS status reads.

The scenario checks cleanup and conditions, but it does not assert that GetKMSEncryptionStatus is not called. A regression that moves status retrieval before the encryption-type check could pass this test. Configure the fake provider to fail on a status read or record reads and assert zero.

This check uses the supplied identity-revert scenario and PR objective.

🤖 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/operator/encryption/controllers/kms_preflight_controller_test.go` around
lines 936 - 959, Update the identity-revert test case around the
fakeEncryptionStatusProvider to detect KMS status reads, configuring it to fail
or record calls when GetKMSEncryptionStatus is invoked. Assert that the read
count remains zero while preserving the existing cleanup and non-degraded
condition assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/operator/encryption/controllers/kms_preflight_controller_test.go`:
- Around line 936-959: Update the identity-revert test case around the
fakeEncryptionStatusProvider to detect KMS status reads, configuring it to fail
or record calls when GetKMSEncryptionStatus is invoked. Assert that the read
count remains zero while preserving the existing cleanup and non-degraded
condition assertions.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 0f444232-2e42-43c1-8cb4-fda0f16f7820

📥 Commits

Reviewing files that changed from the base of the PR and between 2036220 and a29f422.

📒 Files selected for processing (5)
  • pkg/operator/encryption/controllers/key_controller.go
  • pkg/operator/encryption/controllers/kms_preflight_controller.go
  • pkg/operator/encryption/controllers/kms_preflight_controller_test.go
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer.go
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer_test.go
  • pkg/operator/encryption/kms/preflight/always_succeed_deployer.go
  • pkg/operator/encryption/controllers/key_controller.go

@openshift-ci-robot

openshift-ci-robot commented Aug 4, 2026

Copy link
Copy Markdown

@p0lyn0mial: This pull request references CNTRLPLANE-3237 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:

Summary by CodeRabbit

  • New Features
  • Added KMS preflight validation before encryption keys are persisted.
  • Key creation now computes the applicable KMS configuration hash and waits for preflight completion.
  • Added a default preflight implementation that reports successful validation.
  • Bug Fixes
  • Prevented key creation when preflight validation fails and improved handling of pending or stale validation results.
  • Tests
  • Added coverage for preflight success, failure, retries, observed-hash updates, and encryption-mode changes.
  • Updated integration coverage for non-KMS encryption scenarios.

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2026
@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch from a29f422 to b8819dc Compare August 4, 2026 12:24
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2026
@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch 2 times, most recently from 240b024 to 9bdf2ef Compare August 4, 2026 14:16

func (p *prefetchedKMSConfigHasherResourceProvider) getSecret(_ context.Context, namespace, name string) (*corev1.Secret, error) {
if p.secret == nil || p.secret.Namespace != namespace || p.secret.Name != name {
sNS, sName := "", ""

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.

This is redundant, since we already return error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, thx.


func (p *prefetchedKMSConfigHasherResourceProvider) getConfigMap(_ context.Context, namespace, name string) (*corev1.ConfigMap, error) {
if p.configMap == nil || p.configMap.Namespace != namespace || p.configMap.Name != name {
cmNS, cmName := "", ""

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.

This is redundant, since we already return error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, thx.

}
}

var refCM *corev1.ConfigMap

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.

What about there is another referenced configMap?. This logic seems only work, if there is 1 configmap?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

please see #2392 (comment)

// Fetch the referenced Secret and ConfigMap, copying their data into the
// key state. The fetched objects are reused by prefetchedKMSConfigHasherResourceProvider
// to compute the config hash without a second API round-trip.
var refSecret *corev1.Secret

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.

Same, I think we shouldn't assume that there is only 1 referenced resource. Hash calculation should take account that there might be more. If optional another referenced Secret is updated in API, that won't trigger preflight controller, since hash is not changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is preexisting. The current code assumes only a single secret/cm.

type kmsProviderConfig interface {

func (v *vaultProviderConfig) referencedConfigMapName() (string, []string, error) {

does it make sense ?

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.

Yes, it would be pretty easy to switch to support multiple referenced data in key controller. But preflight hash calculator, in my opinion, should support multiple reference data without guessing any format in key controller. However, this can be fixed in a follow up PR.

//
// Callers are responsible for requeuing when this returns (false, nil).
func (c *keyController) ensureKMSPreflightPassed(ctx context.Context, configHash string) (bool, error) {
encryptionStatus, err := c.encryptionStatusProvider.GetKMSEncryptionStatus(ctx)

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.

I only see the fake encryptionStatusProviders or noop. Haven't we merged the prod ready encryptionStatusProvider yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch from 9bdf2ef to 2c3fc98 Compare August 5, 2026 09:24
@p0lyn0mial
p0lyn0mial marked this pull request as ready for review August 5, 2026 09:25
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 5, 2026
@openshift-ci
openshift-ci Bot requested a review from ardaguclu August 5, 2026 09:26
@openshift-ci
openshift-ci Bot requested a review from dgrisonnet August 5, 2026 09:26
@p0lyn0mial

Copy link
Copy Markdown
Contributor Author

a test pr at openshift/cluster-kube-apiserver-operator#2252

in general i got green e2e-aws-operator-encryption-kms and e2e-aws-operator-encryption-kms-2

https://prow.ci.openshift.org/pr-history/?org=openshift&repo=cluster-kube-apiserver-operator&pr=2252

the latest failure of e2e-aws-operator-encryption-kms is not related to the changes in this pr. the kms tests in that run passed. the test failed on [Monitor:audit-log-analyzer][sig-api-machinery][Feature:APIServer] API LBs follow /readyz of kube-apiserver and stop sending requests before server shutdowns for external clients

@ardaguclu

Copy link
Copy Markdown
Member

@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch from 2c3fc98 to 3ce65c5 Compare August 5, 2026 09:39
@ardaguclu

Copy link
Copy Markdown
Member

/lgtm
/approve

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

Copy link
Copy Markdown
Member

@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch from 3ce65c5 to 4404c02 Compare August 5, 2026 11:18
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2026
}

func (p *noopKMSEncryptionStatusProvider) UpdateKMSEncryptionStatus(_ context.Context, _ func(*operatorv1.KMSEncryptionStatus)) error {
return nil

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.

In integration tests, key controller expect the key to be created. I think this mock should return successful status, so that key is created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. Testing locally. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL.

@p0lyn0mial
p0lyn0mial force-pushed the kms-key-controller-preflight-gate branch from 4404c02 to c16225a Compare August 6, 2026 11:03
@ardaguclu

Copy link
Copy Markdown
Member

/lgtm
/approve
e2e-aws-encryption is required already

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

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, p0lyn0mial

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

The pull request process is described here

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

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

@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@p0lyn0mial: all tests passed!

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-merge-bot
openshift-merge-bot Bot merged commit 39539af into openshift:master Aug 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants