Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-08-02 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated Aug. 2, 2017, 4:10 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Addressed comments.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/8/

Changes: https://reviews.apache.org/r/60558/diff/7-8/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-08-02 Thread Qian Zhang


> On Aug. 2, 2017, 11:16 a.m., Avinash sridharan wrote:
> > src/docker/docker.cpp
> > Lines 909 (patched)
> > 
> >
> > Failure(
> > "--dns option ..."); ?

That seems the convention in that file (`src/docker/docker.cpp`), you can take 
a look at all other places in that file, they are all in that style. Let's keep 
consistent for now, we can address all of them in a separate patch in future if 
needed.


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181933
---


On Aug. 1, 2017, 4:41 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated Aug. 1, 2017, 4:41 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/7/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-08-01 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181933
---


Fix it, then Ship it!




Ship It!


src/docker/docker.cpp
Lines 748 (patched)


Minor nit, maybe declare:
`using mesos::internal::ContainerDNSInfo`? Will shorten the code here.



src/docker/docker.cpp
Lines 764 (patched)


s/,it applies/. It applies



src/docker/docker.cpp
Lines 909 (patched)


Failure(
"--dns option ..."); ?


- Avinash sridharan


On Aug. 1, 2017, 8:41 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated Aug. 1, 2017, 8:41 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/7/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-08-01 Thread Qian Zhang


