Skip to content

Commit

Permalink
Release locks when removing apps
Browse files Browse the repository at this point in the history
This prevents leftover locks that can prevent other operations from
taking place.

Change-type: patch
  • Loading branch information
pipex committed Mar 6, 2025
1 parent 5ef6b05 commit 026dc0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/compose/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}

Expand Down
14 changes: 14 additions & 0 deletions test/unit/compose/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit 026dc0a

Please sign in to comment.