Skip to content

Conversation

serngawy
Copy link
Contributor

@serngawy serngawy commented Sep 15, 2025

This PR is based on PR 5499 fixing all the comments

Based on proposal #5451
Adding RosaRoleConfig API with implementation. that should create account roles, operator roles, OIDC config and OIDC provider necessary to create ROSA HCP cluster.

Moving RosaMachinePoolAutoScaling definition to ROSAControlPlane to avoid circular dependency.

What type of PR is this?
/kind feature

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:

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:

Adding Rosa Role Config API and implementation

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Sep 15, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 15, 2025
@serngawy serngawy mentioned this pull request Sep 15, 2025
4 tasks
@serngawy serngawy force-pushed the rosa-roles-implementations branch 3 times, most recently from d9ab817 to ae8dbe6 Compare September 16, 2025 12:59
Copy link
Contributor

@PanSpagetka PanSpagetka left a comment

Choose a reason for hiding this comment

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

Looks good

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 18, 2025
@serngawy serngawy force-pushed the rosa-roles-implementations branch from ae8dbe6 to 1fa491b Compare September 18, 2025 18:02
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 18, 2025
@serngawy serngawy force-pushed the rosa-roles-implementations branch 2 times, most recently from bf7d5c6 to 4ae9bc3 Compare September 18, 2025 18:17
@serngawy
Copy link
Contributor Author

/test pull-cluster-api-provider-aws-test

@damdo
Copy link
Member

damdo commented Sep 22, 2025

/assign @damdo @nrb @richardcase

Comment on lines 231 to 275
rosaRoleConfig := &expinfrav1.ROSARoleConfig{}
// Get role configuration from either RosaRoleConfig or direct fields
if rosaScope.ControlPlane.Spec.RosaRoleConfigRef != nil {
// Get configuration from RosaRoleConfig

key := client.ObjectKey{
Name: rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name,
Namespace: rosaScope.ControlPlane.Namespace,
}

if err := r.Client.Get(ctx, key, rosaRoleConfig); err != nil {
if apierrors.IsNotFound(err) {
conditions.MarkFalse(rosaScope.ControlPlane,
rosacontrolplanev1.ROSARoleConfigReadyCondition,
rosacontrolplanev1.ROSARoleConfigNotFoundReason,
clusterv1.ConditionSeverityError,
"RosaRoleConfig %s/%s not found", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name)
rosaScope.Error(err, fmt.Sprintf("RosaRoleConfig %s/%s not found: %s", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name, err.Error()))
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
}
rosaScope.Error(err, fmt.Sprintf("failed to get RosaRoleConfig %s/%s: %s", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name, err.Error()))
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
}

// Check if RosaRoleConfig is ready
if !conditions.IsTrue(rosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition) {
conditions.MarkFalse(rosaScope.ControlPlane,
rosacontrolplanev1.ROSARoleConfigReadyCondition,
rosacontrolplanev1.ROSARoleConfigNotReadyReason,
clusterv1.ConditionSeverityWarning,
"RosaRoleConfig %s/%s is not ready", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name)
rosaScope.Error(err, fmt.Sprintf("RosaRoleConfig %s/%s is not ready", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name))

return ctrl.Result{RequeueAfter: time.Second * 60}, nil
}

conditions.MarkTrue(rosaScope.ControlPlane, rosacontrolplanev1.ROSARoleConfigReadyCondition)
} else {
rosaRoleConfig.Status.OIDCID = rosaScope.ControlPlane.Spec.OIDCID
rosaRoleConfig.Status.AccountRolesRef.InstallerRoleARN = rosaScope.ControlPlane.Spec.InstallerRoleARN
rosaRoleConfig.Status.AccountRolesRef.SupportRoleARN = rosaScope.ControlPlane.Spec.SupportRoleARN
rosaRoleConfig.Status.AccountRolesRef.WorkerRoleARN = rosaScope.ControlPlane.Spec.WorkerRoleARN
rosaRoleConfig.Status.OperatorRolesRef = rosaScope.ControlPlane.Spec.RolesRef
}

Copy link
Member

Choose a reason for hiding this comment

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

I think we could maybe extract this into a specific reconcileRosaRoleConfig function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

clusterv1.ConditionSeverityError,
"RosaRoleConfig %s/%s not found", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name)
rosaScope.Error(err, fmt.Sprintf("RosaRoleConfig %s/%s not found: %s", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name, err.Error()))
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have these RequeueAfter 60s functions all over the place?
Wouldn't erroring normally and retry soon after be ok?

Copy link
Member

Choose a reason for hiding this comment

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

@serngawy These ones are still here I see, any thoughts?

