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 deployment in Azure Government Cloud (Leonardo) #4813

Open
wants to merge 76 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
076a814
Replace pet Token with leo token
jsaun Jun 18, 2024
f96846a
Replace pet service account tokens with leo service account
jsaun Aug 25, 2024
480ac44
Fix build
jsaun Aug 25, 2024
7ffc656
Fix
jsaun Aug 25, 2024
2a49a1d
Test custom chart
jsaun Sep 11, 2024
c9f44e8
Update wds chart
jsaun Sep 11, 2024
da173ef
Use local helm chart
jsaun Sep 12, 2024
79ebef8
Update Dependencies.scala
jsaun Oct 7, 2024
abe660c
carry over other changes
jsaun Oct 16, 2024
59bc2ea
Update clean_install.sh
jsaun Oct 16, 2024
e70ec14
Update MonitorAtBoot.scala
jsaun Oct 16, 2024
548b753
Update AKSInterpreter.scala
jsaun Oct 16, 2024
adad799
Remove leo auth token from app charts
jsaun Oct 16, 2024
6e056b6
Update CromwellRunnerAppInstall.scala
jsaun Oct 16, 2024
f912dea
Remove auth tokens from app configs
jsaun Oct 22, 2024
a7d27af
Update LeoAppServiceInterp.scala
jsaun Oct 28, 2024
b592443
Update Dependencies.scala
jsaun Oct 28, 2024
e597b53
Update Dependencies.scala
jsaun Oct 28, 2024
b050782
Update Dependencies.scala
jsaun Oct 28, 2024
aa1586e
Update LeoAppServiceInterp.scala
jsaun Oct 30, 2024
23d6ca2
Revert "Update LeoAppServiceInterp.scala"
jsaun Oct 30, 2024
134b8ac
Get leo email from token
jsaun Oct 30, 2024
59aff84
Update reference.conf
jsaun Nov 4, 2024
58fd927
Update Dependencies.scala
bennettn4 Nov 5, 2024
7355698
Update Dependencies.scala
bennettn4 Nov 6, 2024
d1c31af
update gov servicebus and sql suffixes
bennettn4 Nov 6, 2024
83a04ac
fix import and typo
bennettn4 Nov 6, 2024
78df15b
update azure gov config
bennettn4 Nov 6, 2024
9c521d9
update storage account suffix to support azure gov
bennettn4 Nov 7, 2024
e49ce53
Fix postgres suffix in commercial
jsaun Nov 10, 2024
5f9bcfb
test cromwell version
bennettn4 Nov 14, 2024
a592658
Update CromwellAppInstall.scala
bennettn4 Nov 14, 2024
12e1ad7
with test cromwell-runner-app version
bennettn4 Nov 15, 2024
93fa992
Update reference.conf
bennettn4 Nov 15, 2024
ae97497
update tokenscope
bennettn4 Nov 15, 2024
1518e8d
update batch account suffix and re-value environment strings to match…
bennettn4 Nov 18, 2024
e9fb894
update test cromwell version
bennettn4 Nov 18, 2024
be60a6e
Update Dependencies.scala
bennettn4 Nov 18, 2024
8b4ea1f
Update AzureHostingModeConfig.scala
bennettn4 Nov 18, 2024
6bc1d1b
Update CromwellAppInstall.scala
bennettn4 Nov 18, 2024
1d7eabc
Update CromwellRunnerAppInstall.scala
bennettn4 Nov 18, 2024
a9d6b4d
Update AppDependenciesBuilder.scala
jsaun Nov 24, 2024
2bdcaa7
update relay suffix in notebook init script
bennettn4 Nov 29, 2024
fc5466c
Update AzurePubsubHandler.scala
bennettn4 Dec 2, 2024
f58c237
Update reference.conf
bennettn4 Dec 5, 2024
74bb32b
Update Dependencies.scala
jsaun Dec 17, 2024
03d1e94
Revert "Update reference.conf"
jsaun Dec 17, 2024
94b029e
Merge branch 'develop' into jsaun/leo-service-account
jsaun Dec 17, 2024
caf5465
Update reference.conf
jsaun Dec 17, 2024
666b19a
Default empty user token
jsaun Dec 17, 2024
fdfb13f
pr cleanup
jsaun Dec 17, 2024
afd724a
Fix types
jsaun Dec 18, 2024
a7fc8dd
Update WdsAppInstall.scala
jsaun Dec 20, 2024
a6c9800
Fix specs
jsaun Dec 21, 2024
64a1920
scalaFmt
jsaun Dec 21, 2024
25110ff
scalaFmt again
jsaun Dec 21, 2024
80b8afe
Merge branch 'develop' into jsaun/leo-service-account
jsaun Dec 23, 2024
53d2399
Update HailBatchAppInstallSpec.scala
bennettn4 Dec 26, 2024
a0f5a16
Update AppServiceInterpSpec.scala
bennettn4 Dec 26, 2024
3627fe6
Update AllowlistAuthProvider.scala
bennettn4 Dec 26, 2024
59e0cc6
Update AppServiceInterpSpec.scala
bennettn4 Dec 26, 2024
ae716da
update helm override specs
bennettn4 Dec 26, 2024
ef9015a
scalafmt
bennettn4 Dec 26, 2024
a29056c
update specs
bennettn4 Dec 30, 2024
50dd92b
update test specs
bennettn4 Dec 30, 2024
9f228c7
Update ConfigReaderSpec.scala
bennettn4 Dec 30, 2024
a209d3e
Address pr comments
jsaun Jan 28, 2025
df089ce
fix imports
jsaun Jan 28, 2025
64a81d7
Merge branch 'develop' into jsaun/leo-service-account
jsaun Jan 28, 2025
63f36e4
Remove placeholder cromwell image
jsaun Jan 31, 2025
5b3b326
Merge branch 'develop' into jsaun/leo-service-account
jsaun Jan 31, 2025
3363e56
Update CromwellRunnerAppInstallSpec.scala
jsaun Feb 3, 2025
1c68ff4
Update ConfigReaderSpec.scala
jsaun Feb 3, 2025
c9abbea
Update ConfigReaderSpec.scala
jsaun Feb 3, 2025
52da05d
Update ConfigReaderSpec.scala
jsaun Feb 4, 2025
c39ccc3
Update ConfigReaderSpec.scala
jsaun Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ SAMURL=$6
SAMRESOURCEID=$7
CONTENTSECURITYPOLICY_FILE=$8

RELAY_SUFFIX=${21:-".servicebus.windows.net"}

# Envs for welder
WELDER_WSM_URL=${9:-localhost}
WORKSPACE_ID="${10:-dummy}" # Additionally used for welder
Expand All @@ -126,11 +128,11 @@ WORKSPACE_STORAGE_CONTAINER_URL="${17:-dummy}"
SERVER_APP_BASE_URL="/${RELAY_CONNECTION_NAME}/"
SERVER_APP_ALLOW_ORIGIN="*"
HCVAR='\$hc'
SERVER_APP_WEBSOCKET_URL="wss://${RELAY_NAME}.servicebus.windows.net/${HCVAR}/${RELAY_CONNECTION_NAME}"
SERVER_APP_WEBSOCKET_HOST="${RELAY_NAME}.servicebus.windows.net"
SERVER_APP_WEBSOCKET_URL="wss://${RELAY_NAME}${RELAY_SUFFIX}/${HCVAR}/${RELAY_CONNECTION_NAME}"
SERVER_APP_WEBSOCKET_HOST="${RELAY_NAME}${RELAY_SUFFIX}"

# Relay listener configuration
RELAY_CONNECTIONSTRING="Endpoint=sb://${RELAY_NAME}.servicebus.windows.net/;SharedAccessKeyName=listener;SharedAccessKey=${RELAY_CONNECTION_POLICY_KEY};EntityPath=${RELAY_CONNECTION_NAME}"
RELAY_CONNECTIONSTRING="Endpoint=sb://${RELAY_NAME}${RELAY_SUFFIX}/;SharedAccessKeyName=listener;SharedAccessKey=${RELAY_CONNECTION_POLICY_KEY};EntityPath=${RELAY_CONNECTION_NAME}"

