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

unmarshal failed when set ulimit with -1 #154

Open
ermaker opened this issue May 17, 2016 · 4 comments
Open

unmarshal failed when set ulimit with -1 #154

ermaker opened this issue May 17, 2016 · 4 comments

Comments

@ermaker
Copy link

ermaker commented May 17, 2016

This works: (very simliar to Swarm Example)

$ cat docker-compose.yml                                                                                                                                                                  version: '2'
services:
  interlock:
    image: ehazlett/interlock:1.1.1
    container_name: interlock
    command: -D run
    ports:
      - 8080
    environment:
      INTERLOCK_CONFIG: |
        ListenAddr = ":8080"
        DockerURL = "unix:///var/run/docker.sock"
        TLSCACert = "/etc/docker/ca.pem"
        TLSCert = "/etc/docker/server.pem"
        TLSKey = "/etc/docker/server-key.pem"
        [[Extensions]]
        Name = "nginx"
        ConfigPath = "/etc/nginx/nginx.conf"
        PidPath = "/var/run/nginx.pid"
        TemplatePath = ""
        MaxConn = 1024
    volumes:
      - /etc/docker:/etc/docker:ro
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: bridge
    restart: always
  nginx:
    image: nginx
    container_name: nginx
    entrypoint: nginx
    command: -g "daemon off;" -c /etc/nginx/nginx.conf
    ports:
      - 80:80
    labels:
      - "interlock.ext.name=nginx"
    network_mode: bridge
    restart: always
  app:
    image: ehazlett/docker-demo
    container_name: app
    hostname: test.local
    ulimits:
      memlock: 1
    ports:
      - 8080
$ docker-compose up                                                                                                                                                                       Creating network "test2_default" with the default driver
Creating app
Creating nginx
Creating interlock
Attaching to interlock, app, nginx
interlock    | time="2016-05-17T13:45:58Z" level=info msg="interlock 1.1.1 (8e4ea06)"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="loading config from environment"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="using tls for communication with docker"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="docker client: url=unix:///var/run/docker.sock"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="loading extension: name=nginx"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="using internal configuration template" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=info msg="interlock node: id=cab6f5a8943f333e0ee8e48bae819d449ada45e34e03013e6dd37ac545ac5b6f" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="starting event handling"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="event received: status=interlock-start id=0 type= action="
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="triggering reload" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="event received: status=start id=cab6f5a8943f333e0ee8e48bae819d449ada45e34e03013e6dd37ac545ac5b6f type=container action=start"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="inspecting container: id=cab6f5a8943f333e0ee8e48bae819d449ada45e34e03013e6dd37ac545ac5b6f" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="checking container labels: id=cab6f5a8943f333e0ee8e48bae819d449ada45e34e03013e6dd37ac545ac5b6f" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="ignoring interlock container: id=cab6f5a8943f333e0ee8e48bae819d449ada45e34e03013e6dd37ac545ac5b6f" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="event received: status=start id=8d04dd5605109038c30d2c21dddca01d6b8078b965ac657ab02edac53d535036 type=container action=start"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="inspecting container: id=8d04dd5605109038c30d2c21dddca01d6b8078b965ac657ab02edac53d535036" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="checking container labels: id=8d04dd5605109038c30d2c21dddca01d6b8078b965ac657ab02edac53d535036" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="checking container ports: id=8d04dd5605109038c30d2c21dddca01d6b8078b965ac657ab02edac53d535036" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="container is monitored; triggering reload: id=8d04dd5605109038c30d2c21dddca01d6b8078b965ac657ab02edac53d535036" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="triggering reload" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="event received: status=start id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342 type=container action=start"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="inspecting container: id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="checking container labels: id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342" ext=lb
interlock    | time="2016-05-17T13:45:58Z" level=debug msg="ignoring proxy container: id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342" ext=lb
app          | 2016/05/17 13:45:58 listening on :8080
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="reaping key: reload"
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="triggering reload from cache" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="checking to reload" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="updating load balancers" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="generating proxy config" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="websocket endpoints: []" ext=nginx
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="alias domains: []" ext=nginx
interlock    | time="2016-05-17T13:45:59Z" level=info msg="test.local: upstream=0.0.0.0:32806" ext=nginx
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="proxy config path: /etc/nginx/nginx.conf" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="detected proxy container: id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342 backend=nginx" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="proxyContainers: [{64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342 [/nginx] nginx nginx -g 'daemon off;' -c /etc/nginx/nginx.conf 1463492757 Up Less than a second [{0.0.0.0 80 80 tcp} { 443 0 tcp}] 0 0 map[com.docker.compose.project:test2 com.docker.compose.service:nginx com.docker.compose.version:1.7.0 interlock.ext.name:nginx com.docker.compose.config-hash:64e25fac2cc8b6bb78fd6ebcef977907f5f68155988d96252025929a63f0f2f3 com.docker.compose.container-number:1 com.docker.compose.oneoff:False] {map[bridge:{<nil> [] []  0427b7de1768060bc2ea80b0489be2bf523452e3868d70cf5080ceb11aeeb0c7 172.17.0.1 172.17.0.3 16   0 02:42:ac:11:00:03}]}}]" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="saving proxy config" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="updating proxy config: id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="signaling reload" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="event received: status=extract-to-dir id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342 type=container action=extract-to-dir"
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="event received: status=kill id=64f40ec27dd0e12f2b39963a08c82a0b2055b29207a5636667a614d265860342 type=container action=kill"
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:45:59Z" level=info msg="restarted proxy container: id=64f40ec27dd0 name=/nginx" ext=nginx
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="triggering proxy network cleanup" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=info msg="reload duration: 71.75ms" ext=lb
interlock    | time="2016-05-17T13:45:59Z" level=debug msg="checking to remove proxy containers from networks" ext=lb

