Release locks when removing apps

This prevents leftover locks that can prevent other operations from
taking place.

Change-type: patch
This commit is contained in:
Felipe Lalanne 2025-03-06 11:39:40 -03:00
parent 5ef6b054fd
commit 026dc0aed2
No known key found for this signature in database
GPG Key ID: 03E696BFD472B26A
2 changed files with 24 additions and 0 deletions

View File

@ -247,6 +247,16 @@ class AppImpl implements App {
}
}
// Release locks (if any) for all services before settling state
if (state.lock || state.hasLeftoverLocks) {
return [
generateStep('releaseLock', {
appId: this.appId,
lock: state.lock,
}),
];
}
return [];
}

View File

@ -2399,5 +2399,19 @@ describe('compose/app', () => {
const [releaseLockStep] = expectSteps('releaseLock', steps, 1);
expect(releaseLockStep).to.have.property('appId').that.equals(1);
});
it('should infer a releaseLock step when removing an app', async () => {
const current = createApp({
services: [],
networks: [],
});
const steps = current.stepsToRemoveApp({
...defaultContext,
lock: mockLock,
});
const [releaseLockStep] = expectSteps('releaseLock', steps, 1);
expect(releaseLockStep).to.have.property('appId').that.equals(1);
});
});
});