feat: add support for OCM role creation - #6046
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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 |
|
Hi @andclt. 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. |
bc4ddf2 to
e72f968
Compare
| // Note: We do NOT perform any cleanup on deletion because OCM roles are | ||
| // singleton resources shared across clusters. Automated deletion could break | ||
| // all clusters using this role. | ||
| if !scope.OCMRoleConfig.DeletionTimestamp.IsZero() { |
There was a problem hiding this comment.
@andclt So how does a customer delete an OCM Role once created?
I think delete of the resource should unlink and delete the OCM Role? Customers will be prompted to recreate it when they try to interact with Cluster Service
There was a problem hiding this comment.
As discussed on Slack, deleting the OCM role when deleting the CR instance is the right approach here since the OCM role deletion won't break running clusters - will fix it.
There was a problem hiding this comment.
I believe the right behavior is to unlink then delete the ocmRole AND provide optional field eg; skipDelete to let the user skip deleting Role just delete CR.
There was a problem hiding this comment.
Also we should have finalizer to handle any error happen during delete
There was a problem hiding this comment.
yes I will re-add the finalizers as well, I removed them because we didn't have an actual ReconcileDelete function.
| // +kubebuilder:default="/" | ||
| Path string `json:"path,omitempty"` | ||
|
|
||
| // ManagedPolicies indicates whether to use AWS-managed policies (true) or customer-managed policies (false). |
There was a problem hiding this comment.
@andclt No need to expose this at this time. We only support customer managed policies on the OCM Role today. We can revisit if/when they move to managed policies.
There was a problem hiding this comment.
sure - fixed in latest commit
| // Path is the IAM path for the OCM role. | ||
| // +optional | ||
| // +kubebuilder:default="/" | ||
| Path string `json:"path,omitempty"` |
There was a problem hiding this comment.
@andclt Can you validate this starts with a /?
There was a problem hiding this comment.
sure - fixed in latest commit
390d95c to
b87fe6d
Compare
serngawy
left a comment
There was a problem hiding this comment.
some comments and please add release note in the PR desc.
| // The final role name will be: {RolePrefix}-OCM-Role-{ExternalID} | ||
| // where ExternalID is the organization's external identifier from OCM. | ||
| // +kubebuilder:validation:Required | ||
| // +kubebuilder:validation:MaxLength:=32 |
There was a problem hiding this comment.
I would make the max 4-6 to avoid long name case
There was a problem hiding this comment.
I initially wanted to keep it consistent with the ROSA CLI (which allows up to 32 chars for all role prefixes), but I see that ROSARoleConfig already limits both AccountRoleConfig and OperatorRoleConfig
prefixes to 4 characters, so I am fine to change it to 4 chars.
|
|
||
| // Path is the IAM path for the OCM role. | ||
| // +optional | ||
| // +kubebuilder:default="/" |
There was a problem hiding this comment.
no need for default as its an option
| OrganizationID string `json:"organizationID,omitempty"` | ||
|
|
||
| // Linked indicates whether the role has been successfully linked to the OCM organization. | ||
| Linked bool `json:"linked,omitempty"` |
There was a problem hiding this comment.
I don't think there is a need to show this flag. We should show error in link condition if we couldn't link it
There was a problem hiding this comment.
Makes sense, the Ready condition already captures whether the role was successfully linked or not.
| WatchFilterValue string | ||
| NewStsClient func(cloud.ScopeUsage, cloud.Session, logger.Wrapper, runtime.Object) stsiface.STSClient | ||
| NewOCMClient func(ctx context.Context, scope caparosa.OCMSecretsRetriever) (caparosa.OCMClient, error) | ||
| Runtime *rosacli.Runtime |
There was a problem hiding this comment.
this need to change as we are moving to cross account creation. The runtime need to be established with the reconciling. check my PR here
| // +kubebuilder:resource:path=ocmroleconfigs,scope=Cluster,categories=cluster-api,shortName=ocmrole | ||
| // +kubebuilder:storageversion | ||
| // +kubebuilder:subresource:status | ||
| type OCMRoleConfig struct { |
There was a problem hiding this comment.
lets name it as ROSAOCMRoleConfig to follow all other ROSA APIs naming. Also for all struct, types and constant let them all start with ROSA
| // Acquire per-organization mutex to prevent concurrent LinkOrgToRole races | ||
| // Multiple OCMRoleConfigs with different AWS accounts can link to the same org, | ||
| // causing read-modify-write races on the org label. Serialize linking per org. | ||
| linkMu := r.getLinkMutex(orgID) |
There was a problem hiding this comment.
can you elaborate more why this is needed ? how this statement " Multiple OCMRoleConfigs with different AWS accounts can link to the same org" could happen ? I think it should be; first role linked wine others will raise error cannot link.
There was a problem hiding this comment.
The OCM Role is used to link an OCM Org to the AWS Account(s) that they use for cluster provisioning. An OCM org can use many AWS accounts, so it should be possible to link an OCM Role as long as there is not one already linked for the same AWS account.
There was a problem hiding this comment.
This is the same functionality as offered today by the CLI in rosa create ocm-role
There was a problem hiding this comment.
Yes, as Rob said, we can have multiple AWS accounts associated to the same OCM organization by defining multiple OCMRoleConfig with different IdentityRef.
| // Note: We do NOT perform any cleanup on deletion because OCM roles are | ||
| // singleton resources shared across clusters. Automated deletion could break | ||
| // all clusters using this role. | ||
| if !scope.OCMRoleConfig.DeletionTimestamp.IsZero() { |
There was a problem hiding this comment.
I believe the right behavior is to unlink then delete the ocmRole AND provide optional field eg; skipDelete to let the user skip deleting Role just delete CR.
| // Note: We do NOT perform any cleanup on deletion because OCM roles are | ||
| // singleton resources shared across clusters. Automated deletion could break | ||
| // all clusters using this role. | ||
| if !scope.OCMRoleConfig.DeletionTimestamp.IsZero() { |
There was a problem hiding this comment.
Also we should have finalizer to handle any error happen during delete
@serngawy, could you share more about the optional field use case? What's the scenario where someone wants to delete the CR but keep the IAM role? |
b87fe6d to
6cfa3c3
Compare
|
Closing in favor of: #6055 |
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
AI Usage:
Checklist:
Release note: