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

Docker bridge #621

Merged
merged 13 commits into from Sep 26, 2014
Merged

Docker bridge #621

merged 13 commits into from Sep 26, 2014

Conversation

ConnorDoyle
Copy link
Contributor

Fixes #587 (Docker bridged networking mode)

For initial review.

  • Update docs
  • Update Mesos dependency once version 0.20.1 is released
  • Do dynamic global port assignments
  • Verify ports attribute works as expected
  • Publish and update dependency of mesos-utils for 0.20.1

@ConnorDoyle ConnorDoyle added this to the 0.7.1 milestone Sep 23, 2014
@ConnorDoyle
Copy link
Contributor Author

Looking pretty good so far!
Here's an example HTTP request for a bridged Docker app with health checks and two healthy tasks:

GET /v2/apps/bridged-webapp/ HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Host: mesos.vm:8080
User-Agent: HTTPie/0.8.0
HTTP/1.1 200 OK
Content-Type: application/json
Server: Jetty(8.y.z-SNAPSHOT)
Transfer-Encoding: chunked

{
    "app": {
        "args": null, 
        "backoffFactor": 1.15, 
        "backoffSeconds": 1, 
        "cmd": "python3 -m http.server 8080", 
        "constraints": [], 
        "container": {
            "docker": {
                "image": "python:3", 
                "network": "BRIDGE", 
                "portMappings": [
                    {
                        "containerPort": 8080, 
                        "hostPort": 0, 
                        "protocol": "tcp"
                    }, 
                    {
                        "containerPort": 161, 
                        "hostPort": 0, 
                        "protocol": "udp"
                    }
                ]
            }, 
            "type": "DOCKER", 
            "volumes": []
        }, 
        "cpus": 0.5, 
        "dependencies": [], 
        "deployments": [], 
        "disk": 0.0, 
        "env": {}, 
        "executor": "", 
        "healthChecks": [
            {
                "command": null, 
                "gracePeriodSeconds": 5, 
                "intervalSeconds": 20, 
                "maxConsecutiveFailures": 3, 
                "path": "/", 
                "portIndex": 0, 
                "protocol": "HTTP", 
                "timeoutSeconds": 20
            }
        ], 
        "id": "/bridged-webapp", 
        "instances": 2, 
        "mem": 64.0, 
        "ports": [
            10000, 
            10001
        ], 
        "requirePorts": false, 
        "storeUrls": [], 
        "tasks": [
            {
                "appId": "/bridged-webapp", 
                "healthCheckResults": [
                    {
                        "alive": true, 
                        "consecutiveFailures": 0, 
                        "firstSuccess": "2014-09-25T02:47:40.805Z", 
                        "lastFailure": null, 
                        "lastSuccess": "2014-09-25T02:51:21.025Z", 
                        "taskId": "bridged-webapp.4d5e55dc-445e-11e4-b90b-56847afe9799"
                    }
                ], 
                "host": "10.141.141.10", 
                "id": "bridged-webapp.4d5e55dc-445e-11e4-b90b-56847afe9799", 
                "ports": [
                    31004, 
                    31005
                ], 
                "stagedAt": "2014-09-25T02:47:34.361Z", 
                "startedAt": "2014-09-25T02:51:01.661Z", 
                "version": "2014-09-25T02:26:59.256Z"
            }, 
            {
                "appId": "/bridged-webapp", 
                "healthCheckResults": [
                    {
                        "alive": true, 
                        "consecutiveFailures": 0, 
                        "firstSuccess": "2014-09-25T02:39:20.314Z", 
                        "lastFailure": null, 
                        "lastSuccess": "2014-09-25T02:51:21.026Z", 
                        "taskId": "bridged-webapp.1d63944b-445d-11e4-b90b-56847afe9799"
                    }
                ], 
                "host": "10.141.141.10", 
                "id": "bridged-webapp.1d63944b-445d-11e4-b90b-56847afe9799", 
                "ports": [
                    31002, 
                    31003
                ], 
                "stagedAt": "2014-09-25T02:39:04.369Z", 
                "startedAt": "2014-09-25T02:51:01.673Z", 
                "version": "2014-09-25T02:26:59.256Z"
            }
        ], 
        "tasksRunning": 2, 
        "tasksStaged": 0, 
        "upgradeStrategy": {
            "minimumHealthCapacity": 1.0
        }, 
        "uris": [], 
        "user": null, 
        "version": "2014-09-25T02:26:59.256Z"
    }
}

and Docker agrees:

vagrant@mesos:~ $ sudo docker ps -a --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND                                    CREATED             STATUS              PORTS                                             NAMES
27429bd10ca0bbc48615a1fd9e2dc559ab98fd65d4a5ec84d6bdbceedec8d829   python:3            /bin/sh -c 'python3 -m http.server 8080'   7 minutes ago       Up 7 minutes        0.0.0.0:31004->8080/tcp, 0.0.0.0:31005->161/udp   mesos-a837b7b6-e5c0-4163-b861-2773730358bd
98e71b42ff6e7834be5a78094384ee36969d203676b1457e168ac28eef7f6668   python:3            /bin/sh -c 'python3 -m http.server 8080'   15 minutes ago      Up 15 minutes       0.0.0.0:31002->8080/tcp, 0.0.0.0:31003->161/udp   mesos-7b88cae1-ac93-4cf7-ac05-c71930bbe48f

@ConnorDoyle
Copy link
Contributor Author

@drexin @michaeljin ready for review 🔍


val mappingsWithAssignedRandoms = mappings.map {
case PortMapping(containerPort, 0, protocol) =>
PortMapping(containerPort, availablePorts.next, protocol)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if availablePorts is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, will modify this to surface any throwables wrapped by the Try -- in fact, will probably change the method signature to just return the Try.

@drexin
Copy link
Contributor

drexin commented Sep 25, 2014

LGTM, except for the 2 comments

@ConnorDoyle
Copy link
Contributor Author

@drexin thanks for reviewing! Bringing the 🔨 down on the big shiny merge button.

ConnorDoyle added a commit that referenced this pull request Sep 26, 2014
@ConnorDoyle ConnorDoyle merged commit f7655ff into master Sep 26, 2014
@ConnorDoyle ConnorDoyle deleted the docker_bridge branch September 26, 2014 01:02
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

Successfully merging this pull request may close these issues.

Support bridged networking mode for Docker containerizer
4 participants