@@ -677,9 +677,29 @@ class ScenarioRunServiceImpl(
677677 val scenarioRun =
678678 this .findScenarioRunById(organizationId, scenariorunId, withStateInformation = false )
679679 // This call verify by itself that we have the read authorization in the scenario
680- scenarioApiService.findScenarioById(
681- organizationId, scenarioRun.workspaceId!! , scenarioRun.scenarioId!! )
682- return getScenarioRunStatus(organizationId, scenarioRun)
680+ val scenario =
681+ scenarioApiService.findScenarioById(
682+ organizationId, scenarioRun.workspaceId!! , scenarioRun.scenarioId!! )
683+
684+ // PROD-12524
685+ // due to the hack do not check the status as usual as we forced the scenario's status to failed
686+ val scenariorRunStatus = getScenarioRunStatus(organizationId, scenarioRun)
687+ if (scenario.state == ScenarioJobState .Failed ) {
688+ return ScenarioRunStatus (
689+ id = scenariorRunStatus.id,
690+ organizationId = scenariorRunStatus.organizationId,
691+ workflowId = scenariorRunStatus.workflowId,
692+ workflowName = scenariorRunStatus.workflowName,
693+ startTime = scenariorRunStatus.startTime,
694+ endTime = scenariorRunStatus.endTime,
695+ phase = scenariorRunStatus.state.toString(),
696+ progress = scenariorRunStatus.progress,
697+ message = scenariorRunStatus.message,
698+ estimatedDuration = scenariorRunStatus.estimatedDuration,
699+ nodes = scenariorRunStatus.nodes)
700+ }
701+
702+ return scenariorRunStatus
683703 }
684704
685705 private fun getScenarioRunStatus (
@@ -857,10 +877,19 @@ class ScenarioRunServiceImpl(
857877
858878 override fun stopScenarioRun (organizationId : String , scenariorunId : String ): ScenarioRunStatus {
859879 val scenarioRun = findScenarioRunById(organizationId, scenariorunId)
860- val scenario =
880+ var scenario =
861881 scenarioApiService.findScenarioById(
862882 organizationId, scenarioRun.workspaceId!! , scenarioRun.scenarioId!! )
863883 csmRbac.verify(scenario.getRbac(), PERMISSION_WRITE , scenarioPermissions)
884+ // PROD-12524
885+ // As the workflow is not stopping when trying to stop it(argo version 0.16.6)
886+ // the workaround is to set the scenario's state to failed
887+ scenario.state = ScenarioJobState .Failed
888+ eventPublisher.publishEvent(
889+ ScenarioLastRunChanged (this , organizationId, scenarioRun.workspaceId, scenario))
890+
891+ val sr = scenarioRun.copy(state = ScenarioRunState .Failed )
892+ scenarioRunRepository.save(sr)
864893 return workflowService.stopWorkflow(findScenarioRunById(organizationId, scenariorunId))
865894 }
866895
0 commit comments