> On Aug. 1, 2017, 1:24 a.m., Avinash sridharan wrote:
> > src/docker/docker.cpp
> > Lines 755-765 (patched)
> > 
> >
> > This looks really complicated with the `wildcard entry` thrown into 
> > play. Can I suggest storing the DNS entries into a private variable within 
> > `Docker` on the following lines?
> > 
> > Option bridgeDNS;
> > hashmap userDNS;
> > 
> > For wildcard we use the key as "*" in the userDNS network (or you can 
> > keep an explicit variable for user nertworks. 
> > 
> > If we have these variables and populate them from the flags passed to 
> > docker executor, the code here becomes relatively simple which will be 
> > something along the lines of:
> > 
> > if (dockerInfo.network() == ContainerInfo::DocckerInfo::BRIDGE && 
> > bridgeDNS.isSome() {
> >   
> > } else if (dockerInfo.network() == ContainerInfo::DockerInfo::USER && 
> > userDNS.contains(options.network.get()) {
> >   ...
> > } else if (dockerInfo.network() == ContainerInfo::DockerInfo::USER && 
> > userDNS.contains("*") {
> > }

+1

And I'd like to use a dedicated variable (rather than "`*`") for default DNS 
for user-defined network, since "`*`" is a valid Docker network name.


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181816
---


On Aug. 1, 2017, 4:41 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated Aug. 1, 2017, 4:41 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/7/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search 

Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-08-01 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated Aug. 1, 2017, 4:41 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Addressed comments.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/7/

Changes: https://reviews.apache.org/r/60558/diff/6-7/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-31 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181816
---




src/docker/docker.cpp
Lines 755-765 (patched)


This looks really complicated with the `wildcard entry` thrown into play. 
Can I suggest storing the DNS entries into a private variable within `Docker` 
on the following lines?

Option bridgeDNS;
hashmap userDNS;

For wildcard we use the key as "*" in the userDNS network (or you can keep 
an explicit variable for user nertworks. 

If we have these variables and populate them from the flags passed to 
docker executor, the code here becomes relatively simple which will be 
something along the lines of:

if (dockerInfo.network() == ContainerInfo::DocckerInfo::BRIDGE && 
bridgeDNS.isSome() {
  
} else if (dockerInfo.network() == ContainerInfo::DockerInfo::USER && 
userDNS.contains(options.network.get()) {
  ...
} else if (dockerInfo.network() == ContainerInfo::DockerInfo::USER && 
userDNS.contains("*") {
}



src/docker/docker.cpp
Lines 770 (patched)


s/apples/applies?



src/docker/docker.cpp
Lines 783-793 (patched)


We should convert this into a lambda and then invoke the lambda in the `if` 
and the `else if` conditional below. Will avoid code duplication.


- Avinash sridharan


On July 28, 2017, 2:32 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 28, 2017, 2:32 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/6/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec 

Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-28 Thread Qian Zhang


> On July 28, 2017, 8:48 a.m., Avinash sridharan wrote:
> > src/docker/docker.cpp
> > Lines 755 (patched)
> > 
> >
> > I think we need to add the wild card `*` match for `USER` network here. 
> > Basically if mode is `USER` and `network_name` is present we do a wild card 
> > match for all networks.
> > 
> > We want to set the DNS for the most specific match.

My bad, should have handled it in the first place.


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181634
---


On July 25, 2017, 2:05 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 25, 2017, 2:05 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/5/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-28 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 28, 2017, 10:32 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Addessed comments.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/6/

Changes: https://reviews.apache.org/r/60558/diff/5-6/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-27 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review181634
---




src/docker/docker.cpp
Lines 755 (patched)


I think we need to add the wild card `*` match for `USER` network here. 
Basically if mode is `USER` and `network_name` is present we do a wild card 
match for all networks.

We want to set the DNS for the most specific match.


- Avinash sridharan


On July 25, 2017, 6:05 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 25, 2017, 6:05 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/5/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network_mode": "CNI",
>   "network_name": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network_mode": "BRIDGE",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> },
> {
>   "network_mode": "USER",
>   "network_name": "net2",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-25 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 25, 2017, 2:05 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Rebased.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/5/

Changes: https://reviews.apache.org/r/60558/diff/4-5/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-24 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 24, 2017, 4:06 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Rebased.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8081c0203bf62cf62aa3b93d745f0e829ad65509 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/4/

Changes: https://reviews.apache.org/r/60558/diff/3-4/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-23 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 24, 2017, 1:33 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/3/


Testing (updated)
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network_mode": "CNI",
  "network_name": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network_mode": "BRIDGE",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
},
{
  "network_mode": "USER",
  "network_name": "net2",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-10 Thread Qian Zhang


> On July 9, 2017, 3:09 p.m., Avinash sridharan wrote:
> > Hi Qian, the changes LGTM but I think we should follow these patches up 
> > with a test for CNI and CNM networks?

Definitely, I am working on it now.

And actually I have a comment, in this patch I have handled the case of 
launching a command task with Docker containerizer, in this case, Docker 
executor will be responsible for setting DNS for the container (i.e., the 
command task container) according to `--default_container_dns`. However I see 
there is another case: Docker containerizer can be used to directly launch a 
Docker container as a custom executor 
(DockerContainerizerProcess::launchExecutorContainer()), so for such custom 
executor container, do you think we need to update Docker containerizer to set 
its DNS according to `--default_container_dns`?


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179994
---


On July 5, 2017, 3:18 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 5, 2017, 3:18 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/3/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-09 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179994
---


Ship it!




Hi Qian, the changes LGTM but I think we should follow these patches up with a 
test for CNI and CNM networks?

- Avinash sridharan


On July 5, 2017, 7:18 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 5, 2017, 7:18 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/3/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-09 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179993
---


Ship it!




Ship It!

- Avinash sridharan


On July 5, 2017, 7:18 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 5, 2017, 7:18 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/3/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-05 Thread Qian Zhang


> On July 4, 2017, 2:35 a.m., Avinash sridharan wrote:
> > src/docker/docker.hpp
> > Lines 167 (patched)
> > 
> >
> > For consistency can we use `defautlContainerDNS`?
> 
> Qian Zhang wrote:
> Originally I used `defautlContainerDNS`, but that will make this line 
> exceeding 80 chars :-( I think it also makes sense to use `defaultDNS` since 
> here we know we are creating run options for Docker container, so I think we 
> do not have to mention `container` in the parameter name.
> 
> Avinash sridharan wrote:
> You can use this `// NOLINT(whitespace/line_length)` to create 
> exceptions? In `executor.cpp` you use `defaultContainerDNS` so seemed a bit 
> odd.

Agree!


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179530
---


On July 5, 2017, 3:18 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated July 5, 2017, 3:18 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/3/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-05 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 5, 2017, 3:18 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Addressed Avinash's comments.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/3/

Changes: https://reviews.apache.org/r/60558/diff/2-3/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network": "bridge",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-05 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated July 5, 2017, 3:06 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Changes
---

Addressed Avinash's comments.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs (updated)
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/2/

Changes: https://reviews.apache.org/r/60558/diff/1-2/


Testing
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network": "bridge",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-05 Thread Avinash sridharan


> On July 3, 2017, 6:35 p.m., Avinash sridharan wrote:
> > src/docker/docker.hpp
> > Lines 167 (patched)
> > 
> >
> > For consistency can we use `defautlContainerDNS`?
> 
> Qian Zhang wrote:
> Originally I used `defautlContainerDNS`, but that will make this line 
> exceeding 80 chars :-( I think it also makes sense to use `defaultDNS` since 
> here we know we are creating run options for Docker container, so I think we 
> do not have to mention `container` in the parameter name.

You can use this `// NOLINT(whitespace/line_length)` to create exceptions? In 
`executor.cpp` you use `defaultContainerDNS` so seemed a bit odd.


- Avinash


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179530
---


On June 30, 2017, 7:09 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated June 30, 2017, 7:09 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/1/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-05 Thread Qian Zhang


> On July 4, 2017, 2:35 a.m., Avinash sridharan wrote:
> > src/docker/docker.hpp
> > Lines 167 (patched)
> > 
> >
> > For consistency can we use `defautlContainerDNS`?

Originally I used `defautlContainerDNS`, but that will make this line exceeding 
80 chars :-( I think it also makes sense to use `defaultDNS` since here we know 
we are creating run options for Docker container, so I think we do not have to 
mention `container` in the parameter name.


- Qian


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179530
---


On June 30, 2017, 3:09 p.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated June 30, 2017, 3:09 p.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/1/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-07-03 Thread Avinash sridharan

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/#review179530
---




src/docker/docker.hpp
Lines 167 (patched)


For consistency can we use `defautlContainerDNS`?



src/docker/docker.cpp
Line 839 (original), 867 (patched)


We would need to perform a version check for supported DNS options here as 
well.


- Avinash sridharan


On June 30, 2017, 7:09 a.m., Qian Zhang wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60558/
> ---
> 
> (Updated June 30, 2017, 7:09 a.m.)
> 
> 
> Review request for mesos, Avinash sridharan and Jie Yu.
> 
> 
> Bugs: MESOS-7709
> https://issues.apache.org/jira/browse/MESOS-7709
> 
> 
> Repository: mesos
> 
> 
> Description
> ---
> 
> Set container DNS with `--default_container_dns` in Docker executor.
> 
> 
> Diffs
> -
> 
>   src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
>   src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
>   src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 
> 
> 
> Diff: https://reviews.apache.org/r/60558/diff/1/
> 
> 
> Testing
> ---
> 
> sudo make check
> 
> 1. Start Mesos master.
> ```
> $ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
> ```
> 
> 2. Start Mesos agent.
> ```
> $ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
> --containerizers=mesos,docker --image_providers=docker 
> --image_provisioner_backend=aufs 
> --isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem
>  --network_cni_config_dir=/opt/cni/net_configs 
> --network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
> --docker_store_dir=/opt/mesos/store/docker 
> --executor_registration_timeout=60mins 
> --default_container_dns=file:///home/stack/dns.json
> 
> $ cat /home/stack/dns.json
> {
>   "mesos": [
> {
>   "network": "net1",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ]
>   }
> }
>   ],
>   "docker": [
> {
>   "network": "bridge",
>   "dns": {
> "nameservers": [ "8.8.8.8", "8.8.4.4" ],
> "search": [ "xxx.com", "yyy.com" ],
> "options": [ "timeout:3", "attempts:2" ]
>   }
> }
>   ]
> }
> ```
> 
> 3. Launch a Docker container with `mesos-execute`.
> ```
> $ sudo src/mesos-execute --master=192.168.122.216:5050 
> --task=file:///home/stack/task-docker.json
> 
> $cat /home/stack/task-docker.json 
> {
>   "name": "test",
>   "task_id": {"value" : "test"},
>   "agent_id": {"value" : ""},
>   "resources": [
> {
>   "name": "cpus",
>   "type": "SCALAR",
>   "scalar": {
> "value": 0.1
>   }
> },
> {
>   "name": "mem",
>   "type": "SCALAR",
>   "scalar": {
> "value": 32
>   }
> }
>   ],
>   "command": {
> "shell": false
>   },
>   "container": {
> "type": "DOCKER",
> "docker": {
>   "image": "nginx",
>   "network": "BRIDGE"
> }
>   }
> }
> ```
> 
> 4. Check the DNS configuration of the Docker container.
> ```
> $ docker ps 
> CONTAINER IDIMAGE   COMMAND  CREATED  
> STATUS  PORTS   NAMES
> ca642bf31a9fnginx   "nginx -g 'daemon off"   About a 
> minute ago   Up About a minute   80/tcp, 443/tcp 
> mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da
> 
> $ docker exec ca642bf31a9f cat /etc/resolv.conf 
> search xxx.com yyy.com
> nameserver 8.8.8.8
> nameserver 8.8.4.4
> options timeout:3 attempts:2
> ```
> 
> 
> Thanks,
> 
> Qian Zhang
> 
>



Re: Review Request 60558: Set container DNS with `--default_container_dns` in Docker executor.

2017-06-30 Thread Qian Zhang

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60558/
---

(Updated June 30, 2017, 3:09 p.m.)


Review request for mesos, Avinash sridharan and Jie Yu.


Bugs: MESOS-7709
https://issues.apache.org/jira/browse/MESOS-7709


Repository: mesos


Description
---

Set container DNS with `--default_container_dns` in Docker executor.


Diffs
-

  src/docker/docker.hpp 5593cb635e073334c6c2566be3d803cd7febb1c3 
  src/docker/docker.cpp 8ca0c68836ea5d1a1186e79942f6daccf6c6da46 
  src/docker/executor.cpp e03f24461ec7b19cacae79c020406f0a475f2d19 


Diff: https://reviews.apache.org/r/60558/diff/1/


Testing (updated)
---

sudo make check

1. Start Mesos master.
```
$ sudo ./bin/mesos-master.sh --work_dir=/opt/mesos
```

2. Start Mesos agent.
```
$ sudo ./bin/mesos-slave.sh --master=192.168.122.216:5050 
--containerizers=mesos,docker --image_providers=docker 
--image_provisioner_backend=aufs 
--isolation=filesystem/linux,docker/runtime,network/cni,cgroups/cpu,cgroups/mem 
--network_cni_config_dir=/opt/cni/net_configs 
--network_cni_plugins_dir=/opt/cni/plugins --work_dir=/opt/mesos 
--docker_store_dir=/opt/mesos/store/docker 
--executor_registration_timeout=60mins 
--default_container_dns=file:///home/stack/dns.json

$ cat /home/stack/dns.json
{
  "mesos": [
{
  "network": "net1",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ]
  }
}
  ],
  "docker": [
{
  "network": "bridge",
  "dns": {
"nameservers": [ "8.8.8.8", "8.8.4.4" ],
"search": [ "xxx.com", "yyy.com" ],
"options": [ "timeout:3", "attempts:2" ]
  }
}
  ]
}
```

3. Launch a Docker container with `mesos-execute`.
```
$ sudo src/mesos-execute --master=192.168.122.216:5050 
--task=file:///home/stack/task-docker.json

$cat /home/stack/task-docker.json 
{
  "name": "test",
  "task_id": {"value" : "test"},
  "agent_id": {"value" : ""},
  "resources": [
{
  "name": "cpus",
  "type": "SCALAR",
  "scalar": {
"value": 0.1
  }
},
{
  "name": "mem",
  "type": "SCALAR",
  "scalar": {
"value": 32
  }
}
  ],
  "command": {
"shell": false
  },
  "container": {
"type": "DOCKER",
"docker": {
  "image": "nginx",
  "network": "BRIDGE"
}
  }
}
```

4. Check the DNS configuration of the Docker container.
```
$ docker ps 
CONTAINER IDIMAGE   COMMAND  CREATED
  STATUS  PORTS   NAMES
ca642bf31a9fnginx   "nginx -g 'daemon off"   About a minute 
ago   Up About a minute   80/tcp, 443/tcp 
mesos-1d48fc32-a138-4c31-a5a9-fd7d279231da

$ docker exec ca642bf31a9f cat /etc/resolv.conf 
search xxx.com yyy.com
nameserver 8.8.8.8
nameserver 8.8.4.4
options timeout:3 attempts:2
```


Thanks,

Qian Zhang