Skip to content

Commit 40c799c

Browse files
committed
Mount output and temp directory in argo containers to be compatible with k8s secured option securityContext.readOnlyRootFilesystem=true
1 parent dea4890 commit 40c799c

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

run/src/main/kotlin/com/cosmotech/run/RunContainerFactory.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ private const val DATASET_PATH_VAR = "CSM_DATASET_ABSOLUTE_PATH"
4444
private const val DATASET_PATH = "/mnt/scenariorun-data"
4545
private const val PARAMETERS_PATH_VAR = "CSM_PARAMETERS_ABSOLUTE_PATH"
4646
private const val PARAMETERS_PATH = "/mnt/scenariorun-parameters"
47+
private const val OUTPUT_PATH_VAR = "CSM_OUTPUT_ABSOLUTE_PATH"
48+
private const val OUTPUT_PATH = "/pkg/share/Simulation/Output"
49+
private const val TEMP_PATH_VAR = "CSM_TEMP_ABSOLUTE_PATH"
50+
private const val TEMP_PATH = "/usr/tmp"
4751
private const val PARAMETERS_ORGANIZATION_VAR = "CSM_ORGANIZATION_ID"
4852
private const val PARAMETERS_WORKSPACE_VAR = "CSM_WORKSPACE_ID"
4953
private const val PARAMETERS_RUNNER_VAR = "CSM_RUNNER_ID"
@@ -365,6 +369,8 @@ internal fun getMinimalCommonEnvVars(
365369
API_BASE_SCOPE_VAR to containerScopes,
366370
DATASET_PATH_VAR to DATASET_PATH,
367371
PARAMETERS_PATH_VAR to PARAMETERS_PATH,
372+
OUTPUT_PATH_VAR to OUTPUT_PATH,
373+
TEMP_PATH_VAR to TEMP_PATH,
368374
)
369375
return (commonEnvVars + twinCacheEnvVars).toMutableMap()
370376
}

run/src/main/kotlin/com/cosmotech/run/workflow/argo/WorkflowBuilders.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ private const val CSM_DEFAULT_WORKFLOW_NAME = "default-workflow-"
3737
internal const val VOLUME_CLAIM = "datadir"
3838
internal const val VOLUME_CLAIM_DATASETS_SUBPATH = "datasetsdir"
3939
internal const val VOLUME_CLAIM_PARAMETERS_SUBPATH = "parametersdir"
40+
internal const val VOLUME_CLAIM_OUTPUT_SUBPATH = "outputdir"
41+
internal const val VOLUME_CLAIM_TEMP_SUBPATH = "tempdir"
4042
private const val VOLUME_DATASETS_PATH = "/mnt/scenariorun-data"
4143
private const val VOLUME_PARAMETERS_PATH = "/mnt/scenariorun-parameters"
44+
private const val VOLUME_OUTPUT_PATH = "/pkg/share/Simulation/Output"
45+
private const val VOLUME_TEMP_PATH = "/usr/tmp"
4246
internal const val CSM_ARGO_WORKFLOWS_TIMEOUT = 28800
4347
internal const val ALWAYS_PULL_POLICY = "Always"
4448

@@ -66,7 +70,15 @@ internal fun buildTemplate(
6670
V1VolumeMount()
6771
.name(VOLUME_CLAIM)
6872
.mountPath(VOLUME_PARAMETERS_PATH)
69-
.subPath(VOLUME_CLAIM_PARAMETERS_SUBPATH))
73+
.subPath(VOLUME_CLAIM_PARAMETERS_SUBPATH),
74+
V1VolumeMount()
75+
.name(VOLUME_CLAIM)
76+
.mountPath(VOLUME_OUTPUT_PATH)
77+
.subPath(VOLUME_CLAIM_OUTPUT_SUBPATH),
78+
V1VolumeMount()
79+
.name(VOLUME_CLAIM)
80+
.mountPath(VOLUME_TEMP_PATH)
81+
.subPath(VOLUME_CLAIM_TEMP_SUBPATH))
7082

7183
val sizingInfo = runContainer.runSizing ?: BASIC_SIZING.toContainerResourceSizing()
7284

run/src/test/kotlin/com/cosmotech/run/ContainerFactoryTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class ContainerFactoryTests {
178178
"CSM_API_URL" to csmPlatformProperties.api.baseUrl,
179179
"CSM_DATASET_ABSOLUTE_PATH" to "/mnt/scenariorun-data",
180180
"CSM_PARAMETERS_ABSOLUTE_PATH" to "/mnt/scenariorun-parameters",
181+
"CSM_OUTPUT_ABSOLUTE_PATH" to "/pkg/share/Simulation/Output",
182+
"CSM_TEMP_ABSOLUTE_PATH" to "/usr/tmp",
181183
"TWIN_CACHE_HOST" to csmPlatformProperties.twincache.host,
182184
"TWIN_CACHE_PORT" to csmPlatformProperties.twincache.port,
183185
"TWIN_CACHE_PASSWORD" to csmPlatformProperties.twincache.password,

run/src/test/kotlin/com/cosmotech/run/workflow/argo/WorkflowBuildersTests.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,15 @@ class WorkflowBuildersTests {
468468
V1VolumeMount()
469469
.name(VOLUME_CLAIM)
470470
.mountPath("/mnt/scenariorun-parameters")
471-
.subPath(VOLUME_CLAIM_PARAMETERS_SUBPATH))
471+
.subPath(VOLUME_CLAIM_PARAMETERS_SUBPATH),
472+
V1VolumeMount()
473+
.name(VOLUME_CLAIM)
474+
.mountPath("/pkg/share/Simulation/Output")
475+
.subPath(VOLUME_CLAIM_OUTPUT_SUBPATH),
476+
V1VolumeMount()
477+
.name(VOLUME_CLAIM)
478+
.mountPath("/usr/tmp")
479+
.subPath(VOLUME_CLAIM_TEMP_SUBPATH))
472480
assertEquals(expected, template.container?.volumeMounts)
473481
}
474482

0 commit comments

Comments
 (0)