mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-30 16:14:11 +00:00
Wait for Stopping services to stop before target apply success
This mitigates an edge case bug introduced in v13.1.3 where services that are slow to exit may get stuck in a state of Downloaded if a service var is changed then reverted rapidly. More detailed description in linked issue. Change-type: patch Closes: #1991 Signed-off-by: Christina Wang <christina@balena.io>
This commit is contained in:
parent
936ada7f64
commit
12b67742c8
@ -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.
|
* 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 }) =>
|
({ current: c, target: t }) =>
|
||||||
!isEqualExceptForRunningState(c, t) ||
|
!isEqualExceptForRunningState(c, t) ||
|
||||||
shouldBeStarted(c, t) ||
|
shouldBeStarted(c, t) ||
|
||||||
shouldBeStopped(c, t),
|
shouldBeStopped(c, t) ||
|
||||||
|
shouldWaitForStop(c),
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -657,6 +657,23 @@ describe('compose/app', () => {
|
|||||||
expectNoStep('kill', steps);
|
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 () => {
|
it('should remove a dead container that is still referenced in the target state', async () => {
|
||||||
const current = createApp({
|
const current = createApp({
|
||||||
services: [
|
services: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user