# Relay listener configuration - setDateAccessed listener
LEONARDO_URL="${18:-dummy}"
Expand All @@ -143,6 +145,7 @@ echo "RELAY_NAME = ${RELAY_NAME}"
echo "RELAY_CONNECTION_NAME = ${RELAY_CONNECTION_NAME}"
echo "RELAY_TARGET_HOST = ${RELAY_TARGET_HOST}"
echo "RELAY_CONNECTION_POLICY_KEY = ${RELAY_CONNECTION_POLICY_KEY}"
echo "RELAY_SUFFIX = ${RELAY_SUFFIX}"
echo "LISTENER_DOCKER_IMAGE = ${LISTENER_DOCKER_IMAGE}"
echo "SAMURL = ${SAMURL}"
echo "SAMRESOURCEID = ${SAMRESOURCEID}"
Expand Down
2 changes: 1 addition & 1 deletion http/src/main/resources/leo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ azure {
# If true, it is assumed that Leo is hosted on Azure and will use Azure managed identity for authentication.
enabled = ${?AZURE_HOSTING_MODE_ENABLED}
# valid values are AZURE (Azure Commercial), AZURE_US_GOVERNMENT and AZURE_CHINA
azure-environment = ${?AZURE_HOSTING_ENVIRONMENT}
azure-environment = ${?AZURE_ENVIRONMENT}
managed-identity-auth-config{
token-scope = ${?AZURE_MI_TOKEN_SCOPE}
token-acquisition-timeout = ${?AZURE_MI_TOKEN_ACQUISITION_TIMEOUT}
Expand Down
2 changes: 1 addition & 1 deletion http/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ azure {
type = "CustomScript",
version = "2.1",
minor-version-auto-upgrade = true,
file-uris = ["https://raw.githubusercontent.com/DataBiosphere/leonardo/8390d25ccd761fb206cf388560a571be77a42bbd/http/src/main/resources/init-resources/azure_vm_init_script.sh"]
file-uris = ["https://raw.githubusercontent.com/DataBiosphere/leonardo/f58c237b4dc235cd1c24c6dfc7500c07bdbd5bc3/http/src/main/resources/init-resources/azure_vm_init_script.sh"]
}
# [IA-4997] to support CHIPS by setting partitioned cookies
# listener-image = "terradevacrpublic.azurecr.io/terra-azure-relay-listeners:474f157"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import org.broadinstitute.dsde.workbench.azure.{AzureApplicationInsightsService,
import org.broadinstitute.dsde.workbench.leonardo.app.AppInstall.getAzureDatabaseName
import org.broadinstitute.dsde.workbench.leonardo.{AppContext, WsmControlledDatabaseResource}
import org.broadinstitute.dsde.workbench.leonardo.app.Database.ControlledDatabase
import org.broadinstitute.dsde.workbench.leonardo.config.CoaAppConfig
import org.broadinstitute.dsde.workbench.leonardo.auth.SamAuthProvider
import org.broadinstitute.dsde.workbench.leonardo.config.{AzureEnvironmentConverter, CoaAppConfig}
import org.broadinstitute.dsde.workbench.leonardo.dao._
import org.broadinstitute.dsde.workbench.leonardo.http._
import org.broadinstitute.dsde.workbench.leonardo.util.AppCreationException
Expand All @@ -25,7 +26,8 @@ class CromwellAppInstall[F[_]](config: CoaAppConfig,
cromwellDao: CromwellDAO[F],
cbasDao: CbasDAO[F],
azureBatchService: AzureBatchService[F],
azureApplicationInsightsService: AzureApplicationInsightsService[F]
azureApplicationInsightsService: AzureApplicationInsightsService[F],
authProvider: SamAuthProvider[F]
)(implicit
F: Async[F]
) extends AppInstall[F] {
Expand Down Expand Up @@ -69,10 +71,7 @@ class CromwellAppInstall[F[_]](config: CoaAppConfig,

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.fromOption(
tokenOpt,
AppCreationException(s"Pet not found for user ${params.app.auditInfo.creator}", Some(ctx.traceId))
)
userToken <- F.pure(tokenOpt.getOrElse("")) // Empty token when running on Azure.
jsaun marked this conversation as resolved.
Show resolved Hide resolved

values = List(
// azure resources configs
Expand All @@ -85,13 +84,22 @@ class CromwellAppInstall[F[_]](config: CoaAppConfig,
raw"config.subscriptionId=${params.cloudContext.subscriptionId.value}",
raw"config.region=${params.landingZoneResources.region}",
raw"config.applicationInsightsConnectionString=${applicationInsightsComponent.connectionString()}",
raw"config.azureEnvironment=${ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment}",
raw"config.azureManagementTokenScope=${AzureEnvironmentConverter
.fromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)
.getResourceManagerEndpoint}.default",
raw"config.batchAccountSuffix=${AzureEnvironmentConverter
.batchAccountSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",

// relay configs
raw"relay.path=${params.relayPath.renderString}",

// persistence configs
raw"persistence.storageResourceGroup=${params.cloudContext.managedResourceGroupName.value}",
raw"persistence.storageAccount=${params.landingZoneResources.storageAccountName.value}",
raw"persistence.storageAccountSuffix=${AzureEnvironmentConverter
.fromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)
.getStorageEndpointSuffix}",
raw"persistence.blobContainer=${storageContainer.name.value}",
raw"persistence.leoAppInstanceName=${params.app.appName.value}",
raw"persistence.workspaceManager.url=${params.config.wsmConfig.uri.renderString}",
Expand Down Expand Up @@ -124,7 +132,8 @@ class CromwellAppInstall[F[_]](config: CoaAppConfig,

// Database configs
raw"postgres.podLocalDatabaseEnabled=false",
raw"postgres.host=${postgresServer.name}.postgres.database.azure.com",
raw"postgres.host=${postgresServer.name}.postgres${AzureEnvironmentConverter
.postgresSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",
raw"postgres.pgbouncer.enabled=${postgresServer.pgBouncerEnabled}",
// convention is that the database user is the same as the service account name
raw"postgres.user=${params.ksaName.value}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.broadinstitute.dsde.workbench.leonardo.{AppContext, WsmControlledData
import org.broadinstitute.dsde.workbench.leonardo.app.AppInstall.getAzureDatabaseName
import org.broadinstitute.dsde.workbench.leonardo.app.Database.{ControlledDatabase, ReferenceDatabase}
import org.broadinstitute.dsde.workbench.leonardo.auth.SamAuthProvider
import org.broadinstitute.dsde.workbench.leonardo.config.{CromwellRunnerAppConfig, SamConfig}
import org.broadinstitute.dsde.workbench.leonardo.config.{AzureEnvironmentConverter, CromwellRunnerAppConfig, SamConfig}
import org.broadinstitute.dsde.workbench.leonardo.dao.{BpmApiClientProvider, CromwellDAO, SamDAO}
import org.broadinstitute.dsde.workbench.leonardo.http._
import org.broadinstitute.dsde.workbench.leonardo.util.AppCreationException
Expand Down Expand Up @@ -80,11 +80,6 @@ class CromwellRunnerAppInstall[F[_]](config: CromwellRunnerAppConfig,
)

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.fromOption(
tokenOpt,
AppCreationException(s"Pet not found for user ${params.app.auditInfo.creator}", Some(ctx.traceId))
)

leoAuth <- authProvider.getLeoAuthToken

Expand All @@ -99,6 +94,10 @@ class CromwellRunnerAppInstall[F[_]](config: CromwellRunnerAppConfig,
.map(v => raw"config.concurrentJobLimit=${v}")
}

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.pure(tokenOpt.getOrElse("")) // Empty token when running on Azure.
jsaun marked this conversation as resolved.
Show resolved Hide resolved

values = List(
// azure resources configs
raw"config.resourceGroup=${params.cloudContext.managedResourceGroupName.value}",
Expand All @@ -110,12 +109,21 @@ class CromwellRunnerAppInstall[F[_]](config: CromwellRunnerAppConfig,
raw"config.subscriptionId=${params.cloudContext.subscriptionId.value}",
raw"config.region=${params.landingZoneResources.region}",
raw"config.applicationInsightsConnectionString=${applicationInsightsComponent.connectionString()}",
raw"config.azureEnvironment=${ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment}",
raw"config.azureManagementTokenScope=${AzureEnvironmentConverter
.fromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)
.getResourceManagerEndpoint}.default",
raw"config.batchAccountSuffix=${AzureEnvironmentConverter
.batchAccountSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",

// relay configs
raw"relay.path=${params.relayPath.renderString}",

// persistence configs
raw"persistence.storageAccount=${params.landingZoneResources.storageAccountName.value}",
raw"persistence.storageAccountSuffix=${AzureEnvironmentConverter
.fromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)
.getStorageEndpointSuffix}",
raw"persistence.blobContainer=${storageContainer.name.value}",
raw"persistence.leoAppInstanceName=${params.app.appName.value}",
raw"persistence.workspaceManager.url=${params.config.wsmConfig.uri.renderString}",
Expand All @@ -138,7 +146,8 @@ class CromwellRunnerAppInstall[F[_]](config: CromwellRunnerAppConfig,

// database configs
raw"postgres.podLocalDatabaseEnabled=false",
raw"postgres.host=${postgresServer.name}.postgres.database.azure.com",
raw"postgres.host=${postgresServer.name}.postgres${AzureEnvironmentConverter
.postgresSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",
raw"postgres.pgbouncer.enabled=${postgresServer.pgBouncerEnabled}",
// convention is that the database user is the same as the service account name
raw"postgres.user=${params.ksaName.value}",
Expand All @@ -155,7 +164,10 @@ class CromwellRunnerAppInstall[F[_]](config: CromwellRunnerAppConfig,

// Bard configs
raw"bard.bardUrl=${config.bardBaseUri}",
raw"bard.enabled=${config.bardEnabled}"
raw"bard.enabled=${config.bardEnabled}",

// TEMPORARY HELM OVERRIDE VALUES WHILE WAITING FOR PR
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you link the PR? if it is the terra helmfile one you should be good to merge I think

raw"cromwell.image=potomacdevap.azurecr.us/broadinstitute/cromwell:84214c9d71721269f9945406d72e30a6f8aac514"
)

finalList = maybeLimits match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import cats.effect.Async
import cats.mtl.Ask
import cats.syntax.all._
import org.broadinstitute.dsde.workbench.leonardo.AppContext
import org.broadinstitute.dsde.workbench.leonardo.config.HailBatchAppConfig
import org.broadinstitute.dsde.workbench.leonardo.config.{AzureEnvironmentConverter, HailBatchAppConfig}
import org.broadinstitute.dsde.workbench.leonardo.dao.HailBatchDAO
import org.broadinstitute.dsde.workbench.leonardo.http.ConfigReader
import org.broadinstitute.dsde.workbench.leonardo.util.AppCreationException
import org.broadinstitute.dsp.Values
import org.http4s.Uri
Expand Down Expand Up @@ -34,7 +35,9 @@ class HailBatchAppInstall[F[_]](config: HailBatchAppConfig, hailBatchDao: HailBa
raw"persistence.workspaceManager.url=${params.config.wsmConfig.uri.renderString}",
raw"persistence.workspaceManager.workspaceId=${params.workspaceId.value}",
raw"persistence.workspaceManager.containerResourceId=${storageContainer.resourceId.value.toString}",
raw"persistence.workspaceManager.storageContainerUrl=https://${params.landingZoneResources.storageAccountName.value}.blob.core.windows.net/${storageContainer.name.value}",
raw"persistence.workspaceManager.storageContainerUrl=https://${params.landingZoneResources.storageAccountName.value}.blob${AzureEnvironmentConverter
.fromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)
.getStorageEndpointSuffix}/${storageContainer.name.value}",
raw"persistence.leoAppName=${params.app.appName.value}",

// identity configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import cats.mtl.Ask
import cats.syntax.all._
import org.broadinstitute.dsde.workbench.azure.AzureApplicationInsightsService
import org.broadinstitute.dsde.workbench.leonardo.app.Database.ControlledDatabase
import org.broadinstitute.dsde.workbench.leonardo.config.WdsAppConfig
import org.broadinstitute.dsde.workbench.leonardo.auth.SamAuthProvider
import org.broadinstitute.dsde.workbench.leonardo.config.{AzureEnvironmentConverter, WdsAppConfig}
import org.broadinstitute.dsde.workbench.leonardo.dao._
import org.broadinstitute.dsde.workbench.leonardo.http._
import org.broadinstitute.dsde.workbench.leonardo.util.AppCreationException
Expand All @@ -23,7 +24,8 @@ class WdsAppInstall[F[_]](config: WdsAppConfig,
tdrConfig: TdrConfig,
samDao: SamDAO[F],
wdsDao: WdsDAO[F],
azureApplicationInsightsService: AzureApplicationInsightsService[F]
azureApplicationInsightsService: AzureApplicationInsightsService[F],
authProvider: SamAuthProvider[F]
)(implicit
F: Async[F]
) extends AppInstall[F] {
Expand Down Expand Up @@ -54,15 +56,14 @@ class WdsAppInstall[F[_]](config: WdsAppConfig,
)

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.fromOption(
tokenOpt,
AppCreationException(s"Pet not found for user ${params.app.auditInfo.creator}", Some(ctx.traceId))
)

// Get Vpa enabled tag
vpaEnabled <- F.pure(params.landingZoneResources.aksCluster.tags.getOrElse("aks-cost-vpa-enabled", false))

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.pure(tokenOpt.getOrElse("")) // Empty token when running on Azure.
jsaun marked this conversation as resolved.
Show resolved Hide resolved

valuesList =
List(
// pass enviiroment information to wds so it can properly pick its config
Expand Down Expand Up @@ -96,7 +97,8 @@ class WdsAppInstall[F[_]](config: WdsAppConfig,
raw"provenance.sourceWorkspaceId=${params.app.sourceWorkspaceId.map(_.value).getOrElse("")}",

// database configs
raw"postgres.host=${postgresServer.name}.postgres.database.azure.com",
raw"postgres.host=${postgresServer.name}.postgres${AzureEnvironmentConverter
.postgresSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",
raw"postgres.pgbouncer.enabled=${postgresServer.pgBouncerEnabled}",
raw"postgres.dbname=$dbName",
// convention is that the database user is the same as the service account name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.broadinstitute.dsde.workbench.azure.{AzureApplicationInsightsService,
import org.broadinstitute.dsde.workbench.leonardo.{AppContext, WsmControlledDatabaseResource}
import org.broadinstitute.dsde.workbench.leonardo.app.AppInstall.getAzureDatabaseName
import org.broadinstitute.dsde.workbench.leonardo.app.Database.ControlledDatabase
import org.broadinstitute.dsde.workbench.leonardo.config.WorkflowsAppConfig
import org.broadinstitute.dsde.workbench.leonardo.config.{AzureEnvironmentConverter, WorkflowsAppConfig}
import org.broadinstitute.dsde.workbench.leonardo.dao._
import org.broadinstitute.dsde.workbench.leonardo.http._
import org.broadinstitute.dsde.workbench.leonardo.util.AppCreationException
Expand Down Expand Up @@ -69,10 +69,7 @@ class WorkflowsAppInstall[F[_]](config: WorkflowsAppConfig,

// Get the pet userToken
tokenOpt <- samDao.getCachedArbitraryPetAccessToken(params.app.auditInfo.creator)
userToken <- F.fromOption(
tokenOpt,
AppCreationException(s"Pet not found for user ${params.app.auditInfo.creator}", Some(ctx.traceId))
)
userToken <- F.pure(tokenOpt.getOrElse("")) // Empty token when running on Azure.
jsaun marked this conversation as resolved.
Show resolved Hide resolved

values =
List(
Expand Down Expand Up @@ -111,7 +108,8 @@ class WorkflowsAppInstall[F[_]](config: WorkflowsAppConfig,

// database configs
raw"postgres.podLocalDatabaseEnabled=false",
raw"postgres.host=${postgresServer.name}.postgres.database.azure.com",
raw"postgres.host=${postgresServer.name}.postgres${AzureEnvironmentConverter
.postgresSuffixFromString(ConfigReader.appConfig.azure.hostingModeConfig.azureEnvironment)}",
raw"postgres.pgbouncer.enabled=${postgresServer.pgBouncerEnabled}",
// convention is that the database user is the same as the service account name
raw"postgres.user=${params.ksaName.value}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,46 @@
)

object AzureEnvironmentConverter {
val Azure: String = "AZURE"
val AzureGov: String = "AZURE_US_GOVERNMENT"
val AzureChina: String = "AZURE_CHINA"
val Azure: String = "AzureCloud"
val AzureGov: String = "AzureUSGovernmentCloud"

def fromString(s: String): AzureEnvironment = s match {
case AzureGov => AzureEnvironment.AZURE_US_GOVERNMENT
case AzureChina => AzureEnvironment.AZURE_CHINA
case AzureGov => AzureEnvironment.AZURE_US_GOVERNMENT
// a bit redundant, but I want to have a explicit case for Azure for clarity, even though it's the default
case Azure => AzureEnvironment.AZURE
case _ => AzureEnvironment.AZURE
}

// servicebus suffix not currently provided by AzureEnvironment library, values found here
def relaySuffixFromEnvironment(azureEnvironment: AzureEnvironment): String = azureEnvironment match {
case AzureEnvironment.AZURE_US_GOVERNMENT => ".servicebus.usgovcloudapi.net"

Check warning on line 32 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L32

Added line #L32 was not covered by tests
// a bit redundant, but I want to have a explicit case for Azure for clarity, even though it's the default
case AzureEnvironment.AZURE => ".servicebus.windows.net"
case _ => ".servicebus.windows.net"

Check warning on line 35 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L35

Added line #L35 was not covered by tests
}

def relaySuffixFromString(s: String): String =
relaySuffixFromEnvironment(fromString(s))

// database suffix not currently provided by AzureEnvironment library, values found here
def postgresSuffixFromEnvironment(azureEnvironment: AzureEnvironment): String = azureEnvironment match {
case AzureEnvironment.AZURE_US_GOVERNMENT => ".database.usgovcloudapi.net"

Check warning on line 43 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L43

Added line #L43 was not covered by tests
// a bit redundant, but I want to have a explicit case for Azure for clarity, even though it's the default
case AzureEnvironment.AZURE => ".database.azure.com"
case _ => ".database.azure.com"

Check warning on line 46 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L46

Added line #L46 was not covered by tests
}

def postgresSuffixFromString(s: String): String =
postgresSuffixFromEnvironment(fromString(s))

// batchAccount suffix not currently provided by AzureEnvironment library, values found here
def batchAccountSuffixFromEnvironment(azureEnvironment: AzureEnvironment): String = azureEnvironment match {
case AzureEnvironment.AZURE_US_GOVERNMENT => ".batch.usgovcloudapi.net"

Check warning on line 54 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L54

Added line #L54 was not covered by tests
// a bit redundant, but I want to have a explicit case for Azure for clarity, even though it's the default
case AzureEnvironment.AZURE => ".batch.azure.com"
case _ => ".batch.azure.com"

Check warning on line 57 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/config/AzureHostingModeConfig.scala#L57

Added line #L57 was not covered by tests
}

def batchAccountSuffixFromString(s: String): String =
batchAccountSuffixFromEnvironment(fromString(s))
}
Loading
Loading