But when setting ulimit to -1 (-1 means unlimited and there is no way to set to unlimited), interlock fails.

$ cat docker-compose.yml                                                                                                                                                                  version: '2'
services:
  interlock:
    image: ehazlett/interlock:1.1.1
    container_name: interlock
    command: -D run
    ports:
      - 8080
    environment:
      INTERLOCK_CONFIG: |
        ListenAddr = ":8080"
        DockerURL = "unix:///var/run/docker.sock"
        TLSCACert = "/etc/docker/ca.pem"
        TLSCert = "/etc/docker/server.pem"
        TLSKey = "/etc/docker/server-key.pem"
        [[Extensions]]
        Name = "nginx"
        ConfigPath = "/etc/nginx/nginx.conf"
        PidPath = "/var/run/nginx.pid"
        TemplatePath = ""
        MaxConn = 1024
    volumes:
      - /etc/docker:/etc/docker:ro
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: bridge
    restart: always
  nginx:
    image: nginx
    container_name: nginx
    entrypoint: nginx
    command: -g "daemon off;" -c /etc/nginx/nginx.conf
    ports:
      - 80:80
    labels:
      - "interlock.ext.name=nginx"
    network_mode: bridge
    restart: always
  app:
    image: ehazlett/docker-demo
    container_name: app
    hostname: test.local
    ulimits:
      memlock: -1
    ports:
      - 8080
$ docker-compose up                                                                                                                                                                       Creating network "test2_default" with the default driver
Creating app
Creating nginx
Creating interlock
Attaching to app, nginx, interlock
app          | 2016/05/17 13:48:04 listening on :8080
interlock    | time="2016-05-17T13:48:04Z" level=info msg="interlock 1.1.1 (8e4ea06)"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="loading config from environment"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="using tls for communication with docker"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="docker client: url=unix:///var/run/docker.sock"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="loading extension: name=nginx"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="using internal configuration template" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=info msg="interlock node: id=e443c10964514962eed4d8c3f0eaf252dcb45c3a4fea455cf5720be9779fcb25" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="starting event handling"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="event received: status=interlock-start id=0 type= action="
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="triggering reload" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="event received: status=start id=e443c10964514962eed4d8c3f0eaf252dcb45c3a4fea455cf5720be9779fcb25 type=container action=start"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="notifying extension: lb"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="inspecting container: id=e443c10964514962eed4d8c3f0eaf252dcb45c3a4fea455cf5720be9779fcb25" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="checking container labels: id=e443c10964514962eed4d8c3f0eaf252dcb45c3a4fea455cf5720be9779fcb25" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="ignoring interlock container: id=e443c10964514962eed4d8c3f0eaf252dcb45c3a4fea455cf5720be9779fcb25" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="reaping key: reload"
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="triggering reload from cache" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="checking to reload" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="updating load balancers" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=debug msg="generating proxy config" ext=lb
interlock    | time="2016-05-17T13:48:04Z" level=error msg="json: cannot unmarshal number -1 into Go value of type uint64" ext=lb

