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 2 times, most recently 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

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

@richardcase
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: richardcase

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2025
@k8s-ci-robot k8s-ci-robot merged commit 8607e3a into kubernetes-sigs:main Sep 30, 2025
18 checks passed
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-api-provider-aws that referenced this pull request Oct 2, 2025
* Add RosaRoleConfig API and CRD.

* Enable partial reconcile of Rosa Operator Roles

* Review fixes

* Add integration tests

* Add more tests

* Fix comments

Signed-off-by: serngawy <[email protected]>

---------

Signed-off-by: serngawy <[email protected]>
Co-authored-by: rknaur <[email protected]>
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-api-provider-aws that referenced this pull request Oct 2, 2025
* Add RosaRoleConfig API and CRD.

* Enable partial reconcile of Rosa Operator Roles

* Review fixes

* Add integration tests

* Add more tests

* Fix comments

Signed-off-by: serngawy <[email protected]>

---------

Signed-off-by: serngawy <[email protected]>
Co-authored-by: rknaur <[email protected]>
@serngawy
Copy link
Contributor Author

serngawy commented Oct 6, 2025

/cherry-pick release-2.9

@k8s-infra-cherrypick-robot

@serngawy: #5667 failed to apply on top of branch "release-2.9":

Applying: Add RosaRoleConfig API and CRD.
Using index info to reconstruct a base tree...
M	config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml
M	config/rbac/role.yaml
M	controlplane/rosa/controllers/rosacontrolplane_controller.go
M	go.mod
M	go.sum
M	pkg/rosa/ocmclient.go
M	test/mocks/ocm_client_mock.go
Falling back to patching base and 3-way merge...
Auto-merging test/mocks/ocm_client_mock.go
CONFLICT (content): Merge conflict in test/mocks/ocm_client_mock.go
Auto-merging pkg/rosa/ocmclient.go
CONFLICT (content): Merge conflict in pkg/rosa/ocmclient.go
Auto-merging go.sum
Auto-merging go.mod
Auto-merging controlplane/rosa/controllers/rosacontrolplane_controller.go
Auto-merging config/rbac/role.yaml
CONFLICT (content): Merge conflict in config/rbac/role.yaml
Auto-merging config/crd/bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Add RosaRoleConfig API and CRD.

In response to this:

/cherry-pick release-2.9

Instructions 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.

@serngawy
Copy link
Contributor Author

serngawy commented Oct 7, 2025

/cherry-pick release-2.9

@k8s-infra-cherrypick-robot

@serngawy: new pull request created: #5696

In response to this:

/cherry-pick release-2.9

Instructions 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.

serngawy added a commit to stolostron/cluster-api-provider-aws that referenced this pull request Oct 10, 2025
* Add RosaRoleConfig API and CRD.

* Enable partial reconcile of Rosa Operator Roles

* Review fixes

* Add integration tests

* Add more tests

* Fix comments

Signed-off-by: serngawy <[email protected]>

---------

Signed-off-by: serngawy <[email protected]>
Co-authored-by: rknaur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

7 participants