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

Dynamic validation of "EncryptionAtHost" feature subscription level registration at the RP. #3134

Closed

Conversation

schiruma
Copy link
Contributor

@schiruma schiruma commented Aug 31, 2023

Which issue this PR addresses:

ARO-3211

What this PR does / why we need it:

When customers are attempting to set EncryptionAtHost, but that feature is not enabled for their Subscriptions, an error message describing about the issue and its resolution is displayed to them. This is achieved by dynamically validating their Subscription in the RP's frontend.

Test plan for issue:

E2E

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

N/A

@schiruma schiruma changed the title frontend validation of subscription level registrations at the RP Dynamic validation of "EncryptionAtHost" feature subscription level registration at the RP. Aug 31, 2023
@schiruma schiruma added the loki label Aug 31, 2023
@schiruma schiruma marked this pull request as ready for review August 31, 2023 20:18
@SudoBrendan SudoBrendan added ready-for-review go Pull requests that update Go code labels Aug 31, 2023
Copy link
Collaborator

@SudoBrendan SudoBrendan left a comment

Choose a reason for hiding this comment

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

As we talked about in review - this code looks great! I agree with Tanmay's comments. In addition, I'm going to put a hold on this until we have the production permissions changes in place required to make these feature API calls. Nice work!

@SudoBrendan SudoBrendan added the hold Hold label Aug 31, 2023
@github-actions
Copy link

Please rebase pull request.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Aug 31, 2023
@schiruma schiruma force-pushed the frontend-validation-encryptionathost branch from 3010637 to 5641826 Compare September 1, 2023 00:07
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 1, 2023
@schiruma schiruma force-pushed the frontend-validation-encryptionathost branch from 5641826 to 44c5b04 Compare September 1, 2023 00:09
@schiruma schiruma requested a review from SudoBrendan September 1, 2023 19:12
tsatam
tsatam previously approved these changes Sep 1, 2023
@schiruma schiruma force-pushed the frontend-validation-encryptionathost branch from 229927d to 0e64115 Compare September 7, 2023 21:01
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 7, 2023
@schiruma schiruma requested a review from tsatam September 11, 2023 20:33
@schiruma schiruma force-pushed the frontend-validation-encryptionathost branch from 0e64115 to 83423f2 Compare September 11, 2023 20:41
@github-actions
Copy link

Please rebase pull request.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Sep 12, 2023
@schiruma schiruma force-pushed the frontend-validation-encryptionathost branch from 83423f2 to 8af04f1 Compare September 13, 2023 20:10
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Sep 13, 2023
Copy link
Collaborator

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

The validation code looks good to me, I'd just make sure we have an approval from @kimorris27 before proceeding since it makes a change to the vendored azidentity.

Copy link
Contributor

@kimorris27 kimorris27 left a comment

Choose a reason for hiding this comment

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

The validation logic looks good! I requested small changes in a few different places. Let me know if I can further clarify any of those comments.

if err != nil {
return err
}
if *response.Properties.State == armfeatures.SubscriptionFeatureRegistrationStateRegistered {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure we don't get any surprise nil pointer dereferences, let's check for nil pointers as needed before evaluating *response.Properties.State.

Copy link
Contributor Author

@schiruma schiruma Sep 15, 2023

Choose a reason for hiding this comment

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

@kimorris27, In the new commit, since we are returning nil by default it shouldn't cause any nil pointer dereferences. Let me know your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you flipped the conditional in response to @cadenmarchese 's comment, but that won't stop us from potentially encountering a nil pointer dereference here. I would still check for nil pointers before trying if *response.Properties.State ....

Copy link
Contributor

@kimorris27 kimorris27 left a comment

Choose a reason for hiding this comment

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

Looking good, but I hadn't noticed when I looked last week that you had imported the subscription features client from azure-sdk-for-go's sdk package. My requested change is to import the client from the services package, which I gave a link to in the more detailed comment.


"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures"
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than importing the client from the sdk package, I think we should use the one from the services package (even though it's currently deprecated) to be consistent with the rest of the Azure clients: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go@v63.1.0+incompatible/services/resources/mgmt/2021-07-01/features#SubscriptionFeatureRegistrationsClient.

Aside from keeping things consistent throughout the azureclient package, this will help make sure that we pass all of the correct options when instantiating the client in NewSubscriptionFeatureRegistrationsClient. For example, each Azure client needs a base URI telling it which Azure cloud it's working in (public, US Gov, German, etc.). (There may be other important settings, but this is just one that I noticed needs to be set.) It looks like on the clients from the sdk package, you could control these sorts of settings through the last argument (ClientOptions, I think?), but this PR as written wouldn't work in any cloud other than the public cloud, since the public cloud is the default and we're passing nil to that options argument.

For now, we can mimic how the other clients do things to make sure we do these types of things correctly. I think this will also allow you to pass an autorest.Authorizer rather a client certificate credential, which is another way to be consistent with the other clients.

For an example of what I'm talking about, see:

Copy link
Collaborator

Choose a reason for hiding this comment

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

As part of the track2 migration (which we haven't started but at some point will), we will move over clients one-by-one to the new track2. I would prefer any net-new work uses the newer track2 sdk package.

Otherwise we're going to come back to this and "reimplement" it using the newer track2 sdk.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense. In that case, the only change needed here is to make sure that when the client gets instantiated, we pass options to make sure it uses the correct cloud, etc.

Copy link
Contributor Author

@schiruma schiruma Sep 18, 2023

Choose a reason for hiding this comment

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

@bennerv thank you for this context as it will make sense to anyone looking at this code going forward.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Oct 11, 2023
@github-actions
Copy link

Please rebase pull request.

@cblecker cblecker added needs-rebase branch needs a rebase and removed needs-rebase branch needs a rebase ready-for-review labels Oct 15, 2023
@SudoBrendan
Copy link
Collaborator

Closing this and moving to an updated branch in #3826

@SudoBrendan SudoBrendan closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code hold Hold loki needs-rebase branch needs a rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants