Skip to content

Commit 4ba1abd

Browse files
committed
[PROD-13928] Make Runner.datasetList optional again
Requiring it breaks the updateRunner endpoint, or at minima forces users to provide that field (with current values) even if that's not the field they want to modify. This should be fixed in a better way when we find the time to rework the API contract and split the data model for creation, update and reading.
1 parent 14ef5e7 commit 4ba1abd

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

doc/Models/Runner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
| **ownerName** | **String** | the name of the owner | [optional] [default to null] |
2020
| **solutionName** | **String** | the Solution name | [optional] [default to null] |
2121
| **runTemplateName** | **String** | the Solution Run Template name associated with this Runner | [optional] [default to null] |
22-
| **datasetList** | **List** | the list of Dataset Id associated to this Runner Run Template | [default to []] |
22+
| **datasetList** | **List** | the list of Dataset Id associated to this Runner Run Template | [optional] [default to null] |
2323
| **runSizing** | [**RunnerResourceSizing**](RunnerResourceSizing.md) | | [optional] [default to null] |
2424
| **parametersValues** | [**List**](RunnerRunTemplateParameterValue.md) | the list of Solution Run Template parameters values | [optional] [default to null] |
2525
| **lastRunId** | **String** | last run id from current runner | [optional] [default to null] |

openapi/plantuml/schemas.plantuml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ entity Runner {
376376
ownerName: String
377377
solutionName: String
378378
runTemplateName: String
379-
* datasetList: List<String>
379+
datasetList: List<String>
380380
runSizing: RunnerResourceSizing
381381
parametersValues: List<RunnerRunTemplateParameterValue>
382382
lastRunId: String

runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
414414

415415
logger.info(
416416
"should add an Access Control and assert it is the one created in the linked datasets")
417-
runnerSaved.datasetList.forEach {
417+
runnerSaved.datasetList!!.forEach {
418418
assertDoesNotThrow {
419419
datasetApiService.getDatasetAccessControl(organizationSaved.id!!, it, TEST_USER_MAIL)
420420
}
@@ -432,7 +432,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
432432

433433
logger.info(
434434
"should update the Access Control and assert it has been updated in the linked datasets")
435-
runnerSaved.datasetList.forEach {
435+
runnerSaved.datasetList!!.forEach {
436436
assertEquals(
437437
ROLE_EDITOR,
438438
datasetApiService
@@ -457,7 +457,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
457457

458458
logger.info(
459459
"should remove the Access Control and assert it has been removed in the linked datasets")
460-
runnerSaved.datasetList.forEach {
460+
runnerSaved.datasetList!!.forEach {
461461
assertThrows<CsmResourceNotFoundException> {
462462
datasetApiService.getDatasetAccessControl(organizationSaved.id!!, it, TEST_USER_MAIL)
463463
}
@@ -531,7 +531,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
531531
fun `test on runner delete keep datasets`() {
532532
runnerApiService.deleteRunner(organizationSaved.id!!, workspaceSaved.id!!, runnerSaved.id!!)
533533

534-
runnerSaved.datasetList.forEach { dataset ->
534+
runnerSaved.datasetList!!.forEach { dataset ->
535535
assertDoesNotThrow { datasetApiService.findDatasetById(organizationSaved.id!!, dataset) }
536536
}
537537
}
@@ -657,7 +657,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
657657
runnerSaved = runnerApiService.createRunner(organizationSaved.id!!, workspaceSaved.id!!, runner)
658658

659659
datasetSaved =
660-
datasetApiService.findDatasetById(organizationSaved.id!!, runnerSaved.datasetList[0])
660+
datasetApiService.findDatasetById(organizationSaved.id!!, runnerSaved.datasetList!![0])
661661
runnerApiService.deleteRunner(organizationSaved.id!!, workspaceSaved.id!!, runnerSaved.id!!)
662662

663663
assertDoesNotThrow {
@@ -679,7 +679,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
679679
runnerSaved = runnerApiService.createRunner(organizationSaved.id!!, workspaceSaved.id!!, runner)
680680

681681
datasetSaved =
682-
datasetApiService.findDatasetById(organizationSaved.id!!, runnerSaved.datasetList[0])
682+
datasetApiService.findDatasetById(organizationSaved.id!!, runnerSaved.datasetList!![0])
683683
runnerApiService.addRunnerAccessControl(
684684
organizationSaved.id!!,
685685
workspaceSaved.id!!,

runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.cosmotech.workspace.WorkspaceApiServiceInterface
4242
import com.cosmotech.workspace.domain.Workspace
4343
import com.cosmotech.workspace.service.getRbac
4444
import java.time.Instant
45+
import kotlin.collections.mutableListOf
4546
import org.springframework.context.annotation.Scope
4647
import org.springframework.data.domain.PageRequest
4748
import org.springframework.data.domain.Pageable
@@ -179,6 +180,7 @@ class RunnerService(
179180
ownerId = getCurrentAuthenticatedUserName(csmPlatformProperties),
180181
organizationId = organization!!.id,
181182
workspaceId = workspace!!.id,
183+
datasetList = mutableListOf(),
182184
creationDate = now,
183185
lastUpdate = now)
184186
}
@@ -207,8 +209,8 @@ class RunnerService(
207209

208210
// take newly added datasets and propagate existing ACL on it
209211
this.runner.datasetList
210-
.filterNot { beforeMutateDatasetList.contains(it) }
211-
.forEach { newDatasetId ->
212+
?.filterNot { beforeMutateDatasetList?.contains(it) ?: false }
213+
?.forEach { newDatasetId ->
212214
this.runner.security?.accessControlList?.forEach {
213215
this.propagateAccessControlToDataset(newDatasetId, it.id, it.role)
214216
}
@@ -363,7 +365,7 @@ class RunnerService(
363365
}
364366

365367
private fun propagateAccessControlToDatasets(userId: String, role: String) {
366-
this.runner.datasetList.forEach { datasetId ->
368+
this.runner.datasetList?.forEach { datasetId ->
367369
propagateAccessControlToDataset(datasetId, userId, role)
368370
}
369371
}
@@ -384,7 +386,7 @@ class RunnerService(
384386

385387
private fun removeAccessControlToDatasets(userId: String) {
386388
val organizationId = this.runner.organizationId!!
387-
this.runner.datasetList.forEach { datasetId ->
389+
this.runner.datasetList?.forEach { datasetId ->
388390
val datasetACL =
389391
datasetApiService.findDatasetById(organizationId, datasetId).getRbac().accessControlList
390392

runner/src/main/openapi/runner.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ components:
653653
datasetList:
654654
type: array
655655
description: the list of Dataset Id associated to this Runner Run Template
656-
default: []
657656
items:
658657
type: string
659658
runSizing:
@@ -675,8 +674,6 @@ components:
675674
x-field-extra-annotation: "@com.redis.om.spring.annotations.Indexed"
676675
allOf:
677676
- $ref: '#/components/schemas/RunnerSecurity'
678-
required:
679-
- datasetList
680677
RunnerSecurity:
681678
type: object
682679
description: the Runner security information

0 commit comments

Comments
 (0)