Skip to content
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

Add support for Subscription creation in ASO #2446

Merged
merged 7 commits into from
Aug 15, 2022

Conversation

matthchr
Copy link
Member

@matthchr matthchr commented Aug 11, 2022

This resource is a bit wonky/tricky and as such required a few hooks to customize its reconciliation behavior from what the default is.

The underlying API is that creating a subscription requires creating an Alias. That Alias is not the subscription itself, just a mechanism to produce a new one. Unfortunately the Alias cannot have RoleAssignments or other things put on it once it's created, that must be done on the subscription itself.

In order to manage this resource in ASO we combine the two concepts into a single one: subscription.Alias. Deleting the Alias causes the subscription to be cancelled. A subscription cannot be cancelled if it has resources (delete will fail with an error). A subscription that is cancelled will be deleted 90 days later (or can be manually deleted after 3 days).

Blocked until

How does this PR make you feel:
gif

If applicable:

  • this PR contains documentation
  • this PR contains tests

Copy link
Member

@theunrepentantgeek theunrepentantgeek left a comment

Choose a reason for hiding this comment

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

I think I need to read through this again to see how it works, but my first pass looks good, just a trio of comments.

case ResourceHierarchyRootTenant:
// The only resource we actually care about for figuring out resource types is the
// most derived resource
res := h[len(h)-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

could this run into indexOutOfBounds if len==0?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, makes sense .. it panics in rootKind method if len==0

Copy link
Member Author

Choose a reason for hiding this comment

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

It could, yes. There are other places where we explicitly panic on len==0, but basically a ResourceHierarchy is expected to be at least length = 1. Moreover, these are created by functions we control and they always have at least the resource being deployed in them, so there's no way in practice to end up with 1 that's length = 0.

Good question though.

@matthchr matthchr force-pushed the feature/subscriptions branch from 7fbf05a to c0f83fd Compare August 12, 2022 17:10
@matthchr
Copy link
Member Author

/ok-to-test sha=c0f83fd

@matthchr matthchr force-pushed the feature/subscriptions branch from c0f83fd to daa372b Compare August 13, 2022 01:46
@matthchr
Copy link
Member Author

/ok-to-test sha=daa372b

@matthchr
Copy link
Member Author

/ok-to-test sha=bfc2610

@matthchr
Copy link
Member Author

/ok-to-test sha=d5f6faa

@matthchr
Copy link
Member Author

/ok-to-test sha=32bfbfb

1 similar comment
@matthchr
Copy link
Member Author

/ok-to-test sha=32bfbfb

@matthchr matthchr merged commit d775609 into Azure:main Aug 15, 2022
@matthchr matthchr deleted the feature/subscriptions branch August 15, 2022 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants