From cfd6ca362386219646c010cde3ec60f0e5e9b140 Mon Sep 17 00:00:00 2001 From: Valerii Ponomarov Date: Fri, 21 Dec 2018 17:18:22 +0530 Subject: Add events info for 'verify_pvc_status_is_bound' common func For the moment, we write events of failed PVC only to glusto logs. And only info of one type of events - 'ProvisioningFailed'. But in case of CI, it is not really suitable. We need to have info in the exception message. So, add all the pvc-related events to the message of raised exception when PVC fails to reach the "Bound" state. Change-Id: I60e3b9a86acdf251d282059cd2e494c70ae07c70 --- cns-libs/cnslibs/common/openshift_ops.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cns-libs/cnslibs/common/openshift_ops.py b/cns-libs/cnslibs/common/openshift_ops.py index 172a3d6a..9a84ee83 100644 --- a/cns-libs/cnslibs/common/openshift_ops.py +++ b/cns-libs/cnslibs/common/openshift_ops.py @@ -1033,12 +1033,16 @@ def verify_pvc_status_is_bound(hostname, pvc_name, timeout=120, wait_step=3): if msg: raise AssertionError(msg) if w.expired: - # for debug purpose to see why provisioning failed - cmd = "oc describe pvc %s | grep ProvisioningFailed" % pvc_name - ret, out, err = g.run(hostname, cmd, "root") - g.log.info("cmd %s - out- %s err- %s" % (cmd, out, err)) msg = ("Exceeded timeout of '%s' seconds for verifying PVC '%s' " - "to reach the 'Bound' status." % (timeout, pvc_name)) + "to reach the 'Bound' state." % (timeout, pvc_name)) + + # Gather more info for ease of debugging + try: + pvc_events = get_events(hostname, obj_name=pvc_name) + except Exception: + pvc_events = '?' + msg += "\nPVC events: %s" % pvc_events + g.log.error(msg) raise AssertionError(msg) -- cgit