feat(runtime): Validate cross-namespace secret refs in SecretValueFromReference#254
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sapphirew 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 |
0eef61d to
c78f739
Compare
| return "", ackerr.NewTerminalError(err) | ||
| } | ||
| if isCrossNamespace { | ||
| r.log.V(0).Info( |
There was a problem hiding this comment.
Do we need to also apply a condition to the resource similar to FieldExports and ResourceReferences? If yes, we may need to change the function signature. We'd still need to manually update the SecretValueFromReference calls in custom code, but at least they'd fail loudly.
…mReference Move cross-namespace validation for secret references into SecretValueFromReference so every caller is covered, including custom update functions (e.g. RDS db_cluster/custom_update.go) and hooks that call it directly rather than going through generated sdk.go code. - When --enable-cross-namespace is false and the secret targets a different namespace, return a terminal error (wrapping the ResourceReferenceCrossNamespaceNotAllowed sentinel). The caller's existing condition machinery sets ACK.Terminal from the message. - When the flag is true, log a deprecation warning, resolve the secret from the target namespace, and set the ACK.CrossNamespaceOptInRequired condition on the resource being reconciled. Because SecretValueFromReference does not receive the resource handle, the reconciler stashes the resource (a ConditionManager) in the context via WithConditionManager; SecretValueFromReference retrieves it with ConditionManagerFromContext and sets the condition through SetCrossNamespaceOptInRequiredOnSubject. The condition is set on the desired resource before sdkCreate/sdkUpdate deep-copies it into the returned object, so it persists to the status patch. Passing no ConditionManager is safe (the condition is simply skipped). This lets the code-generator drop the per-call secret validation block it currently emits in set_sdk.go, which only covered generated sdk.go call sites. Addresses review feedback on aws-controllers-k8s/code-generator#699.
c78f739 to
a8e6efc
Compare
Issue #, if available:
Description of changes:
Move cross-namespace validation for secret references into SecretValueFromReference so every caller is covered, including custom update functions (e.g. RDS db_cluster/custom_update.go) and hooks that call it directly rather than going through generated sdk.go code.
This lets the code-generator drop the per-call secret validation block it currently emits in set_sdk.go, which only covered generated sdk.go call sites.
Addresses review feedback on aws-controllers-k8s/code-generator#699.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.