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

feat(HMS-2255): launch to location of the resource group by default #730

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

ezr-ondrej
Copy link
Member

@ezr-ondrej ezr-ondrej commented Oct 18, 2023

We should allow users to follow Azure default and use the resource group location by default.

This PR also makes the default Resource Group the image resource group.

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from 5082f94 to e7342e6 Compare October 18, 2023 17:41
@ezr-ondrej
Copy link
Member Author

/retest

@lzap
Copy link
Member

lzap commented Oct 19, 2023

Failed: response not updated with instances

Maybe we need to update a test - images are now being launched in the location of the resource group rather than some hardcoded default, @akhil-jha

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from e7342e6 to dae1c21 Compare October 19, 2023 13:48
@akhil-jha
Copy link
Member

Failed: response not updated with instances

Maybe we need to update a test - images are now being launched in the location of the resource group rather than some hardcoded default, @akhil-jha

Probably true.
I'll look at it tomorrow.

@ezr-ondrej
Copy link
Member Author

/retest

lets try once more for good luck 🤷

@lzap
Copy link
Member

lzap commented Oct 19, 2023

Not your day: Failed: response not updated with instances

@ezr-ondrej
Copy link
Member Author

Ah, with so many failures in the pipeline, I've just not stopped to think that it might be a regression 🤦

"InvalidResourceLocation\",\n    \"message\": \"The specified location 'eastus_1' is invalid. A location must consist of characters, whitespace, digit, or following symbols

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from dae1c21 to 6231399 Compare October 20, 2023 09:09
@@ -147,9 +149,10 @@ func CreateAzureReservation(w http.ResponseWriter, r *http.Request) {
EdgeID: logging.EdgeRequestId(r.Context()),
AccountID: identity.AccountId(r.Context()),
Args: jobs.LaunchInstanceAzureTaskArgs{
// Ignore location for now
//Location: reservation.Detail.Location,
Copy link
Member Author

Choose a reason for hiding this comment

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

We have ignored location previously and always substituted it for eastus, now we're just explicit about it.

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from 6231399 to 128afe2 Compare October 20, 2023 10:51
Comment on lines +41 to +42
if preload.AzureInstanceType.ValidateRegion(payload.Location) {
logger.Warn().Msgf("Azure region passed with location suffix (%s), this is deprecated behaviour format", payload.Location)
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ change for the future, we now validate region, not location.

In the past, we've validated for location, but then actually ignored the param down the line and forced eastus, but we actually need regions, not locations in all the calls (even tho azure calls them Location 🤦)

Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be part of this PR? Also I am not sure if I am following here. Can you explain?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, we required region+zone in the past, but then we dropped the value and used hard coded eastus, so it worked, but our client expects only region (without the zone suffix).

So this patch accepts both, but when user passes the version with suffix, we now warn about it, so we can keep track of how many usages of that there is.

Copy link
Member

Choose a reason for hiding this comment

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

Ok this is fine, if you want to go an extra mile I think you can refactor ValidateRegion to accept variadic string and concatenate by _ because this is exactly how it works for all the clouds.

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's actually dash (-) for EC2 and GCP and underscore _ for Azure 😮‍💨 xD

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from 128afe2 to 83a74e3 Compare October 20, 2023 10:57
@lzap
Copy link
Member

lzap commented Oct 20, 2023

iqe_provisioning_api.exceptions.ApiAttributeError: V1AWSReservationResponseDetail has no attribute 'public_ipv4' at ['['received_data', 'instances', 0, 'detail']']['public_ipv4']

Not related (out of quota).

Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

I am not sure about the terminology. We have the "location" term and then there are "region" and "zone". To me, it looks like "location" is simply "region" and "zone" concatenated into one string, maybe we could adopt this in the codebase.

We need to figure out a good approach, the current proposal simply ditches the location completely, however, it is possible to technically have a VM in a different zone than resource group. Sure, it is not recommended, but it is possible. I would suggest that we keep this possibility at least in the API.

There are some changes I do not understand.

}
return fmt.Sprintf("/resourceGroups/%s/providers/Microsoft.Compute/images/%s", azureUploadRequest.ResourceGroup, uploadOptions.ImageName), nil
return azureUploadRequest.ResourceGroup, uploadOptions.ImageName, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Multiple return values (except error) typically mean we should think about introducing a type. But this is still okay I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was just lazy here, let me know if you insist, I agree struct would work better here 🤔

type AzureResourceGroup struct {
ID string
Name string
Location string
Copy link
Member

Choose a reason for hiding this comment

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

You removed bunch of locations to region, shall we remove this one as well?

Copy link
Member Author

@ezr-ondrej ezr-ondrej Oct 20, 2023

Choose a reason for hiding this comment

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

I went back on the decision, lets keep Location, but explain it's region, not region with availability zone, as it souns like it the first look. I've added more description in the OpenAPI spec.

internal/jobs/launch_instance_azure.go Show resolved Hide resolved
Comment on lines +41 to +42
if preload.AzureInstanceType.ValidateRegion(payload.Location) {
logger.Warn().Msgf("Azure region passed with location suffix (%s), this is deprecated behaviour format", payload.Location)
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be part of this PR? Also I am not sure if I am following here. Can you explain?

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch 2 times, most recently from e843775 to f1a09be Compare October 20, 2023 14:33
Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

All right, needs rebase tho.

@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch 2 times, most recently from e5d2cce to 1a34c67 Compare October 23, 2023 14:46
We should allow users to follow Azure default and use the resource group location by default.
@ezr-ondrej ezr-ondrej force-pushed the default_azure_location branch from 1a34c67 to 008fded Compare October 23, 2023 14:53
@ezr-ondrej
Copy link
Member Author

Rebased and all 🍏

@lzap lzap merged commit f26e2b5 into RHEnVision:main Oct 24, 2023
@lzap
Copy link
Member

lzap commented Oct 24, 2023

Okay, thanks a bunch for working on this.

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.

3 participants