mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-24 07:46:41 +00:00
Merge pull request #1992 from balena-os/1991-wait-for-stopping-services-in-funnel
Wait for Stopping services to stop before target apply success
This commit is contained in:
commit
1c7110badb
@ -360,6 +360,18 @@ export class App {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if Supervisor should keep the state loop alive while waiting on a service to stop
|
||||
* @param serviceCurrent
|
||||
* @param serviceTarget
|
||||
*/
|
||||
const shouldWaitForStop = (serviceCurrent: Service) => {
|
||||
return (
|
||||
serviceCurrent.config.running === true &&
|
||||
serviceCurrent.status === 'Stopping'
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter all the services which should be updated due to run state change, or config mismatch.
|
||||
*/
|
||||
@ -372,7 +384,8 @@ export class App {
|
||||
({ current: c, target: t }) =>
|
||||
!isEqualExceptForRunningState(c, t) ||
|
||||
shouldBeStarted(c, t) ||
|
||||
shouldBeStopped(c, t),
|
||||
shouldBeStopped(c, t) ||
|
||||
shouldWaitForStop(c),
|
||||
);
|
||||
|
||||
return {
|
||||
|
@ -657,6 +657,23 @@ describe('compose/app', () => {
|
||||
expectNoStep('kill', steps);
|
||||
});
|
||||
|
||||
it('should emit a noop while waiting on a stopping service', async () => {
|
||||
const current = createApp({
|
||||
services: [
|
||||
await createService(
|
||||
{ serviceName: 'main', running: true },
|
||||
{ state: { status: 'Stopping' } },
|
||||
),
|
||||
],
|
||||
});
|
||||
const target = createApp({
|
||||
services: [await createService({ serviceName: 'main', running: true })],
|
||||
});
|
||||
|
||||
const steps = current.nextStepsForAppUpdate(defaultContext, target);
|
||||
expectSteps('noop', steps);
|
||||
});
|
||||
|
||||
it('should remove a dead container that is still referenced in the target state', async () => {
|
||||
const current = createApp({
|
||||
services: [
|
||||
|
Loading…
Reference in New Issue
Block a user