mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-25 05:19:59 +00:00
Merge pull request #956 from balena-io/fix-service-comparison
Fix service comparison when starting a stopped service
This commit is contained in:
commit
e0db04e6a9
@ -650,22 +650,15 @@ export class Service {
|
|||||||
const differentArrayFields: string[] = [];
|
const differentArrayFields: string[] = [];
|
||||||
sameConfig =
|
sameConfig =
|
||||||
sameConfig &&
|
sameConfig &&
|
||||||
_.every(Service.configArrayFields, (field: ServiceConfigArrayField) => {
|
_.every(Service.configArrayFields, (field: keyof ServiceConfig) => {
|
||||||
return _.isEmpty(
|
const eq = _.isEqual(
|
||||||
_.xorWith(
|
_.sortBy(this.config[field] as Array<unknown>),
|
||||||
// TODO: The typings here aren't accepted, even though we
|
_.sortBy(service.config[field] as Array<unknown>),
|
||||||
// know it's fine
|
|
||||||
(this.config as any)[field],
|
|
||||||
(service.config as any)[field],
|
|
||||||
(a, b) => {
|
|
||||||
const eq = _.isEqual(a, b);
|
|
||||||
if (!eq) {
|
|
||||||
differentArrayFields.push(field);
|
|
||||||
}
|
|
||||||
return eq;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (!eq) {
|
||||||
|
differentArrayFields.push(field);
|
||||||
|
}
|
||||||
|
return eq;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(sameConfig && sameNetworks)) {
|
if (!(sameConfig && sameNetworks)) {
|
||||||
@ -844,15 +837,20 @@ export class Service {
|
|||||||
if (current.aliases == null) {
|
if (current.aliases == null) {
|
||||||
sameNetwork = false;
|
sameNetwork = false;
|
||||||
} else {
|
} else {
|
||||||
// Remove the auto-added docker container id
|
// Take out the container id from both aliases, as it *will* be present
|
||||||
const currentAliases = _.filter(current.aliases, (alias: string) => {
|
// in a currently running container, and can also be present in the target
|
||||||
return !_.startsWith(this.containerId!, alias);
|
// for example when doing a start-service
|
||||||
});
|
// Also sort the aliases, so we can do a simple comparison
|
||||||
const targetAliases = target.aliases || [];
|
const [currentAliases, targetAliases] = [
|
||||||
|
current.aliases,
|
||||||
sameNetwork = _.isEmpty(
|
target.aliases,
|
||||||
_.xorWith(currentAliases, targetAliases, _.isEqual),
|
].map(aliases =>
|
||||||
|
_.sortBy(
|
||||||
|
aliases.filter(a => !_.startsWith(this.containerId || '', a)),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
sameNetwork = _.isEqual(currentAliases, targetAliases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target.ipv4Address != null) {
|
if (target.ipv4Address != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user