From 869185ea7be5d6b5b21c964a620839d5475196fd Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 23 Apr 2020 12:03:45 +0100 Subject: [PATCH] Switch default docker storage driver to overlay2 To avoid switching existing deployments from devicemapper to overlay2, we check the existing storage driver configuration directly with the Docker daemon, or if unreachable by reading the /etc/docker/daemon.json configuration file. Co-Authored-By: Pierre Riteau Story: 2005667 Task: 30972 Change-Id: Iaf2ee8c9f302f4684ae039bb00b2e2e5969cf1fc --- ansible/docker-devicemapper.yml | 37 ++++++++++++++++++- ansible/group_vars/all/docker | 4 +- .../docker-devicemapper/defaults/main.yml | 2 +- ansible/roles/kolla-ansible/defaults/main.yml | 2 +- doc/source/configuration/reference/hosts.rst | 4 +- etc/kayobe/docker.yml | 2 +- .../default-overlay2-970bdb5b7b62b60a.yaml | 7 ++++ 7 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/default-overlay2-970bdb5b7b62b60a.yaml diff --git a/ansible/docker-devicemapper.yml b/ansible/docker-devicemapper.yml index e61c97644..ce0e0128f 100644 --- a/ansible/docker-devicemapper.yml +++ b/ansible/docker-devicemapper.yml @@ -1,11 +1,44 @@ --- -- name: Ensure docker devicemapper storage is configured +- name: Verify and configure Docker storage driver hosts: docker tags: - docker - docker-devicemapper tasks: - - name: Ensure docker devicemapper storage is configured + - name: Check for existing Docker configuration using devicemapper + block: + - name: Query Docker daemon for storage driver + docker_host_info: + failed_when: false + register: docker + + - block: + - name: Check for a Docker configuration file + become: True + stat: + path: /etc/docker/daemon.json + register: docker_config_file + + - name: Check whether devicemapper is used in configuration file + lineinfile: + path: /etc/docker/daemon.json + regexp: 'storage-driver.*devicemapper' + state: absent + become: True + changed_when: False + # `check_mode: True` ensures that we don't modify daemon.json + check_mode: True + register: devicemapper_docker + when: docker_config_file.stat.exists + when: not docker.can_talk_to_docker + + - name: Fail if devicemapper is in use while another storage driver was requested + fail: + msg: "Docker storage driver {{ docker_storage_driver }} was requested, but devicemapper is in use" + when: (docker.can_talk_to_docker and docker.host_info.Driver == 'devicemapper') or (devicemapper_docker.found | default(0) == 1) + when: docker_storage_driver != 'devicemapper' + + - name: Ensure Docker devicemapper storage is configured include_role: name: docker-devicemapper when: docker_storage_driver == 'devicemapper' diff --git a/ansible/group_vars/all/docker b/ansible/group_vars/all/docker index d9ab508b3..861ddcc7e 100644 --- a/ansible/group_vars/all/docker +++ b/ansible/group_vars/all/docker @@ -2,8 +2,8 @@ ############################################################################### # Docker configuration. -# Name of the docker storage driver. Default is 'devicemapper'. -docker_storage_driver: devicemapper +# Name of the docker storage driver. Default is 'overlay2'. +docker_storage_driver: overlay2 # Name of the docker storage LVM volume group. docker_storage_volume_group: data diff --git a/ansible/roles/docker-devicemapper/defaults/main.yml b/ansible/roles/docker-devicemapper/defaults/main.yml index b9f813b0b..7c210ae89 100644 --- a/ansible/roles/docker-devicemapper/defaults/main.yml +++ b/ansible/roles/docker-devicemapper/defaults/main.yml @@ -1,6 +1,6 @@ --- # Name of the docker storage driver. -docker_storage_driver: devicemapper +docker_storage_driver: overlay2 # Name of the docker storage LVM volume group. docker_storage_volume_group: diff --git a/ansible/roles/kolla-ansible/defaults/main.yml b/ansible/roles/kolla-ansible/defaults/main.yml index 7cf6f57f5..9dcc683fe 100644 --- a/ansible/roles/kolla-ansible/defaults/main.yml +++ b/ansible/roles/kolla-ansible/defaults/main.yml @@ -262,7 +262,7 @@ kolla_enable_host_ntp: # Docker configuration. # Name of the docker storage driver. -docker_storage_driver: devicemapper +docker_storage_driver: overlay2 # Name of the docker storage LVM volume group. docker_storage_volume_group: diff --git a/doc/source/configuration/reference/hosts.rst b/doc/source/configuration/reference/hosts.rst index 5722df25b..1bcf98c44 100644 --- a/doc/source/configuration/reference/hosts.rst +++ b/doc/source/configuration/reference/hosts.rst @@ -690,8 +690,8 @@ Docker engine configuration is applied by both Kayobe and Kolla Ansible (during bootstrap-servers). The ``docker_storage_driver`` variable sets the Docker storage driver, and by -default the ``devicemapper`` driver is used. If using this driver, see -:ref:`configuration-hosts-lvm` for information about configuring LVM for +default the ``overlay2`` driver is used. If using the ``devicemapper`` driver, +see :ref:`configuration-hosts-lvm` for information about configuring LVM for Docker. Various options are defined in ``${KAYOBE_CONFIG_PATH}/docker.yml`` diff --git a/etc/kayobe/docker.yml b/etc/kayobe/docker.yml index 5d30a5d19..4ec00a1f4 100644 --- a/etc/kayobe/docker.yml +++ b/etc/kayobe/docker.yml @@ -2,7 +2,7 @@ ############################################################################### # Docker configuration. -# Name of the docker storage driver. Default is 'devicemapper'. +# Name of the docker storage driver. Default is 'overlay2'. #docker_storage_driver: # Name of the docker storage LVM volume group. diff --git a/releasenotes/notes/default-overlay2-970bdb5b7b62b60a.yaml b/releasenotes/notes/default-overlay2-970bdb5b7b62b60a.yaml new file mode 100644 index 000000000..1c50e7f8b --- /dev/null +++ b/releasenotes/notes/default-overlay2-970bdb5b7b62b60a.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The default Docker storage driver has been changed from ``devicemapper`` to + ``overlay2``, which is the storage driver preferred by Docker. Environments + using ``devicemapper`` should set ``docker_storage_driver`` to + ``devicemapper`` in ``${KAYOBE_CONFIG_PATH}/docker.yml``.