fix: implement two-stage teardown for reliable atomic rollbacks

This commit is contained in:
SaelixCode
2026-03-06 10:18:47 -05:00
parent b90db0124c
commit fb3a28834e
4 changed files with 35 additions and 6 deletions
+13 -1
View File
@@ -1095,7 +1095,19 @@ app.post('/api/templates/deploy', async (req: Request, res: Response) => {
const shouldRollback = parsed.rule ? parsed.rule.canSilentlyRollback : true;
if (shouldRollback) {
await fileSystemService.deleteStack(stackName);
try {
// Stage 1: Tell Docker to clean up ghost networks/containers
await composeService.downStack(stackName);
} catch (downErr) {
console.error("Rollback Stage 1 (Docker down) failed:", downErr);
}
try {
// Stage 2: Obliterate the files
await fileSystemService.deleteStack(stackName);
} catch (fsErr) {
console.error("Rollback Stage 2 (File deletion) failed:", fsErr);
}
}
res.status(500).json({