馃悰 Fix ParseSecretName round-trip for purposes containing hyphens - #14040
馃悰 Fix ParseSecretName round-trip for purposes containing hyphens#14040kiarashazarnia wants to merge 1 commit into
Conversation
Replace LastIndex-based split with suffix matching against
allSecretPurposes, so that APIServerEtcdClient ("apiserver-etcd-client")
round-trips correctly with Name/ParseSecretName.
Add TestParseSecretName_RoundTrip covering all purpose values.
|
Welcome @kiarashazarnia! |
|
Hi @kiarashazarnia. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
/kind bug
/area bootstrap
/sig cluster-lifecycle
What this PR does / why we need it:
Some Cluster API secrets were being silently dropped during
clusterctl move, causing the move graph to miss real resources. The cause isParseSecretNamefailing on theAPIServerEtcdClientpurpose because it splits the secret name at the last hyphen and the trailing segment is not a valid purpose.The fix replaces the
LastIndexsplit with suffix-based matching againstallSecretPurposes, mirroringHasPurposeSuffixinconsts.go.Which issue(s) this PR fixes:
Suggested Release Note"
Reviewer notes:
ParseSecretNameis also called fromutil/kubeconfig/kubeconfig.go:193, but that path only handlesKubeconfigsecrets, so it never hit the bug.TestParseSecretName_RoundTrip's twoAPIServerEtcdClientcases ("cluster-apiserver-etcd-client"and"my-cluster-apiserver-etcd-client") returned an error because the last-hyphen split extracted"client"instead of"apiserver-etcd-client". After the fix, both parse correctly as(cluster_name, APIServerEtcdClient).