Skip to content

Commit 311df2b

Browse files
authored
Make dataproc zone configurable (#760)
1 parent ba52be0 commit 311df2b

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

leonardo-example.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# Google Cloud dataproc configuration
77
dataproc {
88
dataprocDefaultRegion = "YOUR_REGION" # the google region for your dataproc
9+
#dataprocZone = "YOUR_ZONE" # Optional. The Google zone for the dataproc cluster.
10+
# If not specified, Dataproc will automatically choose a zone
11+
# within the configured region.
912
leoGoogleProject = "GOOGLE_PROJECT" # the name of the google project to use during cluster startup
1013
# *this is not the project the cluster will be created in
1114
clusterUrlBase = "https://YOUR_DOMAIN/notebooks" # the base url to access your cluster

src/main/scala/org/broadinstitute/dsde/workbench/leonardo/Boot.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object Boot extends App with LazyLogging {
7575
}
7676

7777
val (leoServiceAccountEmail, leoServiceAccountPemFile) = serviceAccountProvider.getLeoServiceAccountAndKey
78-
val gdDAO = new HttpGoogleDataprocDAO(dataprocConfig.applicationName, Pem(leoServiceAccountEmail, leoServiceAccountPemFile), "google", NetworkTag(dataprocConfig.networkTag), dataprocConfig.vpcNetwork.map(VPCNetworkName), dataprocConfig.vpcSubnet.map(VPCSubnetName), dataprocConfig.dataprocDefaultRegion, dataprocConfig.defaultExecutionTimeout)
78+
val gdDAO = new HttpGoogleDataprocDAO(dataprocConfig.applicationName, Pem(leoServiceAccountEmail, leoServiceAccountPemFile), "google", NetworkTag(dataprocConfig.networkTag), dataprocConfig.vpcNetwork.map(VPCNetworkName), dataprocConfig.vpcSubnet.map(VPCSubnetName), dataprocConfig.dataprocDefaultRegion, dataprocConfig.dataprocZone, dataprocConfig.defaultExecutionTimeout)
7979
val googleComputeDAO = new HttpGoogleComputeDAO(dataprocConfig.applicationName, Pem(leoServiceAccountEmail, leoServiceAccountPemFile), "google")
8080
val googleIamDAO = new HttpGoogleIamDAO(dataprocConfig.applicationName, Pem(leoServiceAccountEmail, leoServiceAccountPemFile), "google")
8181
val googleStorageDAO = new HttpGoogleStorageDAO(dataprocConfig.applicationName, Pem(leoServiceAccountEmail, leoServiceAccountPemFile), "google")

src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/DataprocConfig.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import scala.concurrent.duration.FiniteDuration
77
case class DataprocConfig(
88
applicationName: String,
99
dataprocDefaultRegion: String,
10+
dataprocZone: Option[String],
1011
leoGoogleProject: GoogleProject,
1112
dataprocDockerImage: String,
1213
clusterUrlBase: String,

src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/package.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package object config {
2121
DataprocConfig(
2222
config.getString("applicationName"),
2323
config.getString("dataprocDefaultRegion"),
24+
config.getAs[String]("dataprocZone"),
2425
GoogleProject(config.getString("leoGoogleProject")),
2526
config.getString("dataprocDockerImage"),
2627
config.getString("clusterUrlBase"),

src/main/scala/org/broadinstitute/dsde/workbench/leonardo/dao/google/HttpGoogleDataprocDAO.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class HttpGoogleDataprocDAO(appName: String,
3838
vpcNetwork: Option[VPCNetworkName],
3939
vpcSubnet: Option[VPCSubnetName],
4040
defaultRegion: String,
41+
zoneOpt: Option[String],
4142
defaultExecutionTimeout: FiniteDuration)
4243
(implicit override val system: ActorSystem, override val executionContext: ExecutionContext)
4344
extends AbstractHttpGoogleDAO(appName, googleCredentialMode, workbenchMetricBaseName) with GoogleDataprocDAO {
@@ -244,6 +245,11 @@ class HttpGoogleDataprocDAO(appName: String,
244245
.setMachineTypeUri(machineConfig.masterMachineType.get)
245246
.setDiskConfig(new DiskConfig().setBootDiskSizeGb(machineConfig.masterDiskSize.get))
246247

248+
// Set the zone, if specified. If not specified, Dataproc will pick a zone within the configured region.
249+
zoneOpt.foreach { zone =>
250+
gceClusterConfig.setZoneUri(zone)
251+
}
252+
247253
// Create a Cluster Config and give it the GceClusterConfig, the NodeInitializationAction and the InstanceGroupConfig
248254
createClusterConfig(machineConfig, credentialsFileName)
249255
.setGceClusterConfig(gceClusterConfig)

src/test/resources/reference.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dataproc {
3232
applicationName = "test:leonardo"
3333
serviceAccountEmail = "test@test.com"
3434
dataprocDefaultRegion = "testregion"
35+
dataprocZone = "test-zone"
3536
leoGoogleProject = "test-bucket"
3637
dataprocDockerImage = "testrepo/test"
3738
clusterUrlBase = "http://leonardo/"

0 commit comments

Comments
 (0)