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

PowerVS: Add an only IPI regions list #10

Closed
wants to merge 1 commit into from

Conversation

hamzy
Copy link
Contributor

@hamzy hamzy commented Feb 7, 2024

In order for the IPI installer to be able to use this module, it needs the ability to have the list of regions to only include supported regions.

@ppc64le-cloud-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hamzy
Once this PR has been reviewed and has the lgtm label, please assign mkumatag for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 7, 2024
@hamzy
Copy link
Contributor Author

hamzy commented Feb 7, 2024

@mkumatag How about this version?

In order for the IPI installer to be able to use this module, it needs the ability to have the list of regions to only include supported regions.
@hamzy hamzy force-pushed the PowerVS-Only-support-PER2 branch from 800109f to bbd3d40 Compare February 7, 2024 15:02
Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

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

I'm little uncomfortable overriding the variables like Regions, wondering if there any better way to deal with this? may be a better implementation of this utility itself! 🤔

Any idea will be appreciated @Karthik-K-N @dharaneeshvrd

Copy link
Contributor

@dharaneeshvrd dharaneeshvrd left a comment

Choose a reason for hiding this comment

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

Overall, a bit of refactoring required, added my comments!

}

// Regions provides a mapping between Power VS and IBM Cloud VPC and IBM COS regions.
var Regions = map[string]Region{
var Regions = FullRegions
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to do like this? Any reason behind this?
IMHO, we can use the existing map itself with the addition of IPISupported field on each region.

},
}

var IPIRegions = map[string]Region{}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems unused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used. Have you searched the code?

var Regions = FullRegions

// Switch the list of regions to all of the regions.
func UseFullRegions () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required IMO, if we just modify the existing Regions map itself.

}

// Switch the list of regions to only the regions supported by the IPI installer.
func UseIPIRegions () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func UseIPIRegions () {
func GetIPIRegions () map[string]Region {

This can be used to filter the IPI regions alone and return it.

}
}

Regions = IPIRegions
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Regions = IPIRegions
return IPIRegions

@hamzy
Copy link
Contributor Author

hamzy commented Feb 8, 2024

@dharaneeshvrd The reason why I do it this way is so the user can switch between the two lists at any time.

@mkumatag The other way I see to implement this is to alter every API call to add an additional parameter to indicate that only IPI is requested. This would require everyone to change and therefore be unacceptable. Feel free to submit a PR for code you don't have a problem with.

It seems to me that this is a situation where the approver does not work on the IPI project and therefore does not feel the constant pain of having to implement new zones and/or regions.

@mjturek
Copy link

mjturek commented Feb 8, 2024

Does adding the parameter really mean we'll need to expose it in every API call? Another option is a function that returns a list of keys into the Region list (dal, wdc, mad, etc)

@hamzy
Copy link
Contributor Author

hamzy commented Feb 8, 2024

AFAIK Go does not have a default parameter. I don't even think you can have two different functions with the same name but different number of parameters.

@dharaneeshvrd
Copy link
Contributor

@hamzy I understood what you are trying to do now. The changes will work.
But I am also not that comfortable with overriding variables and creating another instance of map[string]Region.

Please see below approach will work!
With your current design also we need to call UseIPIRegions() to map IPIRegions to Regions var.
How about using some kind of env var to decide on each func to look for IPISupported field.
So we don't need to alter func params and like calling UseIPIRegions() one time, we can set the env var.
With above approach we can avoid the overriding and creating new map.

Another suggestion is if IPI is the major consumer of this utility pkg, then we can keep that env as default to IPIRegions and other consumers like hypershift can keep that env var to false and use it.

@hamzy
Copy link
Contributor Author

hamzy commented Feb 9, 2024

@dharaneeshvrd So you would rather change 11 functions, and all future functions, than one list? Would you agree that this way is more maximally invasive than the previous way?

@dharaneeshvrd
Copy link
Contributor

Agree, it's a lot of change. I think current implementation looks good to me!

@hamzy hamzy closed this Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants