from_json always creates mappings with host port
Opened this issue · 0 comments
mikekatica commented
When generating a MarathonApp object (or any object between it and MarathonContainerPortMapping) from a dict using from_json, a host port of 0 is always included. This causes undesired behavior when not trying to map a container port to a host port, especially in DCOS, where the overlay network can be used instead. See below:
{
"id": "/uhttpd",
"backoffFactor": 1.15,
"backoffSeconds": 1,
"container": {
"type": "DOCKER",
"volumes": [],
"docker": {
"image": "fnichol/uhttpd",
"forcePullImage": false,
"privileged": false,
"parameters": [],
"portMappings": [
{
"containerPort": 80,
"servicePort": 10087,
"name": "http"
}
]
}
},
"cpus": 0.1,
"disk": 0,
"healthChecks": [
{
"gracePeriodSeconds": 60,
"ignoreHttp1xx": false,
"intervalSeconds": 5,
"maxConsecutiveFailures": 3,
"portIndex": 0,
"timeoutSeconds": 20,
"delaySeconds": 5,
"protocol": "HTTP",
"path": "/"
}
],
"instances": 1,
"labels": {
"HAPROXY_GROUP": "internal"
},
"maxLaunchDelaySeconds": 3600,
"mem": 128,
"gpus": 0,
"networks": [
{
"name": "dcos",
"mode": "container"
}
],
"requirePorts": false,
"upgradeStrategy": {
"maximumOverCapacity": 1,
"minimumHealthCapacity": 1
},
"killSelection": "YOUNGEST_FIRST",
"unreachableStrategy": {
"inactiveAfterSeconds": 300,
"expungeAfterSeconds": 600
},
"fetch": [],
"constraints": []
}
Creates the following MarathonContainer:
MarathonContainer::{"docker": {"forcePullImage": false, "image": "fnichol/uhttpd", "parameters": [], "portMappings": [{"containerPort": 80, "hostPort": 0, "labels": null, "name": "http", "protocol": "tcp", "servicePort": 10087}], "privileged": false}, "type": "DOCKER", "volumes": []}
But should create:
MarathonContainer::{"docker": {"forcePullImage": false, "image": "fnichol/uhttpd", "parameters": [], "portMappings": [{"containerPort": 80, "labels": null, "name": "http", "protocol": "tcp", "servicePort": 10087}], "privileged": false}, "type": "DOCKER", "volumes": []}