Skip to content

CNTRLPLANE-3237: Add new KMS foundational mechanism in encryption controller - #2161

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
ardaguclu:kms-v2-foundations
Apr 20, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
ardaguclu:kms-v2-foundations

Conversation

@ardaguclu

@ardaguclu ardaguclu commented Apr 13, 2026

Copy link
Copy Markdown
Member

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

Summary by CodeRabbit

  • Refactor

    • KMS encryption keys now use per-key Unix socket endpoints instead of a single shared socket
    • KMS configuration is stored in secret data fields (not annotations) and related identifiers updated
    • Test/KMS assets adjusted to run multiple per-key mock KMS instances
  • Tests

    • Test suites updated to validate per-key endpoints and the new KMS config storage format

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

openshift-ci-robot commented Apr 13, 2026

Copy link
Copy Markdown

@ardaguclu: This pull request references CNTRLPLANE-2993 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 "4.22.0" version, but no target version was set.

Details

In response to this:

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

This PR breaks KMS TP v1 changes, so it must not be merged in release-4.22 code base (so that this can be merged after the branchcut to 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

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 Apr 13, 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

Replaced the shared KMS Unix socket with per-key sockets (unix:///var/run/kmsplugin/kms-<keyID>.sock) and moved KMS configuration storage from Secret annotations into Secret data (encryption.apiserver.operator.openshift.io-kms-encryption-config); updated constants, types, controller logic, helpers, tests, and test assets accordingly.

Changes

Cohort / File(s) Summary
Controller & key flow
pkg/operator/encryption/controllers/key_controller.go
Switch to per-key KMS endpoint format (fmt.Sprintf(kmsEndpointFormat, keyID)) and assign KMS config from key.KMSEncryptionConfig when generating key Secrets.
Secret types & serialization
pkg/operator/encryption/secrets/types.go, pkg/operator/encryption/secrets/secrets.go
Renamed constant to EncryptionSecretKMSEncryptionConfig; stop using annotations for KMS config and persist/parse serialized KMS config from Secret .data[...] under the new key; updated error messages and field refs to KMSEncryptionConfig.
State types & conversion
pkg/operator/encryption/state/types.go, pkg/operator/encryption/encryptionconfig/config.go
Renamed KeyState field KMSConfigurationKMSEncryptionConfig and updated conversions to check/deep-copy KMSEncryptionConfig when building provider KMS configs.
Secrets roundtrip & utilities
pkg/operator/encryption/secrets/secrets_test.go, pkg/operator/encryption/encryptionconfig/config_test.go
Test fixtures updated to use per-key socket endpoints (kms-1.sock, kms-2.sock) and to expect KMSEncryptionConfig populated in KeyState for KMS cases.
Controller & state tests
pkg/operator/encryption/controllers/key_controller_test.go, pkg/operator/encryption/controllers/state_controller_test.go, pkg/operator/encryption/statemachine/transition_test.go
Updated assertions to read KMS config from Secret .data[...] key encryption.apiserver.operator.openshift.io-kms-encryption-config and to expect per-key KMS socket endpoints in KMSConfiguration.Endpoint. Negative assertions adjusted to check absence of the data key.
Test helpers
pkg/operator/encryption/testing/helpers.go
Helpers now write KMS JSON into Secret .data[...] under the new key and construct per-key KMS socket endpoints when creating test encryption key Secrets and provider configs.
Test assets (DaemonSet)
test/library/encryption/kms/assets/k8s_mock_kms_plugin_daemonset.yaml
DaemonSet expanded to run multiple mock KMS plugin containers (kms-plugin-1 ... kms-plugin-5) each exposing unique unix sockets (kms-1.sock ... kms-5.sock) and adjusted container names, volumeMounts, and socket cleanup logic.
Misc updates
various test files
Small adjustments across tests to reflect the new data key name and per-key endpoints; no changes to public API signatures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing KMS foundational mechanism (per-key socket endpoints and moving KMS config from annotations to data) required for KMS TPv2.
Stable And Deterministic Test Names ✅ Passed The PR uses only Go's standard testing package with table-driven tests, not Ginkgo framework, so this Ginkgo-specific check is not applicable.
Test Structure And Quality ✅ Passed The pull request's test changes all use the standard Go testing framework (testing.T) and do not include any Ginkgo/It blocks. As a result, the Ginkgo-specific quality requirements are not applicable to this PR.
Microshift Test Compatibility ✅ Passed PR modifies unit tests and test fixtures, not new Ginkgo e2e tests requiring MicroShift compatibility.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This pull request does not add any new Ginkgo e2e tests; it only modifies existing unit and integration tests using the standard Go testing package.
Topology-Aware Scheduling Compatibility ✅ Passed PR changes do not introduce topology-incompatible scheduling constraints; test-only DaemonSet has no nodeSelectors, affinity rules, or topology spread constraints.
Ote Binary Stdout Contract ✅ Passed PR introduces no process-level stdout writes violating OTE Binary Stdout Contract. Init functions perform scheme and metrics registration only; klog calls are in regular functions; no fmt.Print calls exist at package level.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only standard Go unit tests and test assets, not Ginkgo e2e tests. No IPv4 assumptions, external connectivity requirements, or e2e test additions found.

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

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

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

@openshift-ci
openshift-ci Bot requested review from dgrisonnet and tkashem April 13, 2026 09:52
@ardaguclu

Copy link
Copy Markdown
Member Author

@openshift-ci
openshift-ci Bot requested review from benluddy, bertinatto and p0lyn0mial and removed request for dgrisonnet and tkashem April 13, 2026 09:53

@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 the current code and only fix it if needed.

Inline comments:
In `@pkg/operator/encryption/controllers/key_controller.go`:
- Around line 274-278: The test mock KMS plugin DaemonSet still binds a fixed
socket (kms.sock) which no longer matches the per-key socket naming produced by
KMSConfiguration (APIVersion/Name/Endpoint using defaultKMSEndpointPrefix and
keyID), so update the DaemonSet container command: remove the fixed "rm -f
/var/run/kmsplugin/kms.sock" cleanup and change the mock plugin invocation to
create/bind sockets using the per-key filename pattern (e.g., kms-<id>.sock)
that matches fmt.Sprintf("%s-%d.sock", defaultKMSEndpointPrefix, keyID) used
when constructing KMSConfiguration; ensure the mount/path and any socket
creation logic use that same pattern so tests use per-key sockets.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93e09477-3cea-49cb-a98c-88e338798171

📥 Commits

Reviewing files that changed from the base of the PR and between d2db42c and 9622e29.

📒 Files selected for processing (9)
  • pkg/operator/encryption/controllers/key_controller.go
  • pkg/operator/encryption/controllers/key_controller_test.go
  • pkg/operator/encryption/controllers/state_controller_test.go
  • pkg/operator/encryption/encryptionconfig/config_test.go
  • pkg/operator/encryption/secrets/secrets.go
  • pkg/operator/encryption/secrets/secrets_test.go
  • pkg/operator/encryption/secrets/types.go
  • pkg/operator/encryption/statemachine/transition_test.go
  • pkg/operator/encryption/testing/helpers.go

Comment thread pkg/operator/encryption/controllers/key_controller.go Outdated
@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from 9622e29 to 1a8f3a2 Compare April 13, 2026 10:10
@openshift-ci-robot

openshift-ci-robot commented Apr 13, 2026

Copy link
Copy Markdown

@ardaguclu: This pull request references CNTRLPLANE-2993 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 "4.22.0" version, but no target version was set.

Details

In response to this:

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

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.

@ardaguclu

ardaguclu commented Apr 13, 2026

Copy link
Copy Markdown
Member Author

/hold
until branch cut and tests

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 13, 2026
@ardaguclu

ardaguclu commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

/retitle CNTRLPLANE-3237: Add new KMS foundational mechanism in encryption controller

@openshift-ci openshift-ci Bot changed the title CNTRLPLANE-2993: Add new KMS foundational mechanism in encryption controller CNTRLPLANE-3237: Add new KMS foundational mechanism in encryption controller Apr 14, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 14, 2026

Copy link
Copy Markdown

@ardaguclu: 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 "4.22.0" version, but no target version was set.

Details

In response to this:

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

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.

@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from 1a8f3a2 to c1d3fda Compare April 14, 2026 08:34
Comment thread pkg/operator/encryption/controllers/key_controller.go Outdated
Comment thread pkg/operator/encryption/controllers/key_controller.go Outdated
Comment thread pkg/operator/encryption/controllers/key_controller.go Outdated
if err := json.Unmarshal(v, kmsConfiguration); err != nil {
return state.KeyState{}, fmt.Errorf("secret %s/%s has invalid %s data: %v", s.Namespace, s.Name, EncryptionSecretKMSEncryptionConfig, err)
}
key.KMSConfiguration = kmsConfiguration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we rename key.KMSConfiguration to key.KMSEncryptionConfiguration / key.KMSEncryptionConfig ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've updated to key.KMSEncryptionConfig

EncryptionSecretKMSConfig = "encryption.apiserver.operator.openshift.io/kms-config"
// EncryptionSecretKMSEncryptionConfig is the data field key that stores the serialized KMS
// encryption configuration for KMS mode in the encryption-key secret.
EncryptionSecretKMSEncryptionConfig = "encryption.apiserver.operator.openshift.io-kms-encryption-config"

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.

shouldn't this be kms-encryption-config ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All annotations and data fields in this area uses encryption.apiserver.operator.openshift. prefix, I think we should still have it to distinguish.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have a flexibility to just use kms-encrypyion-config as data key, though.

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.

if that is the convention then we should stick to it. thanks.

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.

why not encryption.apiserver.operator.openshift.io/kms-encryption-config ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried to use it and got an error. After the investigations, I found out the reason https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api/core/v1/types.go#L7949-L7954 that secret data key can not contain / character.

EncryptionSecretKeyDataKey = "encryption.apiserver.operator.openshift.io-key"
is in the same format due to this reason.

encryptionSecretKeyDataForTest = "encryption.apiserver.operator.openshift.io-key"
encryptionSecretMigratedTimestampForTest = "encryption.apiserver.operator.openshift.io/migrated-timestamp"
encryptionSecretMigratedResourcesForTest = "encryption.apiserver.operator.openshift.io/migrated-resources"
encryptionSecretKMSEncryptionConfigForTest = "encryption.apiserver.operator.openshift.io-kms-encryption-config"

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.

shouldn't this be kms-encryption-config ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread pkg/operator/encryption/secrets/secrets.go Outdated
Comment thread pkg/operator/encryption/secrets/secrets.go Outdated
@openshift-ci-robot

openshift-ci-robot commented Apr 14, 2026

Copy link
Copy Markdown

@ardaguclu: 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 "4.22.0" version, but no target version was set.

Details

In response to this:

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

Summary by CodeRabbit

  • Refactor
  • KMS encryption keys now use individual socket endpoints instead of a shared endpoint across all keys
  • KMS configuration storage migrated from secret annotations to secret data fields
  • Configuration identifiers updated throughout the system to reflect the new storage location
  • Tests updated to validate per-key endpoint configurations

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 commented Apr 14, 2026

Copy link
Copy Markdown

@ardaguclu: 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 "4.22.0" version, but no target version was set.

Details

In response to this:

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

Summary by CodeRabbit

  • Refactor
  • KMS encryption keys now use per-key Unix socket endpoints instead of a single shared socket
  • KMS configuration is stored in secret data fields (not annotations) and identifiers updated accordingly
  • Tests
  • Test suites updated to validate per-key endpoints and the new KMS config storage format

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.

@ardaguclu

Copy link
Copy Markdown
Member Author

/retest

@ardaguclu

Copy link
Copy Markdown
Member Author

Manual testing proves that this PR properly works with plugin lifecycle changes openshift/cluster-kube-apiserver-operator#2035 (tested on openshift/cluster-kube-apiserver-operator#2103). In my opinion, if we prefer moving small incremental changes, we can merge this PR maybe
/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 15, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 16, 2026

Copy link
Copy Markdown

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

This PR brings the minimal changes required for the KMS TPv2 work described here openshift/enhancements#1960.

Main aim is to store data in Data field of Secret instead of annotation, insert key id into unix domain socket path. This PR should work with plugin lifecycle smoothly.

Changes here break KMS TP v1 functionality, so it must not be merged in release-4.22 code base (so that this can be merged after the branch cut of 4.23).

This PR excludes;

  • Track the changes in API side (whether new key is required or just in-place update)
  • secret/configmap, kmsConfig propagation mechanism to Key Secret
  • secret/configmap periodic sync

Summary by CodeRabbit

  • Refactor

  • KMS encryption keys now use per-key Unix socket endpoints instead of a single shared socket

  • KMS configuration is stored in secret data fields (not annotations) and related identifiers updated

  • Test/KMS assets adjusted to run multiple per-key mock KMS instances

  • Tests

  • Test suites updated to validate per-key endpoints and the new KMS config storage format

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.

@ardaguclu

Copy link
Copy Markdown
Member Author

subPath: softhsm-config.json
- name: softhsm-tokens
mountPath: /var/lib/softhsm/tokens
- name: kms-plugin-2

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.

could we move these changes to a new PR ?

also, could we just have a single manifest ?
could we extend the current template to accept additional param (keyID) ? and then we could use the keyID to generate name and the socket name.

then we would change

and we could extend (or write a new function)

func DeployUpstreamMockKMSPlugin(ctx context.Context, t testing.TB, kubeClient kubernetes.Interface, namespace, image string) {
to accept the number of replicas.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've dropped test changes from this PR in favor of #2165

@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from 67e3cac to ca7eb30 Compare April 17, 2026 11:43
bertinatto added a commit to bertinatto/cluster-kube-apiserver-operator that referenced this pull request Apr 17, 2026
@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from ca7eb30 to d2417fd Compare April 17, 2026 16:11
@ardaguclu

Copy link
Copy Markdown
Member Author

/retest

@p0lyn0mial p0lyn0mial left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

}
key.KMSEncryptionConfig = kmsConfiguration
}
if key.KMSEncryptionConfig == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can key.KMSEncryptionConfig be nil ? (given &apiserverconfigv1.KMSConfiguration{} ) ?

@ardaguclu ardaguclu Apr 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think, empty KMSEncryptionConfig will be forbidden in API side https://github.com/openshift/api/pull/2805/changes#diff-616d67895c3421c2d091662d30ed47b4b6f0b57db9411e29618d22b964ddb9efR212`

Since KMSEncryptionConfig is generated by key_controller in each new key, technically it is not possible to have nil KMSEncryptionConfig.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just for historical context: We have added this check to be defensive #2086 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean it can be nil when there is no EncryptionSecretKMSEncryptionConfig right ?

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.

if v, ok := s.Data[EncryptionSecretKMSEncryptionConfig]; ok && len(v) > 0 {
   ...
} else {
   return state.KeyState{}, fmt.Errorf("KMSEncryptionConfig can not be nil, when mode is KMS")
}

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.

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean it can be nil when there is no EncryptionSecretKMSEncryptionConfig right ?

yes that is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Key controller always populates this field. But when this field is empty (due to manual deletion by modifying the key Secret, etc.), we will return error by checking key.KMSEncryptionConfig == nil

EncryptionSecretKMSConfig = "encryption.apiserver.operator.openshift.io/kms-config"
// EncryptionSecretKMSEncryptionConfig is the data field key that stores the serialized KMS
// encryption configuration for KMS mode in the encryption-key secret.
EncryptionSecretKMSEncryptionConfig = "encryption.apiserver.operator.openshift.io-kms-encryption-config"

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.

if that is the convention then we should stick to it. thanks.

EncryptionSecretKMSConfig = "encryption.apiserver.operator.openshift.io/kms-config"
// EncryptionSecretKMSEncryptionConfig is the data field key that stores the serialized KMS
// encryption configuration for KMS mode in the encryption-key secret.
EncryptionSecretKMSEncryptionConfig = "encryption.apiserver.operator.openshift.io-kms-encryption-config"

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.

why not encryption.apiserver.operator.openshift.io/kms-encryption-config ?

@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from dea3114 to 4dfab23 Compare April 20, 2026 11:07
@ardaguclu
ardaguclu force-pushed the kms-v2-foundations branch from 4dfab23 to 216f898 Compare April 20, 2026 11:12
@p0lyn0mial

Copy link
Copy Markdown
Contributor

/lgtm

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

openshift-ci Bot commented Apr 20, 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 20, 2026
@ardaguclu

Copy link
Copy Markdown
Member Author

/hold
to see e2e-aws-encryption green (in case it is optional)

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 20, 2026
@ardaguclu

Copy link
Copy Markdown
Member Author

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 20, 2026
@openshift-ci

openshift-ci Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@ardaguclu: 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 18e7937 into openshift:master Apr 20, 2026
6 checks passed
@ardaguclu
ardaguclu deleted the kms-v2-foundations branch April 20, 2026 12:29
gangwgr added a commit to gangwgr/cluster-kube-apiserver-operator that referenced this pull request Apr 20, 2026
Bumps library-go to include openshift/library-go#2161
(CNTRLPLANE-3237: Add new KMS foundational mechanism in encryption controller)
kaleemsiddiqu pushed a commit to kaleemsiddiqu/cluster-kube-apiserver-operator that referenced this pull request May 18, 2026
Bumps library-go to include openshift/library-go#2161
(CNTRLPLANE-3237: Add new KMS foundational mechanism in encryption controller)
ibihim added a commit to ibihim/library-go that referenced this pull request Jun 10, 2026
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