kms: clean up and improve autokey config identity and deletion resolution - #9658
Merged
gemmahou merged 1 commit intoJul 13, 2026
Merged
Conversation
Contributor
Author
|
/assign @gemmahou |
gemmahou
reviewed
Jun 12, 2026
iamkonohamaru
force-pushed
the
kms-autokey-cleanups
branch
from
July 13, 2026 06:47
c19f0d5 to
55e7b93
Compare
gemmahou
approved these changes
Jul 13, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gemmahou The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Merged
via the queue into
GoogleCloudPlatform:master
with commit Jul 13, 2026
de03df6
203 of 392 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR cleans up and improves the identity resolution and deletion logic for the KMSAutokeyConfig resource to handle edge cases where referenced projects or folders have already been deleted.
Key Changes
Identity Resolution (apis/kms/v1beta1/autokeyconfig_identity.go):
Updated NewAutokeyConfigIdentity to parse Status.ExternalRef first if it is present.
Validates the Spec references (folderRef or projectRef) against the parsed identity without executing Kubernetes reference resolution. This prevents Delete reconciles from blocking when the parent project/folder has already been deleted.
Added comprehensive unit tests in apis/kms/v1beta1/autokeyconfig_identity_test.go covering all combinations of externalRef and Spec inputs.
Controller Cleanups (pkg/controller/direct/kms/autokeyconfig/autokeyconfig_controller.go):
Reference Resolution: Moved the resolution of keyProjectRef from AdapterForObject down to the Update method. This prevents resolution failures from blocking other operations like Delete.
Deletion Logic:
Updated Delete to return success immediately (return true, nil) if the resource is already UNINITIALIZED on GCP, skipping the rest of the code.
Handled NOT_FOUND errors during the update call in Delete (e.g., if the parent project/folder was already deleted in GCP), treating them as successful deletions.
Adapter Struct: Removed the unused desiredKeyProject field and stored the reader client.Reader to perform reference resolution inside Update.
Redundant Checks: Removed the unnecessary if a.actual == nil check in updateAutokeyConfig.
Schema Compatibility Cleanups:
Deleted the stale exception file tests/apichecks/testdata/exceptions/multi_version_crd_diff/KMSAutokeyConfig.diff. The schemas for v1alpha1 and v1beta1 are now fully identical, and the TestMultiVersionCRDNoDiff schema test passes.