summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2019-07-02 12:23:54 +0530
committerNitin Goyal <nigoyal@redhat.com>2019-07-02 12:47:49 +0000
commit3997c825e0a42256ba5125c0cd378934787ff2dc (patch)
tree32ad5d69dc94c219433912b3cb35f3e2e72ae59e /openshift-storage-libs
parent33c9873aca41c262bcc2c31a381279503c1982b9 (diff)
Add state arg in *_service_status_* libs in openshift-ops module
Before, these libraries could be used for 'active' state only. Make it accept one additional 'state' argument for possibility to use it for any state, not just one. Change-Id: I6d4fbd7584b308e3ad248213cb0ec3f4996f6437
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 5186510..c8275c5 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -32,7 +32,7 @@ PODS_WIDE_RE = re.compile(
r'(\S+)\s+(\S+)\s+(\w+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+).*\n')
SERVICE_STATUS = "systemctl status %s"
SERVICE_RESTART = "systemctl restart %s"
-SERVICE_STATUS_REGEX = r"Active: active \((.*)\) since .*;.*"
+SERVICE_STATUS_REGEX = r"Active: (.*) \((.*)\) since .*;.*"
def oc_get_pods(ocp_node, selector=None):
@@ -1296,7 +1296,7 @@ def match_pv_and_heketi_block_volumes(
def check_service_status_on_pod(
- ocp_client, podname, service, status, timeout=180, wait_step=3):
+ ocp_client, podname, service, status, state, timeout=180, wait_step=3):
"""Check a service state on a pod.
Args:
@@ -1304,6 +1304,9 @@ def check_service_status_on_pod(
podname (str): pod name on which service needs to be checked
service (str): service which needs to be checked
status (str): status to be checked
+ e.g. 'active', 'inactive', 'failed'
+ state (str): state to be checked
+ e.g. 'running', 'exited', 'dead'
timeout (int): seconds to wait before service starts having
specified 'status'
wait_step (int): interval in seconds to wait before checking
@@ -1322,7 +1325,8 @@ def check_service_status_on_pod(
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if status_match and status_match.group(1) == status:
+ if (status_match and status_match.group(1) == status and
+ status_match.group(2) == state):
return True
if w.expired:
@@ -1331,13 +1335,17 @@ def check_service_status_on_pod(
def wait_for_service_status_on_gluster_pod_or_node(
- ocp_client, service, status, gluster_node, timeout=180, wait_step=3):
+ ocp_client, service, status, state, gluster_node,
+ timeout=180, wait_step=3):
"""Wait for a service specific status on a Gluster POD or node.
Args:
ocp_client (str): hostname on which we want to check service
service (str): target service to be checked
status (str): service status which we wait for
+ e.g. 'active', 'inactive', 'failed'
+ state (str): service state which we wait for
+ e.g. 'running', 'exited', 'dead'
gluster_node (str): Gluster node IPv4 which stores either Gluster POD
or Gluster services directly.
timeout (int): seconds to wait before service starts having
@@ -1353,7 +1361,8 @@ def wait_for_service_status_on_gluster_pod_or_node(
ocp_client, SERVICE_STATUS % service, gluster_node)
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if status_match and status_match.group(1) == status:
+ if (status_match and status_match.group(1) == status and
+ status_match.group(2) == state):
return True
if w.expired:
g.log.error(err_msg)