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

support for other Azure cloud environments #3634

Merged

Conversation

staebler
Copy link
Contributor

Add the azure.cloudName field to the installconfig. This field directs which Azure cloud environment is used for the cluster.

The status.platformStatus.azure.cloudName field is set in the infrastructure.config.openshift.io resource to match the cloud name configured in the installconfig.

The cloud field is set in the cloud-provider-config ConfigMap to match the cloud name configured in the installconfig.

Use the cloud name specified in the installconfig to have the installer, destroyer, and terraform connect to the correct Azure cloud environment.

See openshift/enhancements#321

https://issues.redhat.com/browse/CORS-1442

@staebler
Copy link
Contributor Author

/hold

This is currently vendoring an openshift/api fork until openshift/api#650 merges.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 20, 2020
@staebler staebler force-pushed the azure_other_cloud_env branch 3 times, most recently from f5e3051 to 790b4cb Compare May 20, 2020 19:39
@staebler
Copy link
Contributor Author

/test e2e-azure

Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

I had a chance to read through this and it looks really good. Left a few suggestions in case they are helpful.

@@ -105,8 +108,8 @@ func getRegions() (map[string]string, error) {
return allLocations, nil
}

func getResourceCapableRegions() ([]string, error) {
client, err := NewClient(context.TODO())
func getResourceCapableRegions(cloudName azure.CloudEnvironment) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make more sense for these (getRegions and getResourceCapableRegions) to live in the azure client API. In general I think anything that uses a client should follow this pattern, but I'm not very familiar with the Azure code.

Moving it to the API interface would allow mocking and testing these functions. You didn't create these functions so just a suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not agree that the functions make more sense as part of the client API. The functions rely on making calls to the client API and formatting the results in ways specific to what is needed by the Azure Platform. I do, however, take your point that it would be good to be able to mock and test the functions. So, in that vein, I will change the functions to take a client as a parameter rather than creating a client inside the function.

pkg/types/azure/platform.go Show resolved Hide resolved
@@ -23,7 +26,7 @@ func (params CloudProviderConfig) JSON() (string, error) {
resourceGroupName := params.ResourcePrefix + "-rg"
config := config{
authConfig: authConfig{
Cloud: "AzurePublicCloud",
Cloud: string(params.CloudName),
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm I dislike casting or type conversion in general but I don't think there's anyway around this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could add a function like the following.

// Environment returns name that Azure uses for the cloud environment.
// See https://github.com/Azure/go-autorest/blob/ec5f4903f77ed9927ac95b19ab8e44ada64c1356/autorest/azure/environments.go#L13
func (e CloudEnvironment) Name() string {
	return string(e)
}

That would push the casting to a location closer to where the enum is defined. I don't know of any precedence for this approach, though.

Suggested change
Cloud: string(params.CloudName),
Cloud: params.CloudName.Name(),

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2020
@staebler
Copy link
Contributor Author

staebler commented Jun 2, 2020

/hold

This is currently vendoring an openshift/api fork until openshift/api#650 merges.

/hold cancel

The PR has been updated to vendor the latest from openshift/api.

The initial code review feedback has been addressed.

/cc @jhixson74

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 2, 2020
@jhixson74
Copy link
Member

/approve
/lgtm

@jhixson74
Copy link
Member

/test e2e-azure

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2020
@abhinavdahiya
Copy link
Contributor

/test e2e-azure

Add the `azure.cloudName` field to the installconfig. This field
directs which Azure cloud environment is used for the cluster.

The `status.platformStatus.azure.cloudName` field is set in the
infrastructure.config.openshift.io resource to match the cloud name
configured in the installconfig.

The `cloud` field is set in the cloud-provider-config ConfigMap
to match the cloud name configured in the installconfig.

See openshift/enhancements#321

https://issues.redhat.com/browse/CORS-1442
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 3, 2020
@staebler
Copy link
Contributor Author

staebler commented Jun 3, 2020

020e32c...0af108c

  • Moved code for determining the Azure environment for terraform into pkg/tfvars/azure.
  • Squashed commits.

Use the cloud name specified in the installconfig to have the installer,
destroyer, and terraform connect to the correct Azure cloud environment.

https://issues.redhat.com/browse/CORS-1442
Bump to the latest github.com/openshift/api version in order to
pick up changes to the infrastructure.config.openshift.io type
for supporting other Azure cloud environments.

Changes from openshift/api#650.

https://issues.redhat.com/browse/CORS-1442
@staebler
Copy link
Contributor Author

staebler commented Jun 3, 2020

/test e2e-azure

@abhinavdahiya
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, jhixson74

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 4, 2020
@jhixson74
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 8, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit e513bbb into openshift:master Jun 8, 2020
staebler added a commit to staebler/installer that referenced this pull request Jul 22, 2020
When support for other Azure cloud environments was added [1],
there were some necessary changes that were omitted.

* Azure clients that are created need to use the base URI
appropriate for the cloud environment.
* Azure authorizers need to use the ActiveDirectory endpoint
appropriate for the cloud environment.
* The environment needs to be specified for the terraform
azureprivatedns provider.

[1] openshift#3634
staebler added a commit to staebler/installer that referenced this pull request Jul 22, 2020
When support for other Azure cloud environments was added [1],
there were some necessary changes that were omitted.

* Azure clients that are created need to use the base URI
appropriate for the cloud environment.
* Azure authorizers need to use the ActiveDirectory endpoint
appropriate for the cloud environment.
* The environment needs to be specified for the terraform
azureprivatedns provider.

[1] openshift#3634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants