Skip to content

feat(cli): create managed identities#4660

Draft
komidore64 wants to merge 4 commits intomasterfrom
adprice/aro-6445-create-identities
Draft

feat(cli): create managed identities#4660
komidore64 wants to merge 4 commits intomasterfrom
adprice/aro-6445-create-identities

Conversation

@komidore64
Copy link
Copy Markdown
Collaborator

Which issue this PR addresses:

Fixes https://issues.redhat.com/browse/ARO-6445

What this PR does / why we need it:

az aro identity create-required creates all necessary identities and role assignments to facilitate creation of a Managed-Identity OpenShift Cluster.

Test plan for issue:

There are little (or no) tests for our ARO CLI extension at the moment. Building tests are a separate work ticket (ARO-8293).

Is there any documentation that needs to be updated for this PR?

Not that I'm aware.

How do you know this will function as expected in production?

This is new CLI functionality that interacts with existing APIs.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 6, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Copy Markdown
Member

@cadenmarchese cadenmarchese left a comment

Choose a reason for hiding this comment

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

nice work, things are working for me locally. I think at this point it's mostly just idempotence and DRY needed. thanks!

vnet,
vnet_resource_group_name=None) -> list:

# FIXME: figure out how to do the fancy "in progress" spinner
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively, can we have the CLI print what it's doing during each creation? Something like Creating identity "cloud-controller-manager" in resource group "caden-miwi" for version "4.19.20" and etc...


# vnet/subnet role assignments
for scope in scopes:
ra = racreate(command_args={
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While we can't directly modify the aaz itself, we'll need some kind of "check if this already exists" behavior implemented here before we execute the create so that we can run this command idempotently. In its current state, if I delete a previously created identity and re-run this command, I will get an "already exists" error because there's a leftover orphaned role assignment:

(RoleAssignmentExists) The role assignment already exists.
Code: RoleAssignmentExists
Message: The role assignment already exists.

Fixing this will account for cases where a role assignment or identity failed to create and the customer needs to re-run. It's a bit tedious removing role assignments manually and most customers won't have the option to remove and re-create the whole resource group every time.

racreate = roleassignment_create(cli_ctx=cmd.cli_ctx)

# cluster top-level identity
cluster_id = idcreate(command_args={
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Before we execute any creation, should we prompt the user Y/n like we do on cluster deletion? (I don't have a strong opinion since we don't do it on cluster create, but it might be nice here)

Required identities and role assignments for version "4.19.20" in resource group "caden-miwi" will be created. Proceed? (Y/n)

)


def aro_identity_create_required(*,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Most of this function is duplicated from our previous command get-required. Can we move the duplicated code to a separate function where we can call it both here and in get-required?

@@ -0,0 +1,43 @@
# ARO-RP/python
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the readme!

We also have this one: https://github.com/Azure/ARO-RP/blob/master/docs/az-aro-python-development.md should we consolidate them?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should. I remembered that az-aro-python-development.md existed after I started this one. I have changes in my working tree to consolidate them.

Azure CLI recommends using `logger.<severity>()` instead of `print()`.
.. between aro_identity_get_required and aro_identity_create_required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants