Skip updateMetadata step if there are network changes

Previous behavior would make it that an `updateMetadata` step would take
precedence over a `kill` step when network changes are present. This
would lead to an inconsistent state if an update included a
network and a container change.

Closes: #1576
Change-type: patch
This commit is contained in:
Felipe Lalanne 2023-04-25 12:00:02 -04:00
parent 0a358a4463
commit 7aecaae8b0

View File

@ -150,7 +150,7 @@ export class App {
.map((pair) => .map((pair) =>
this.generateStepsForService(pair, { this.generateStepsForService(pair, {
...state, ...state,
servicePairs: installPairs.concat(updatePairs), servicePairs,
targetApp: target, targetApp: target,
networkPairs: networkChanges, networkPairs: networkChanges,
volumePairs: volumeChanges, volumePairs: volumeChanges,
@ -528,10 +528,7 @@ export class App {
return generateStep('noop', {}); return generateStep('noop', {});
} }
if (target && current?.isEqualConfig(target, context.containerIds)) { if (current == null) {
// we're only starting/stopping a service
return this.generateContainerStep(current, target);
} else if (current == null) {
// Either this is a new service, or the current one has already been killed // Either this is a new service, or the current one has already been killed
return this.generateFetchOrStartStep( return this.generateFetchOrStartStep(
target!, target!,
@ -548,12 +545,21 @@ export class App {
'An empty changing pair passed to generateStepsForService', 'An empty changing pair passed to generateStepsForService',
); );
} }
const needsSpecialKill = this.serviceHasNetworkOrVolume( const needsSpecialKill = this.serviceHasNetworkOrVolume(
current, current,
context.networkPairs, context.networkPairs,
context.volumePairs, context.volumePairs,
); );
if (
!needsSpecialKill &&
current.isEqualConfig(target, context.containerIds)
) {
// we're only starting/stopping a service
return this.generateContainerStep(current, target);
}
let strategy = let strategy =
checkString(target.config.labels['io.balena.update.strategy']) || ''; checkString(target.config.labels['io.balena.update.strategy']) || '';
const validStrategies = [ const validStrategies = [