-
Notifications
You must be signed in to change notification settings - Fork 627
✨ Rosa roles config implementations #5667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
✨ Rosa roles config implementations #5667
Conversation
d9ab817
to
ae8dbe6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
ae8dbe6
to
1fa491b
Compare
bf7d5c6
to
4ae9bc3
Compare
/test pull-cluster-api-provider-aws-test |
/assign @damdo @nrb @richardcase |
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 | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
// UnManaged OIDC Provider type | ||
UnManaged OidcProviderType = "UnManaged" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
err = r.setUpRuntime(ctx, scope) | ||
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err) | ||
} |
There was a problem hiding this comment.
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
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) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
4ae9bc3
to
63d8809
Compare
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
63d8809
to
658a1d2
Compare
/label tide/merge-method-squash |
There was a problem hiding this 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
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
} |
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
} |
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | |
} |
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | |
} |
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 | ||
} |
There was a problem hiding this comment.
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
if err = r.setUpRuntime(ctx, scope); err != nil { | ||
return ctrl.Result{}, fmt.Errorf("failed to set up runtime: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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?
658a1d2
to
c1c0047
Compare
Signed-off-by: serngawy <[email protected]>
Thanks @damdo , fixed all the err inline nil check AND removed the RequeueAfter 60 (just forget remove it with others) |
There was a problem hiding this 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
There was a problem hiding this 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
LGTM label has been added. Git tree hash: d89f75256d7de8148a3dccb2b6a17b1083baef51
|
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:
Release note: