From 9a65ec231d7f76655caa964e1d9228ba7a910dea Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 9 Jul 2018 11:51:24 +0200 Subject: [PATCH] tests: fix `_get_osd_id_from_host()` in TestOSDs() We must initialize `children` variable in `_get_osd_id_from_host()`, otherwise, if for any reason the deployment has failed and result with an osd host with no OSD registered, we won't enter in the condition, therefore, `children` is never set and the function tries to return something undefined. Typical error: ``` E UnboundLocalError: local variable 'children' referenced before assignment ``` Fixes: #2860 Signed-off-by: Guillaume Abrioux --- tests/functional/tests/osd/test_osds.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/tests/osd/test_osds.py b/tests/functional/tests/osd/test_osds.py index 8dbee2e86..e87f6e1b0 100644 --- a/tests/functional/tests/osd/test_osds.py +++ b/tests/functional/tests/osd/test_osds.py @@ -49,6 +49,7 @@ class TestOSDs(object): host.exists('ceph-volume-systemd') def _get_osd_id_from_host(self, node, osd_tree): + children = [] for n in osd_tree['nodes']: if n['name'] == node['vars']['inventory_hostname'] and n['type'] == 'host': children = n['children'] -- 2.39.5