Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_json always creates mappings with host port #244

Open
mikekatica opened this issue Mar 7, 2018 · 0 comments
Open

from_json always creates mappings with host port #244

mikekatica opened this issue Mar 7, 2018 · 0 comments

Comments

@mikekatica
Copy link

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": []}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant