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 to list PER enabled DCs/Zones #542

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

kishen-v
Copy link
Contributor

@kishen-v kishen-v commented Jan 11, 2024

Fixes: #519

Changes in this PR:

  1. Add support to list PER enabled DCs/Zones, and if the current zone supports PER.
  2. Sort packages/Lines of code alphabetically.
Kishens-MacBook-Pro  bin : per-availability : ᐅ  ./pvsadm get per-availability --instance-id <redacted>
I0111 13:43:43.702835   50978 root.go:50] Using an API key from IBMCLOUD_API_KEY environment variable
I0111 13:43:46.403958   50978 peravailability.go:67] tok04, where the current instance is present does not support PER.
I0111 13:43:46.403998   50978 peravailability.go:72] The following zones/datacenters have support for PER: [dal10 eu-de-1 eu-de-2 mad02 mad04 sao04 wdc06 wdc07]. More information at https://cloud.ibm.com/docs/overview?topic=overview-locations

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 11, 2024
@kishen-v kishen-v force-pushed the per-availability branch 2 times, most recently from f983290 to ef43fbc Compare January 11, 2024 06:53
@kishen-v kishen-v closed this Jan 11, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 11, 2024
@kishen-v kishen-v reopened this Jan 11, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 11, 2024
@mkumatag
Copy link
Member

/cc @dharaneeshvrd

for _, datacenter := range ret.Datacenters {
if datacenter.Capabilities[powerEdgeRouter] {
perEnabledRegions = append(perEnabledRegions, *datacenter.Location.Region)
if pvmclient.Zone == *datacenter.Location.Region {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of checking here, once perEnabledRegions is populated, you can check outside the for loop only once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current design will avoid an additional round of iteration on perEnabledRegions as the membership is validated within the same loop. Hope this is ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes understood, I think the current code looks good to me!

} else {
klog.Infof("%s, where the current instance is present supports PER.", pvmclient.Zone)
}
sort.Strings(perEnabledRegions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason behind the sorting?

Copy link
Contributor Author

@kishen-v kishen-v Jan 11, 2024

Choose a reason for hiding this comment

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

Just for improved readability, where datacenters of the same region stay grouped. 🙂

dal10 eu-de-1 eu-de-2 mad02 mad04 sao04 wdc06 wdc07

@dharaneeshvrd
Copy link
Contributor

/lgtm

@ppc64le-cloud-bot ppc64le-cloud-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 11, 2024
@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishen-v, mkumatag

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

@ppc64le-cloud-bot ppc64le-cloud-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 12, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot merged commit 3bcfa97 into ppc64le-cloud:main Jan 12, 2024
@kishen-v kishen-v deleted the per-availability branch April 16, 2024 03:54
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. 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.

Add command to list regions/zones in account which supports PER
4 participants