From 735aa0410578a48da88bae46d7a98ba1db395250 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 29 Jul 2020 09:27:28 +0800 Subject: [PATCH] qa/tasks/ceph: do not print out empty list of pg we could have following logging messages: tasks.ceph:Waiting for all PGs to be active+clean and split+merged, waiting on ['2.6', '2.5', '1.0', '2.4'] to go clean and/or [] to split/merge if the cluster has non-active+clean pgs when the "ceph" is about to end. but this message is a little bit confusing in the sense it lists "[]" in it. in this change, only PGs being waited are listed. also, added some cleanups: * use "else" to check if the loop is terminated by a break * remove "0" from the range() call Signed-off-by: Kefu Chai --- qa/tasks/ceph.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index 71fc2eafae19a..3eb63406d4dd8 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -1188,8 +1188,7 @@ def osd_scrub_pgs(ctx, config): delays = 20 cluster_name = config['cluster'] manager = ctx.managers[cluster_name] - all_clean = False - for _ in range(0, retries): + for _ in range(retries): stats = manager.get_pg_stats() unclean = [stat['pgid'] for stat in stats if 'active+clean' not in stat['state']] split_merge = [] @@ -1200,12 +1199,16 @@ def osd_scrub_pgs(ctx, config): # we don't support pg_num_target before nautilus pass if not unclean and not split_merge: - all_clean = True break - log.info( - "Waiting for all PGs to be active+clean and split+merged, waiting on %s to go clean and/or %s to split/merge" % (unclean, split_merge)) + waiting_on = [] + if unclean: + waiting_on.append(f'{unclean} to go clean') + if split_merge: + waiting_on.append(f'{split_merge} to split/merge') + waiting_on = ' and '.join(waiting_on) + log.info('Waiting for all PGs to be active+clean and split+merged, waiting on %s', waiting_on) time.sleep(delays) - if not all_clean: + else: raise RuntimeError("Scrubbing terminated -- not all pgs were active and clean.") check_time_now = time.localtime() time.sleep(1) -- 2.47.3