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