From: Guillaume Abrioux Date: Fri, 10 Jan 2020 09:55:06 +0000 (+0100) Subject: containers: use --cpus instead --cpu-quota X-Git-Tag: v4.0.44~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b903446fa4a70c0985962ca7e9c8fc5442f9e512;p=ceph-ansible.git containers: use --cpus instead --cpu-quota When using docker 1.13.1, the current condition: ``` {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%} ``` is wrong because it compares the first digit (1) whereas it should compare the second one. It means we always use `--cpu-quota` although documentation recommend using `--cpus` when docker version is 1.13.1 or higher. From the doc: > --cpu-quota= Impose a CPU CFS quota on the container. The number of > microseconds per --cpu-period that the container is limited to before > throttled. As such acting as the effective ceiling. > If you use Docker 1.13 or higher, use --cpus instead. Signed-off-by: Guillaume Abrioux (cherry picked from commit 3e262e072b0e86bbb431c47bc691bcad70783443) --- diff --git a/infrastructure-playbooks/docker-to-podman.yml b/infrastructure-playbooks/docker-to-podman.yml index 80a28ada4..a6d2cb703 100644 --- a/infrastructure-playbooks/docker-to-podman.yml +++ b/infrastructure-playbooks/docker-to-podman.yml @@ -65,19 +65,6 @@ - import_role: name: ceph-handler - - name: with docker configuration - when: container_binary == 'docker' - block: - - name: get docker version - command: docker --version - changed_when: false - check_mode: no - register: ceph_docker_version - - - name: set_fact ceph_docker_version ceph_docker_version.stdout.split - set_fact: - ceph_docker_version: "{{ ceph_docker_version.stdout.split(' ')[2] }}" - - name: set_fact docker2podman and container_binary set_fact: docker2podman: True diff --git a/roles/ceph-container-common/tasks/main.yml b/roles/ceph-container-common/tasks/main.yml index f575b2fb6..aa9139b0d 100644 --- a/roles/ceph-container-common/tasks/main.yml +++ b/roles/ceph-container-common/tasks/main.yml @@ -2,19 +2,6 @@ - name: include prerequisites.yml include_tasks: prerequisites.yml -- name: get docker version - block: - - name: get docker version - command: docker --version - changed_when: false - check_mode: no - register: ceph_docker_version - - - name: set_fact ceph_docker_version ceph_docker_version.stdout.split - set_fact: - ceph_docker_version: "{{ ceph_docker_version.stdout.split(' ')[2] }}" - when: container_binary == 'docker' - - name: include registry.yml include_tasks: registry.yml when: ceph_docker_registry_auth | bool diff --git a/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 b/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 index 3f2f594f0..484b0f93e 100644 --- a/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 +++ b/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 @@ -21,11 +21,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_rbd_target_api_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_rbd_target_api_docker_cpu_limit }} \ - {% else -%} - --cpu-quota={{ ceph_rbd_target_api_docker_cpu_limit * 100000 }} \ - {% endif -%} -v /etc/localtime:/etc/localtime:ro \ --privileged \ --net=host \ diff --git a/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 b/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 index ef56edb3c..b6baf8c32 100644 --- a/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 +++ b/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 @@ -21,11 +21,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_rbd_target_gw_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_rbd_target_gw_docker_cpu_limit }} \ - {% else -%} - --cpu-quota={{ ceph_rbd_target_gw_docker_cpu_limit * 100000 }} \ - {% endif -%} -v /etc/localtime:/etc/localtime:ro \ --privileged \ --net=host \ diff --git a/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 b/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 index b488acf1e..5809ed356 100644 --- a/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 +++ b/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 @@ -21,11 +21,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_tcmu_runner_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_tcmu_runner_docker_cpu_limit }} \ - {% else -%} - --cpu-quota={{ ceph_tcmu_runner_docker_cpu_limit * 100000 }} \ - {% endif -%} -v /etc/localtime:/etc/localtime:ro \ --privileged \ --net=host \ diff --git a/roles/ceph-mds/templates/ceph-mds.service.j2 b/roles/ceph-mds/templates/ceph-mds.service.j2 index fa84c6bf7..6d60fd25a 100644 --- a/roles/ceph-mds/templates/ceph-mds.service.j2 +++ b/roles/ceph-mds/templates/ceph-mds.service.j2 @@ -22,11 +22,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_mds_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ cpu_limit }} \ - {% else -%} - --cpu-quota={{ cpu_limit * 100000 }} \ - {% endif -%} -v /var/lib/ceph:/var/lib/ceph:z \ -v /etc/ceph:/etc/ceph:z \ -v /var/run/ceph:/var/run/ceph:z \ diff --git a/roles/ceph-mgr/templates/ceph-mgr.service.j2 b/roles/ceph-mgr/templates/ceph-mgr.service.j2 index d187c2aba..5e4874837 100644 --- a/roles/ceph-mgr/templates/ceph-mgr.service.j2 +++ b/roles/ceph-mgr/templates/ceph-mgr.service.j2 @@ -21,11 +21,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_mgr_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_mgr_docker_cpu_limit }} \ - {% else -%} - --cpu-quota={{ ceph_mgr_docker_cpu_limit * 100000 }} \ - {% endif -%} -v /var/lib/ceph:/var/lib/ceph:z,rshared \ -v /etc/ceph:/etc/ceph:z \ -v /var/run/ceph:/var/run/ceph:z \ diff --git a/roles/ceph-mon/templates/ceph-mon.service.j2 b/roles/ceph-mon/templates/ceph-mon.service.j2 index a961bf220..a0f47786e 100644 --- a/roles/ceph-mon/templates/ceph-mon.service.j2 +++ b/roles/ceph-mon/templates/ceph-mon.service.j2 @@ -20,11 +20,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-mon-%i \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_mon_docker_memory_limit }} \ -{% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_mon_docker_cpu_limit }} \ -{% else -%} - --cpu-quota={{ ceph_mon_docker_cpu_limit * 100000 }} \ -{% endif -%} -v /var/lib/ceph:/var/lib/ceph:z,rshared \ -v /etc/ceph:/etc/ceph:z \ -v /var/run/ceph:/var/run/ceph:z \ diff --git a/roles/ceph-osd/templates/ceph-osd.service.j2 b/roles/ceph-osd/templates/ceph-osd.service.j2 index 73f8190d2..32d78a566 100644 --- a/roles/ceph-osd/templates/ceph-osd.service.j2 +++ b/roles/ceph-osd/templates/ceph-osd.service.j2 @@ -34,11 +34,7 @@ numactl \ {% if osd_objectstore == 'filestore' -%} --memory={{ ceph_osd_docker_memory_limit }} \ {% endif -%} - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ cpu_limit }} \ - {% else -%} - --cpu-quota={{ cpu_limit * 100000 }} \ - {% endif -%} {% if ceph_osd_docker_cpuset_cpus is defined -%} --cpuset-cpus='{{ ceph_osd_docker_cpuset_cpus }}' \ {% endif -%} diff --git a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 index 191100bec..830d29ae2 100644 --- a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 +++ b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 @@ -21,11 +21,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_rbd_mirror_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ ceph_rbd_mirror_docker_cpu_limit }} \ - {% else -%} - --cpu-quota={{ ceph_rbd_mirror_docker_cpu_limit * 100000 }} \ - {% endif -%} -v /var/lib/ceph:/var/lib/ceph:z \ -v /etc/ceph:/etc/ceph:z \ -v /var/run/ceph:/var/run/ceph:z \ diff --git a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 index aaa8f3a1f..54bd5b0c1 100644 --- a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 +++ b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 @@ -22,11 +22,7 @@ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ -d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ {% endif %} --memory={{ ceph_rgw_docker_memory_limit }} \ - {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%} --cpus={{ cpu_limit }} \ - {% else -%} - --cpu-quota={{ cpu_limit * 100000 }} \ - {% endif -%} {% if ceph_rgw_docker_cpuset_cpus is defined -%} --cpuset-cpus="{{ ceph_rgw_docker_cpuset_cpus }}" \ {% endif -%}