diff --git a/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts b/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts index 041d17d2..cde47afe 100644 --- a/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts +++ b/app/gateway-api/src/orchestrator/gatewayOrchestrator.ts @@ -975,11 +975,12 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle { try { await this.processManager.stop(name); } catch { - try { - await this.processManager.delete(name); - } catch (error) { - failures.push(`${name}: ${error instanceof Error ? error.message : String(error)}`); - } + // Deleting the definition below also terminates a process that raced with stop. + } + try { + await this.processManager.delete(name); + } catch (error) { + failures.push(`${name}: ${error instanceof Error ? error.message : String(error)}`); } } if (failures.length > 0) { diff --git a/app/gateway-api/test/orchestratorOperations.test.ts b/app/gateway-api/test/orchestratorOperations.test.ts index de3b7809..ece1b258 100644 --- a/app/gateway-api/test/orchestratorOperations.test.ts +++ b/app/gateway-api/test/orchestratorOperations.test.ts @@ -153,6 +153,7 @@ describe('GatewayOrchestrator first-class operations', () => { expect(harness.statuses).toEqual(['STOPPED']); expect(harness.stopped).toEqual(['sammo:che:2:game-api', 'sammo:che:2:turn-daemon']); + expect(harness.deleted).toEqual(['sammo:che:2:game-api', 'sammo:che:2:turn-daemon']); expect(harness.completions).toEqual(['SUCCEEDED']); });