mirror of https://github.com/ceph/ceph-ansible.git
ceph_volume: fix bug in `is_lv()`
This function makes the `ceph_volume` module be not idempotent in
containerized context because it tries to run a container and bindmount
directories that no longer exist.
In that case, the `lvs` command being executed returns something
different than `0` so we can't call `json.loads(out)['report'][0]['lv']`
since it might throw an python error.
The idea is to return `True` only if `rc` is equal to `0` and
`len(result)` is greater than `0`, which means the command matched an
LV.
Fixes: #6284
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit ed79bc7a4e
)
pull/6384/head
parent
be7cfb9ccc
commit
3c5f5f1503
|
@ -477,11 +477,12 @@ def is_lv(module, vg, lv, container_image):
|
||||||
|
|
||||||
rc, cmd, out, err = exec_command(module, cmd)
|
rc, cmd, out, err = exec_command(module, cmd)
|
||||||
|
|
||||||
result = json.loads(out)['report'][0]['lv']
|
if rc == 0:
|
||||||
if rc == 0 and len(result) > 0:
|
result = json.loads(out)['report'][0]['lv']
|
||||||
return True
|
if len(result) > 0:
|
||||||
else:
|
return True
|
||||||
return False
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def zap_devices(module, container_image):
|
def zap_devices(module, container_image):
|
||||||
|
|
Loading…
Reference in New Issue