Skip to content

Commit eeb442e

Browse files
committed
Fix after dev review
1 parent c180488 commit eeb442e

File tree

6 files changed

+45
-117
lines changed

6 files changed

+45
-117
lines changed

api/kubernetes/deploy_via_helm-dev.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,6 @@ image:
458458
tag: "$API_IMAGE_TAG"
459459
460460
config:
461-
workflow:
462-
containers:
463-
- name : "twingraphImportContainer"
464-
imageRegistry: "ghcr.io"
465-
imageName: "cosmo-tech/adt-twincache-connector"
466-
imageVersion: "0.0.4"
467461
csm:
468462
platform:
469463
argo:

api/src/main/resources/application.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ csm:
8888
scenario-fetch-parameters: cosmo-tech/fetch-scenario-parameters
8989
send-datawarehouse: cosmo-tech/azure-data-explorer-connector
9090
scenario-data-upload: cosmo-tech/azure-storage-publish:latest
91+
containers:
92+
- name: "twingraphImport"
93+
imageRegistry: "ghcr.io"
94+
imageName: "cosmo-tech/adt-twincache-connector"
95+
imageVersion: "0.0.4"
9196
authorization:
9297
principal-jwt-claim: "sub"
9398
tenant-id-jwt-claim: "iss"

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/ContainerFactory.kt

