Move docker systemd unit creation to docker role

Creating the unit using default settings early on
and then changing it during network_plugin section
leads to too many docker restarts and duplicated code.

Reversed Wants= dependence on docker.service so it does not
restart docker when reloading systemd

Consolidated all docker restart handlers.
This commit is contained in:
Matthew Mosesohn
2016-08-02 13:42:27 +03:00
parent 2af71f31b4
commit e8a1c7a53f
18 changed files with 38 additions and 128 deletions

View File

@@ -10,13 +10,6 @@
- restart docker
when: ansible_os_family != "CoreOS"
- name: Calico | Write docker.service systemd file
template:
src: systemd-docker.service
dest: /lib/systemd/system/docker.service
notify: restart docker
when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- meta: flush_handlers
- name: Calico | Install calicoctl container script

View File

@@ -2,7 +2,7 @@
Description=Calico per-node agent
Documentation=https://github.com/projectcalico/calico-docker
After=docker.service docker.socket etcd-proxy.service
Wants=docker.service docker.socket etcd-proxy.service
Wants=docker.socket etcd-proxy.service
[Service]
User=root

View File

@@ -1,39 +0,0 @@
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
{% if ansible_os_family == "RedHat" %}
After=network.target docker-storage-setup.service
Wants=docker-storage-setup.service
{% elif ansible_os_family == "Debian" %}
After=network.target docker.socket
Wants=docker.socket
{% endif %}
[Service]
Type=notify
{% if ansible_os_family == "RedHat" %}
EnvironmentFile=-/etc/default/docker
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-network
EnvironmentFile=-/etc/sysconfig/docker-storage
{% elif ansible_os_family == "Debian" %}
EnvironmentFile=-/etc/default/docker
{% endif %}
Environment=GOTRACEBACK=crash
ExecReload=/bin/kill -s HUP $MAINPID
Delegate=yes
KillMode=process
ExecStart=/usr/bin/docker daemon \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$INSECURE_REGISTRY \
$DOCKER_OPTS
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
MountFlags=slave
TimeoutStartSec=1min
[Install]
WantedBy=multi-user.target

View File

@@ -4,22 +4,6 @@
ignore_errors: yes
notify: restart docker
- name: restart docker
command: /bin/true
notify:
- Flannel | reload systemd
- Flannel | reload docker
- Flannel | reload kubelet
- name : Flannel | reload systemd
shell: systemctl daemon-reload
when: ansible_service_mgr == "systemd"
- name: Flannel | reload docker
service:
name: docker
state: restarted
- name: Flannel | reload kubelet
service:
name: kubelet

View File

@@ -50,11 +50,4 @@
state: link
when: ansible_os_family == "CoreOS"
- name: Flannel | Write docker.service systemd file
template:
src: systemd-docker.service
dest: /lib/systemd/system/docker.service
notify: restart docker
when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- meta: flush_handlers

View File

@@ -1,32 +0,0 @@
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
{% if ansible_os_family == "RedHat" %}
After=network.target docker-storage-setup.service
Wants=docker-storage-setup.service
{% elif ansible_os_family == "Debian" %}
After=network.target docker.socket
Wants=docker.socket
{% endif %}
[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
Environment=GOTRACEBACK=crash
ExecReload=/bin/kill -s HUP $MAINPID
Delegate=yes
KillMode=process
ExecStart=/usr/bin/docker daemon \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$INSECURE_REGISTRY \
$DOCKER_OPTS
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
MountFlags=slave
TimeoutStartSec=1min
[Install]
WantedBy=multi-user.target

View File

@@ -6,3 +6,4 @@ dependencies:
when: kube_network_plugin == 'flannel'
- role: network_plugin/weave
when: kube_network_plugin == 'weave'
- role: docker

View File

@@ -1,10 +1,4 @@
---
- name: Weave | restart docker
command: /bin/true
notify:
- Weave | reload systemd
- Weave | reload docker
- name: restart weave
command: /bin/true
notify:
@@ -27,11 +21,6 @@
- Weave | reload systemd
- reload weaveexpose
- name: Weave | reload docker
service:
name: docker
state: restarted
- name: reload weave
service:
name: weave

View File

@@ -7,14 +7,7 @@
group: root
mode: 0644
notify:
- Weave | restart docker
- name: Write docker.service systemd file
template:
src: systemd-docker.service
dest: /lib/systemd/system/docker.service
notify: Weave | restart docker
when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- restart docker
- name: Weave | Install weave
command: rsync -piu "{{ local_release_dir }}/weave/bin/weave" "{{ bin_dir }}/weave"

View File

@@ -1,32 +0,0 @@
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
{% if ansible_os_family == "RedHat" %}
After=network.target
Wants=docker-storage-setup.service
{% elif ansible_os_family == "Debian" %}
After=network.target docker.socket
Wants=docker.socket
{% endif %}
[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
Environment=GOTRACEBACK=crash
ExecReload=/bin/kill -s HUP $MAINPID
Delegate=yes
KillMode=process
ExecStart=/usr/bin/docker daemon \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$INSECURE_REGISTRY \
$DOCKER_OPTS
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
MountFlags=slave
TimeoutStartSec=1min
[Install]
WantedBy=multi-user.target

View File

@@ -1,7 +1,7 @@
[Unit]
Description=Weave Network
Documentation=http://docs.weave.works/weave/latest_release/
Wants=docker.service docker.socket
Wants=docker.socket
After=docker.service docker.socket
[Service]

View File

@@ -1,6 +1,6 @@
[Unit]
Documentation=http://docs.weave.works/
Wants=docker.service docker.socket weave.service
Wants=docker.socket weave.service
After=docker.service docker.socket weave.service
[Service]

View File

@@ -1,7 +1,7 @@
[Unit]
Description=Weave proxy for Docker API
Documentation=http://docs.weave.works/
Wants=docker.service docker.socket
Wants=docker.socket
After=docker.service docker.socket
[Service]