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

yml parsing error | support groups #11

Open
fsemrau opened this issue Mar 3, 2016 · 1 comment
Open

yml parsing error | support groups #11

fsemrau opened this issue Mar 3, 2016 · 1 comment

Comments

@fsemrau
Copy link

fsemrau commented Mar 3, 2016

marathon_deploy fails when parsing the following yml (see file below).
We ensured that the yml can be converted to JSON and back to YAML with http://jsontoyaml.com/ and http://yamltojson.com/:

{
  "id": "/sample",
  "groups": [
    {
      "id": "service1",
      "args": [
        "-url",
        "http://consul.service.consul:8500"
      ],
      "cpus": 0.1,
      "mem": 5,
      "instances": 1,
      "constraints": [
        "hostname",
        "UNIQUE"
      ],
      "container": {
        "docker": {
          "image": "...",
          "network": "BRIDGE"
        },
        "type": "DOCKER"
      },
      "env": {
        "SERVICE_NAME": "service1"
      }
    },
    {
      "cmd": "...", 
      "id": "proxy",
      "cpus": 0.1,
      "mem": 32,
      "instances": 1,
      "constraints": [
        "hostname",
        "UNIQUE"
      ],
      "container": {
        "docker": {
          "image": "sameersbn/squid:3.3.8-8",
          "network": "BRIDGE",
          "portMappings": [
            {
              "protocol": "tcp",
              "containerPort": 3128,
              "servicePort": 3128,
              "hostPort": 0
            }
          ]
        },
        "type": "DOCKER"
      },
      "healthChecks": [
        {
          "portIndex": 0,
          "protocol": "TCP",
          "gracePeriodSeconds": 15,
          "intervalSeconds": 10,
          "timeoutSeconds": 20,
          "maxConsecutiveFailures": 3
        }
      ],
      "env": {
        "SERVICE_NAME": "proxy",
        "SERVICE_TAGS": "proxy,haproxy,haproxy_tcp=3128"
      }
    }
  ]
}

marathon_deploy gives us this error:

$ marathon_deploy local-groups.yml -u http://192.168.10.10:8080
/Library/Ruby/Gems/2.0.0/gems/marathon_deploy-0.1.48/lib/marathon_deploy/application.rb:39:in `initialize': undefined method `each' for nil:NilClass (NoMethodError)
    from /Library/Ruby/Gems/2.0.0/gems/marathon_deploy-0.1.48/bin/marathon_deploy:136:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/marathon_deploy-0.1.48/bin/marathon_deploy:136:in `<top (required)>'
    from /usr/local/bin/marathon_deploy:23:in `load'
    from /usr/local/bin/marathon_deploy:23:in `<main>'

Just guessing, but maybe this would do the trick? In application.rb (line 37):

    # JSON fix for marathon
    # marathon require ENV variables to be quoted
    @json['env'].each do |key, value|
      if (value.is_a? Numeric)
        @json['env'][key] = value.to_json
      end
    end if json['env']

just replace the closing end with end if json['env']

@sielaq
Copy link
Contributor

sielaq commented Mar 10, 2016

Hi,

This is bigger problem here.

problem is that we never supported groups - that would require rewrite some part of code (injecting ENV variables per app in array / setting defaults instances / memory etc.. )
We could do the easy way first ans support groups without extra features like singe app have.

but is your example even working by
curl -X POST -H "Content-Type: application/json" http://$HOSTNAME:8080/v2/apps/ [email protected] ?
I suspect that some part is missing

@sielaq sielaq changed the title yml parsing error yml parsing error | support groups Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants