Skip to content

Commit

Permalink
Merge pull request #2406 from balena-os/release-locks-on-app-remove
Browse files Browse the repository at this point in the history
Release locks when removing apps
  • Loading branch information
flowzone-app[bot] authored Mar 6, 2025
2 parents 5ef6b05 + 026dc0a commit 7771c0e
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 7771c0e

Please sign in to comment.