Comment on lines 35 to 36
// UnManaged OIDC Provider type
UnManaged OidcProviderType = "UnManaged"
Copy link
Member

Choose a reason for hiding this comment

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

I think Unmanaged might be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

credentialsSecretRef:
name: rosa-creds-secret
rosaRoleConfigRef:
name: "${CLUSTER_NAME}-role-config" No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

There is a missing EndOfFile here

Comment on lines 119 to 122
err = r.setUpRuntime(ctx, scope)
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner to have all these invocations that only return errors as inlined err checks

Suggested change
err = r.setUpRuntime(ctx, scope)
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}
if err := r.setUpRuntime(ctx, scope); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@serngawy serngawy force-pushed the rosa-roles-implementations branch from 4ae9bc3 to 63d8809 Compare September 23, 2025 21:15
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from nrb. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@serngawy serngawy force-pushed the rosa-roles-implementations branch from 63d8809 to 658a1d2 Compare September 23, 2025 21:25
@damdo
Copy link
Member

damdo commented Sep 25, 2025

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Sep 25, 2025
Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

Thanks for addressing some of my comments, still some things left to be addressed but we are looking good! TY

Comment on lines 138 to 142
err = r.reconcileAccountRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Account Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("account Roles: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err = r.reconcileAccountRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Account Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("account Roles: %w", err)
}
if err := r.reconcileAccountRoles(scope); err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Account Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("account Roles: %w", err)
}

Comment on lines 144 to 148
err = r.reconcileOIDC(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "OIDC Config/provider failure: %v", err)
return ctrl.Result{}, fmt.Errorf("oicd Config: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err = r.reconcileOIDC(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "OIDC Config/provider failure: %v", err)
return ctrl.Result{}, fmt.Errorf("oicd Config: %w", err)
}
if err := r.reconcileOIDC(scope); err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "OIDC Config/provider failure: %v", err)
return ctrl.Result{}, fmt.Errorf("oicd Config: %w", err)
}

Comment on lines 150 to 154
err = r.reconcileOperatorRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Operator Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("operator Roles: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err = r.reconcileOperatorRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Operator Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("operator Roles: %w", err)
}
if err := r.reconcileOperatorRoles(scope); err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigReconciliationFailedReason, clusterv1.ConditionSeverityError, "Operator Roles failure: %v", err)
return ctrl.Result{}, fmt.Errorf("operator Roles: %w", err)
}

Comment on lines 180 to 184
err := r.deleteOperatorRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigDeletionFailedReason, clusterv1.ConditionSeverityError, "Failed to delete operator roles: %v", err)
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err := r.deleteOperatorRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigDeletionFailedReason, clusterv1.ConditionSeverityError, "Failed to delete operator roles: %v", err)
return err
}
if err := r.deleteOperatorRoles(scope); err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigDeletionFailedReason, clusterv1.ConditionSeverityError, "Failed to delete operator roles: %v", err)
return err
}

Comment on lines 186 to 196
err = r.deleteOIDC(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigDeletionFailedReason, clusterv1.ConditionSeverityError, "Failed to delete OIDC provider: %v", err)
return err
}

err = r.deleteAccountRoles(scope)
if err != nil {
conditions.MarkFalse(scope.RosaRoleConfig, expinfrav1.RosaRoleConfigReadyCondition, expinfrav1.RosaRoleConfigDeletionFailedReason, clusterv1.ConditionSeverityError, "Failed to delete account roles: %v", err)
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Also let's add inline nil check for these

Comment on lines 119 to 121
if err = r.setUpRuntime(ctx, scope); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err = r.setUpRuntime(ctx, scope); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}
if err := r.setUpRuntime(ctx, scope); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err)
}

clusterv1.ConditionSeverityError,
"RosaRoleConfig %s/%s not found", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name)
rosaScope.Error(err, fmt.Sprintf("RosaRoleConfig %s/%s not found: %s", rosaScope.ControlPlane.Namespace, rosaScope.ControlPlane.Spec.RosaRoleConfigRef.Name, err.Error()))
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
Copy link
Member

Choose a reason for hiding this comment

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

@serngawy These ones are still here I see, any thoughts?

@serngawy serngawy force-pushed the rosa-roles-implementations branch from 658a1d2 to c1c0047 Compare September 25, 2025 18:14
Signed-off-by: serngawy <[email protected]>
@serngawy
Copy link
Contributor Author

Thanks @damdo , fixed all the err inline nil check AND removed the RequeueAfter 60 (just forget remove it with others)

Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments

Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

/lgtm

Let's see what others think

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 25, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: d89f75256d7de8148a3dccb2b6a17b1083baef51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants