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

[PF-692] Pass workspace bucket zone/region parameter to Leonardo createRuntime… #2441

Closed
wants to merge 7 commits into from

Conversation

wnojopra
Copy link
Contributor

@wnojopra wnojopra commented Apr 9, 2021

In DataBiosphere/leonardo#1933, zone and region parameters were added to createRuntime so Leo can now create instances outside of us-central1. This PR will use the location of the workspace bucket to determine the region to create the instance.

In a future PR I plan to have a UI dropdown that will allow a user to specifically choose the location of their cloud environment (defaulting to their current workspace's bucket location).

I have tested:

  1. Creating a GCE instance with the default us-multiregional bucket.
  2. Creating a cluster with the default us-multiregional bucket.
  3. Creating a GCE instance in a non default location (like australia-southeast1)
  4. Creating a cluster in a non default location (like australia-southeast1)

In all cases I verified that the instance was created in the specified zone:
image

@@ -1,74 +1,77 @@
// Get a { flag: ..., countryName: ... } object representing a google locationType/location input.
// 'flag' will always be defined (even if it's a question mark.
// 'regionDescription' is the same as location when locationType is 'multi-region', or a country name when locationType is 'region'.
// computeZone is generally the 'a' zone for each region, except for those regions where it is not available.
// The choice to use the 'a' zone is arbitrary, choosing 'b' zone would also work.
// The region choice for multi-region locations is arbitrary as well.
export const unknownRegionFlag = '❓'
export const regionInfo = (location, locationType) => {
switch (locationType) {
case 'multi-region':
switch (location) {
Copy link
Contributor

@jdcanas jdcanas Apr 20, 2021

Choose a reason for hiding this comment

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

we have a utility function Utils.switchcase (in utils.js) to clean up the syntax of switches a bit. I know it existed before your changes, but could be nice to clean up. Up to you

@@ -258,10 +261,12 @@ export const NewRuntimeModal = withModalDrawer({ width: 675 })(class NewRuntimeM
const shouldDeleteRuntime = oldRuntime && !this.canUpdateRuntime()
const shouldCreateRuntime = !this.canUpdateRuntime() && newRuntime
const { name, bucketName, googleProject } = this.getWorkspaceObj()
const { computeZone, clusterRegion } = regionInfo(bucketLocation, bucketLocationType)
Copy link
Contributor

@jdcanas jdcanas Apr 20, 2021

Choose a reason for hiding this comment

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

can we call clusterRegion computeRegion for consistency? (comment applies to region-common.js too)

@@ -487,13 +499,17 @@ export const NewRuntimeModal = withModalDrawer({ width: 675 })(class NewRuntimeM
currentPersistentDisk ? Ajax().Disks.disk(currentPersistentDisk.googleProject, currentPersistentDisk.name).details() : null
])

const { location, locationType } = await Ajax().Workspaces.workspace(namespace, workspaceName).checkBucketLocation(bucketName)
Copy link
Contributor

@jdcanas jdcanas Apr 20, 2021

Choose a reason for hiding this comment

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

we may want to provide a default here in case the remote call fails (google down-time, etc), otherwise there will be some errors that cascade (thinking about the failure mode of this line in particular const { computeZone, clusterRegion } = regionInfo(bucketLocation, bucketLocationType). Unlikely that the app would actually work in the proposed scenario, but I like guarding against javascript crash scenarios wherever possible...

Copy link
Contributor

@jdcanas jdcanas left a comment

Choose a reason for hiding this comment

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

Played around with it locally and everything passed to leo and in the code looks good. Couple small nits for consistency/redundancy.
Ran the integration tests locally and they were all green, they will not pass here as this PR is from a fork.
The conflict its complaining about will look daunting when you try to rebase, but its just a lot of renaming, which can be referenced here #2447

Copy link
Contributor

@kyuksel kyuksel left a comment

Choose a reason for hiding this comment

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

Looks good to me pending Justin's comments being addressed 👍🏼

default:
return { flag: unknownRegionFlag, regionDescription: `${locationType}: ${location}` }
}
return Utils.switchCase(locationType,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you declare a

const regionDescription = `${locationType}: ${location}`

above this, you can simplify a lot of the lines below.

@lgtm-com
Copy link

lgtm-com bot commented Apr 26, 2021

This pull request introduces 1 alert when merging ae5967f into 8574dbf - view on LGTM.com

new alerts:

  • 1 for Overwritten property

@yonghaoy yonghaoy changed the title Pass workspace bucket zone/region parameter to Leonardo createRuntime… [PF-693] Pass workspace bucket zone/region parameter to Leonardo createRuntime… Apr 28, 2021
@yonghaoy yonghaoy changed the title [PF-693] Pass workspace bucket zone/region parameter to Leonardo createRuntime… [PF-692] Pass workspace bucket zone/region parameter to Leonardo createRuntime… Apr 28, 2021
@kyuksel
Copy link
Contributor

kyuksel commented Jun 4, 2021

@wnojopra Curious if we should expect any updates on this PR soon?

@wnojopra
Copy link
Contributor Author

wnojopra commented Jun 4, 2021

Thanks for asking @kyuksel . We'd like to merge this PR together with #2420 as they both introduce rationality to Terra. By introducing regional buckets, users could end up accruing egress charges when data is moved between regions. This could happen between a regional bucket and a notebook VM or a workflow VM. To address this, I'm working on two PRs in Cromwell (cromwell/pull/6332 and cromwell/pull/6324)that adds options to minimize egress charges. I'd like to get those changes in before we make regional buckets/VMs in Terra more accessible.

TL;DR - pending Cromwell PRs broadinstitute/cromwell#6324 and broadinstitute/cromwell#6332

@petesantos
Copy link
Contributor

Closing because this PR appears to be stale. If you need to finish this work, feel free to reopen.

@petesantos petesantos closed this Aug 9, 2021
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.

5 participants