mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-02 17:12:56 +00:00
compose: Normalise target ports for comparison with docker's output
Docker always returns ports in ascending order, so if they aren't specified like that in the compose, a restart loop would occur. This patch changes the port maps to be stored in ascending order, based on an alphabetical sort of the internalStart port (not taking into account the protocol). This is the same as how Docker returns them, so they will match, regardless of input form. Change-type: patch Closes: #824 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
68aa34927b
commit
557c32b80e
@ -139,6 +139,12 @@ export class PortMap {
|
||||
}, []);
|
||||
}
|
||||
|
||||
public static normaliseComposePorts(portMaps: PortMap[]): PortMap[] {
|
||||
return _.sortBy(portMaps, p => {
|
||||
return p.ports.internalStart;
|
||||
});
|
||||
}
|
||||
|
||||
private parsePortString(portStr: string): void {
|
||||
const match = portStr.match(PORTS_REGEX);
|
||||
if (match == null) {
|
||||
|
@ -253,7 +253,9 @@ export class Service {
|
||||
|
||||
let portMaps: PortMap[] = [];
|
||||
if (config.ports != null) {
|
||||
portMaps = _.map(config.ports, p => new PortMap(p));
|
||||
portMaps = PortMap.normaliseComposePorts(
|
||||
_.map(config.ports, p => new PortMap(p)),
|
||||
);
|
||||
}
|
||||
delete config.ports;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user