Lines changed: 36 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,11 @@ internal class ContainerFactory(
274274
nodeLabel: String = NODE_LABEL_DEFAULT
275275
): ScenarioRunStartContainers {
276276

277-
val defaultSizing =
278-
if (nodeLabel != null) {
279-
(LABEL_SIZING[nodeLabel] ?: BASIC_SIZING)
280-
} else {
281-
(BASIC_SIZING)
282-
}
277+
var defaultSizing = BASIC_SIZING
278+
279+
if (nodeLabel != null) {
280+
defaultSizing = LABEL_SIZING[nodeLabel] ?: BASIC_SIZING
281+
}
283282

284283
val container =
285284
buildSimpleContainer(
@@ -324,70 +323,6 @@ internal class ContainerFactory(
324323
runSizing = nodeSizing.toContainerResourceSizing())
325324
}
326325

327-
internal fun getMinimalCommonEnvVars(
328-
csmPlatformProperties: CsmPlatformProperties,
329-
azureManagedIdentity: Boolean? = null,
330-
azureAuthenticationWithCustomerAppRegistration: Boolean? = null,
331-
): MutableMap<String, String> {
332-
if (azureManagedIdentity == true && azureAuthenticationWithCustomerAppRegistration == true) {
333-
throw IllegalArgumentException(
334-
"Don't know which authentication mechanism to use to connect " +
335-
"against Azure services. Both azureManagedIdentity and " +
336-
"azureAuthenticationWithCustomerAppRegistration cannot be set to true")
337-
}
338-
val identityEnvVars =
339-
if (azureManagedIdentity == true) {
340-
mapOf(CSM_AZURE_MANAGED_IDENTITY_VAR to "true")
341-
} else if (azureAuthenticationWithCustomerAppRegistration == true) {
342-
mapOf(
343-
AZURE_TENANT_ID_VAR to
344-
(csmPlatformProperties.azure?.credentials?.customer?.tenantId!!),
345-
AZURE_CLIENT_ID_VAR to
346-
(csmPlatformProperties.azure?.credentials?.customer?.clientId!!),
347-
AZURE_CLIENT_SECRET_VAR to
348-
(csmPlatformProperties.azure?.credentials?.customer?.clientSecret!!),
349-
)
350-
} else {
351-
mapOf(
352-
AZURE_TENANT_ID_VAR to (csmPlatformProperties.azure?.credentials?.core?.tenantId!!),
353-
AZURE_CLIENT_ID_VAR to (csmPlatformProperties.azure?.credentials?.core?.clientId!!),
354-
AZURE_CLIENT_SECRET_VAR to
355-
(csmPlatformProperties.azure?.credentials?.core?.clientSecret!!),
356-
)
357-
}
358-
val oktaEnvVars: MutableMap<String, String> = mutableMapOf()
359-
if (csmPlatformProperties.identityProvider?.code == "okta") {
360-
oktaEnvVars.putAll(
361-
mapOf(
362-
OKTA_CLIENT_ID to (csmPlatformProperties.okta?.clientId!!),
363-
OKTA_CLIENT_SECRET to (csmPlatformProperties.okta?.clientSecret!!),
364-
OKTA_CLIENT_ISSUER to (csmPlatformProperties.okta?.issuer!!),
365-
))
366-
}
367-
368-
val twinCacheEnvVars: MutableMap<String, String> = mutableMapOf()
369-
if (csmPlatformProperties.twincache != null) {
370-
val twinCacheInfo = csmPlatformProperties.twincache!!
371-
twinCacheEnvVars.putAll(
372-
mapOf(
373-
TWIN_CACHE_HOST to (twinCacheInfo.host),
374-
TWIN_CACHE_PORT to (twinCacheInfo.port),
375-
TWIN_CACHE_PASSWORD to (twinCacheInfo.password),
376-
TWIN_CACHE_USERNAME to (twinCacheInfo.username),
377-
))
378-
}
379-
val containerScopes = getContainerScopes(csmPlatformProperties)
380-
val commonEnvVars =
381-
mapOf(
382-
IDENTITY_PROVIDER to (csmPlatformProperties.identityProvider?.code ?: "azure"),
383-
API_BASE_URL_VAR to csmPlatformProperties.api.baseUrl,
384-
API_BASE_SCOPE_VAR to containerScopes,
385-
DATASET_PATH_VAR to DATASET_PATH,
386-
PARAMETERS_PATH_VAR to PARAMETERS_PATH,
387-
)
388-
return (identityEnvVars + commonEnvVars + oktaEnvVars + twinCacheEnvVars).toMutableMap()
389-
}
390-
391326
internal fun buildContainersStart(
392327
scenario: Scenario,
393328
datasets: List<Dataset>?,
@@ -416,12 +351,11 @@ internal class ContainerFactory(
416351

417352
val runTemplateSizing = template.runSizing?.toSizing()
418353

419-
val defaultSizing =
420-
if (nodeLabel != null) {
421-
(LABEL_SIZING[nodeLabel] ?: BASIC_SIZING)
422-
} else {
423-
(BASIC_SIZING)
424-
}
354+
var defaultSizing = BASIC_SIZING
355+
356+
if (nodeLabel != null) {
357+
defaultSizing = LABEL_SIZING[nodeLabel] ?: BASIC_SIZING
358+
}
425359

426360
val containers =
427361
buildContainersPipeline(
@@ -1534,14 +1468,8 @@ internal fun getContainerScopes(csmPlatformProperties: CsmPlatformProperties): S
15341468
return "${csmPlatformProperties.azure?.appIdUri}${API_SCOPE_SUFFIX}"
15351469
}
15361470

1537-
@Suppress("LongMethod")
1538-
internal fun getCommonEnvVars(
1471+
internal fun getMinimalCommonEnvVars(
15391472
csmPlatformProperties: CsmPlatformProperties,
1540-
csmSimulationId: String,
1541-
organizationId: String,
1542-
workspaceId: String,
1543-
scenarioId: String,
1544-
workspaceKey: String,
15451473
azureManagedIdentity: Boolean? = null,
15461474
azureAuthenticationWithCustomerAppRegistration: Boolean? = null,
15471475
): MutableMap<String, String> {
@@ -1590,16 +1518,38 @@ internal fun getCommonEnvVars(
15901518
TWIN_CACHE_USERNAME to (twinCacheInfo.username),
15911519
))
15921520
}
1593-
15941521
val containerScopes = getContainerScopes(csmPlatformProperties)
15951522
val commonEnvVars =
15961523
mapOf(
15971524
IDENTITY_PROVIDER to (csmPlatformProperties.identityProvider?.code ?: "azure"),
1598-
CSM_SIMULATION_ID to csmSimulationId,
15991525
API_BASE_URL_VAR to csmPlatformProperties.api.baseUrl,
16001526
API_BASE_SCOPE_VAR to containerScopes,
16011527
DATASET_PATH_VAR to DATASET_PATH,
16021528
PARAMETERS_PATH_VAR to PARAMETERS_PATH,
1529+
)
1530+
return (identityEnvVars + commonEnvVars + oktaEnvVars + twinCacheEnvVars).toMutableMap()
1531+
}
1532+
1533+
internal fun getCommonEnvVars(
1534+
csmPlatformProperties: CsmPlatformProperties,
1535+
csmSimulationId: String,
1536+
organizationId: String,
1537+
workspaceId: String,
1538+
scenarioId: String,
1539+
workspaceKey: String,
1540+
azureManagedIdentity: Boolean? = null,
1541+
azureAuthenticationWithCustomerAppRegistration: Boolean? = null,
1542+
): MutableMap<String, String> {
1543+
1544+
val minimalEnvVars =
1545+
getMinimalCommonEnvVars(
1546+
csmPlatformProperties,
1547+
azureManagedIdentity,
1548+
azureAuthenticationWithCustomerAppRegistration)
1549+
1550+
val commonEnvVars =
1551+
mapOf(
1552+
CSM_SIMULATION_ID to csmSimulationId,
16031553
AZURE_DATA_EXPLORER_RESOURCE_URI_VAR to
16041554
(csmPlatformProperties.azure?.dataWarehouseCluster?.baseUri ?: ""),
16051555
AZURE_DATA_EXPLORER_RESOURCE_INGEST_URI_VAR to
@@ -1609,7 +1559,7 @@ internal fun getCommonEnvVars(
16091559
PARAMETERS_WORKSPACE_VAR to workspaceId,
16101560
PARAMETERS_SCENARIO_VAR to scenarioId,
16111561
)
1612-
return (identityEnvVars + commonEnvVars + oktaEnvVars + twinCacheEnvVars).toMutableMap()
1562+
return (minimalEnvVars + commonEnvVars).toMutableMap()
16131563
}
16141564

16151565
private fun stackSolutionContainers(

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/azure/ScenarioRunServiceImpl.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.cosmotech.scenariorun.CSM_JOB_ID_LABEL_KEY
3535
import com.cosmotech.scenariorun.ContainerFactory
3636
import com.cosmotech.scenariorun.SCENARIO_DATA_DOWNLOAD_ARTIFACT_NAME
3737
import com.cosmotech.scenariorun.api.ScenariorunApiService
38-
import com.cosmotech.scenariorun.config.ContainerConfig
3938
import com.cosmotech.scenariorun.domain.RunTemplateParameterValue
4039
import com.cosmotech.scenariorun.domain.ScenarioRun
4140
import com.cosmotech.scenariorun.domain.ScenarioRunLogs
@@ -60,7 +59,6 @@ import kotlinx.coroutines.joinAll
6059
import kotlinx.coroutines.launch
6160
import kotlinx.coroutines.runBlocking
6261
import kotlinx.coroutines.withTimeout
63-
import org.springframework.beans.factory.annotation.Autowired
6462
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
6563
import org.springframework.context.event.EventListener
6664
import org.springframework.scheduling.annotation.Async
@@ -82,8 +80,6 @@ internal class ScenarioRunServiceImpl(
8280
private val azureEventHubsClient: AzureEventHubsClient
8381
) : CsmAzureService(), ScenariorunApiService {
8482

85-
@Autowired private lateinit var containerConfig: ContainerConfig
86-
8783
private fun ScenarioRun.asMapWithAdditionalData(workspaceId: String? = null): Map<String, Any> {
8884
val scenarioAsMap = this.convertToMap().toMutableMap()
8985
scenarioAsMap["type"] = "ScenarioRun"
@@ -337,11 +333,11 @@ internal class ScenarioRunServiceImpl(
337333
@EventListener(TwingraphImportEvent::class)
338334
fun onTwingraphImportEvent(twingraphImportEvent: TwingraphImportEvent) {
339335
val twingraphImportContainerList =
340-
containerConfig.containers.filter { it.name == "twingraphImportContainer" }
336+
csmPlatformProperties.containers.filter { it.name == "twingraphImport" }
341337

342338
if (twingraphImportContainerList.isEmpty()) {
343339
throw MissingResourceException(
344-
"twingraphImportContainer is not found in configuration (workflow.containers.name)",
340+
"twingraphImport is not found in configuration (workflow.containers.name)",
345341
ScenarioRunServiceImpl::class.simpleName,
346342
"workflow.containers.name")
347343
}

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/config/ContainerConfig.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

twingraph/src/main/kotlin/com/cosmotech/twingraph/api/TwingraphServiceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package com.cosmotech.twingraph.api
55
import com.cosmotech.api.CsmPhoenixService
66
import com.cosmotech.api.events.TwingraphImportEvent
77
import com.cosmotech.api.rbac.CsmRbac
8-
import com.cosmotech.api.rbac.PERMISSION_WRITE
8+
import com.cosmotech.api.rbac.PERMISSION_READ
99
import com.cosmotech.organization.api.OrganizationApiService
1010
import com.cosmotech.organization.azure.getRbac
1111
import com.cosmotech.api.exceptions.CsmResourceNotFoundException
@@ -38,7 +38,7 @@ class TwingraphServiceImpl(
3838
twinGraphImport: TwinGraphImport
3939
): TwinGraphImportInfo {
4040
val organization = organizationService.findOrganizationById(organizationId)
41-
csmRbac.verify(organization.getRbac(), PERMISSION_WRITE)
41+
csmRbac.verify(organization.getRbac(), PERMISSION_READ)
4242
val requestJobId = this.idGenerator.generate(scope = "graphdataimport", prependPrefix = "gdi-")
4343
val graphImportEvent =
4444
TwingraphImportEvent(

0 commit comments

Comments
 (0)