mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 01:36:18 +00:00
Only start a container once in its lifetime
This will ensure the restart policy specified is not violated Change-type: patch Closes: #1668 Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
This commit is contained in:
parent
9aa50eea8a
commit
ca9945bdfb
@ -336,15 +336,13 @@ export class App {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we previously remember starting it
|
||||
if (
|
||||
applicationManager.containerStarted[serviceCurrent.containerId!] != null
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the config otherwise matches, then we should be running
|
||||
return isEqualExceptForRunningState(serviceCurrent, serviceTarget);
|
||||
// Only start a Service if we have never started it before and the service matches target!
|
||||
// This is so the engine can handle the restart policy configured for the container.
|
||||
return (
|
||||
(serviceCurrent.status === 'Installing' ||
|
||||
serviceCurrent.status === 'Installed') &&
|
||||
isEqualExceptForRunningState(serviceCurrent, serviceTarget)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -951,7 +951,7 @@ describe('compose/app', () => {
|
||||
applicationManager.containerStarted = {};
|
||||
});
|
||||
|
||||
it('should create a start step when all that changes is a running state', async () => {
|
||||
it('should not create a start step when all that changes is a running state', async () => {
|
||||
const contextWithImages = {
|
||||
...defaultContext,
|
||||
...{
|
||||
@ -972,13 +972,10 @@ describe('compose/app', () => {
|
||||
isTarget: true,
|
||||
});
|
||||
|
||||
// now should see a 'start'
|
||||
const steps = current.nextStepsForAppUpdate(contextWithImages, target);
|
||||
|
||||
const [startStep] = expectSteps('start', steps);
|
||||
expect(startStep)
|
||||
.to.have.property('target')
|
||||
.that.deep.includes({ serviceName: 'main' });
|
||||
// There should be no steps since the engine manages restart policy for stopped containers
|
||||
expect(steps.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('should create a kill step when a service release has to be updated but the strategy is kill-then-download', async () => {
|
||||
|
@ -208,7 +208,7 @@ describe('compose/application-manager', () => {
|
||||
|
||||
// TODO: missing tests for getCurrentApps
|
||||
|
||||
it('infers a start step when all that changes is a running state', async () => {
|
||||
it('should not infer a start step when all that changes is a running state', async () => {
|
||||
const targetApps = createApps(
|
||||
{
|
||||
services: [await createService({ running: true, appId: 1 })],
|
||||
@ -226,7 +226,7 @@ describe('compose/application-manager', () => {
|
||||
networks: [DEFAULT_NETWORK],
|
||||
});
|
||||
|
||||
const [startStep] = await applicationManager.inferNextSteps(
|
||||
const steps = await applicationManager.inferNextSteps(
|
||||
currentApps,
|
||||
targetApps,
|
||||
{
|
||||
@ -236,10 +236,8 @@ describe('compose/application-manager', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(startStep).to.have.property('action').that.equals('start');
|
||||
expect(startStep)
|
||||
.to.have.property('target')
|
||||
.that.deep.includes({ serviceName: 'main' });
|
||||
// There should be no steps since the engine manages restart policy for stopped containers
|
||||
expect(steps.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('infers a kill step when a service has to be removed', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user