From 7d695416c493d8023ff986b89e744a3e15dd15ab Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Wed, 8 Apr 2020 11:55:57 +0200 Subject: [PATCH] ceph-volume/batch: return success when all devices are filtered batch should only return an error if some (but not all) devices are filtered. When only some devices are filtered the resulting osd layout could look very different from what a user expects. If all devies are filtered just return success. Fixes: https://tracker.ceph.com/issues/44994 Signed-off-by: Jan Fajerski (cherry picked from commit cb3eade3d00fdcdb34c4156f3c488bbb8747cd6f) --- src/ceph-volume/ceph_volume/devices/lvm/batch.py | 7 ++++++- .../tests/functional/batch/playbooks/test_explicit.yml | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index 27ee5bb47e00..d38c16f749fc 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -366,7 +366,12 @@ class Batch(object): self.filtered_devices.update({d: used_reason for d in getattr(self.args, dev_list_prop) if d.used_by_ceph}) - if self.args.yes and dev_list and devs != usable: + # only fail if non-interactive, this iteration concerns + # non-data devices, there are usable data devices (or not all + # data devices were filtered) and non-data devices were filtered + # so in short this branch is not taken if all data devices are + # filtered + if self.args.yes and dev_list and self.usable and devs != usable: err = '{} devices were filtered in non-interactive mode, bailing out' raise RuntimeError(err.format(len(devs) - len(usable))) diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml index ac01062a0503..f3be4972af2a 100644 --- a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml @@ -9,7 +9,6 @@ state: stopped with_items: "{{ osd_ids }}" - - hosts: mons become: yes tasks: @@ -21,7 +20,6 @@ command: "ceph --cluster {{ cluster }} osd purge osd.{{ item }} --yes-i-really-mean-it" with_items: "{{ osd_ids }}" - - hosts: osds become: yes tasks: @@ -37,7 +35,7 @@ environment: CEPH_VOLUME_DEBUG: 1 - - name: ensure batch create is idempotent + - name: ensure batch create is idempotent when all data devices are filtered command: "ceph-volume --cluster {{ cluster }} lvm batch --yes --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices[:2] | join(' ') }} --db-devices {{ devices[2:] | join(' ') }}" register: batch_cmd failed_when: false @@ -49,7 +47,6 @@ msg: "lvm batch failed idempotency check" when: - batch_cmd.rc != 0 - - "'strategy changed' not in batch_cmd.stderr" - name: run batch --report to see if devices get filtered command: "ceph-volume --cluster {{ cluster }} lvm batch --report --format=json --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices[:2] | join(' ') }} --db-devices {{ devices[2:] | join(' ') }}" @@ -63,4 +60,3 @@ msg: "lvm batch --report failed idempotency check" when: - report_cmd.rc != 0 - - "'strategy changed' not in report_cmd.stderr" -- 2.47.3