I think interlock does not handle the value -1 (which means unlimited), and I hope interlock handles it.
I attached my environment and container which make fail.

Thank you.

$ docker version                                                                                                                                                                          Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:30:23 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:30:23 2016
 OS/Arch:      linux/amd64
$ docker-compose version                                                                                                                                                                  docker-compose version 1.7.0, build 0d7bf73
docker-py version: 1.8.0
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
$ uname -a                                                                                                                                                                                Linux dev 3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ docker inspect app                                                                                                                                                                      [
    {
        "Id": "284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b",
        "Created": "2016-05-17T13:51:09.906017029Z",
        "Path": "/bin/docker-demo",
        "Args": [
            "-listen=:8080"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 9280,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2016-05-17T13:51:10.060165813Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:69b663051ba5740f495dc86f6eca34bc98f6704672298356bb200aea036e94bd",
        "ResolvConfPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/hostname",
        "HostsPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/hosts",
        "LogPath": "/var/lib/docker/containers/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b/284032cb1fffa676fd382d252f2a5d0c8dbddbb9400737114a315fc870d84a1b-json.log",
        "Name": "/app",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "test2_default",
            "PortBindings": {
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": ""
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "StorageOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": [
                {
                    "Name": "memlock",
                    "Hard": -1,
                    "Soft": -1
                }
            ],
            "CpuCount": 0,
            "CpuPercent": 0,
            "BlkioIOps": 0,
            "BlkioBps": 0,
            "SandboxSize": 0
        },
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "Mounts": [],
        "Config": {
            "Hostname": "test",
            "Domainname": "local",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "-listen=:8080"
            ],
            "Image": "ehazlett/docker-demo",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/bin/docker-demo"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "a74c0dbc9be4e2b268244966f4d99e3fe0b47660424edcde7f84f2990cce0791",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "test2",
                "com.docker.compose.service": "app",
                "com.docker.compose.version": "1.7.0"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "2e81ad8e6a44ee396e618d5dbb0b3a27f352e707b316cfd593a14331c955bf62",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8080/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32809"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/2e81ad8e6a44",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "test2_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "app",
                        "284032cb1fff"
                    ],
                    "NetworkID": "5cc8abf32d129693cd4a7c846a423a32f0c8b93c52ea6c543f15ee6d41cd2e8b",
                    "EndpointID": "06cb88a36cdf04949ff6e287821ecc34e854810f2414d5e41fe902f885dcb61d",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:02"
                }
            }
        }
    }
]
@ehazlett
Copy link
Owner

It's trying to convert to a uint. Try setting it to "-1". (add the quotes so it's a string. this should get passed to the engine).

@ermaker
Copy link
Author

ermaker commented May 17, 2016

Trying setting it to "-1" fails on docker-compose.

$ docker-compose up
ERROR: Validation failed in file './docker-compose.yml', reason(s):
services.app.ulimits.memlock contains an invalid type, it should be an integer, or an object

Also fails without docker-compose. option "-1" converts to int, neither uint nor string.

$ docker run -d --ulimit memlock=-1 --name app ehazlett/docker-demo
1db141cac32f382304210d9107d97146c709e0f43321052eb4fa710ec7bedf17
$ docker inspect  app | grep Ulimit -A 5
            "Ulimits": [
                {
                    "Name": "memlock",
                    "Hard": -1,
                    "Soft": -1
                }

I think it may be a bug for samalba/dockerclient, because the types defined between dockerclient and docker/go-unit are different.

So I issued this problem to dockerclient, too. samalba/dockerclient#239

@ehazlett
Copy link
Owner

ehazlett commented Jun 6, 2016

Internally we should move to the official Docker Go library (docker/engine-api). That should fix these.

@ermaker
Copy link
Author

ermaker commented Jun 15, 2016

I got it. Thank you for kindly reply.

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

2 participants