diff options
author | Arun Kumar <arukumar@redhat.com> | 2019-05-30 18:49:18 +0530 |
---|---|---|
committer | vponomar <vponomar@redhat.com> | 2019-09-25 12:49:03 +0000 |
commit | c3181ad2210ad76a1f27be046b43b108a71dc4f1 (patch) | |
tree | 6382f03ac3bffcaf764e01d41ea4dd964cd75765 /openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | |
parent | 203410a740e275cce78e840c30c583c82e563c28 (diff) |
Add TC Fail tcmu-runner service while creating and deleting pvc
Create 8 Block PVC and wait for them to get bound. Delete created
PVC's and create 8 more PVC's simultaneously. Kill the tcmu-runner
service while PVC creation and deletion is in the progress. Restart
all the services related to block volumes and verify all pending
operations are completed sucessfully.
Change-Id: I0cb4cd29b92233a65be93f4b96f1a9a0cb8bed9f
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/openshift_ops.py')
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py index 62c6affe..07c90d7a 100644 --- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py @@ -34,6 +34,9 @@ PODS_WIDE_RE = re.compile( SERVICE_STATUS = "systemctl status %s" SERVICE_RESTART = "systemctl restart %s" SERVICE_STATUS_REGEX = r"Active: (.*) \((.*)\) since .*;.*" +PGREP_SERVICE = "pgrep %s" +KILL_SERVICE = "kill -9 %s" +IS_ACTIVE_SERVICE = "systemctl is-active %s" def oc_get_pods(ocp_node, selector=None): @@ -1487,6 +1490,33 @@ def restart_service_on_gluster_pod_or_node(ocp_client, service, gluster_node): ocp_client, SERVICE_RESTART % service, gluster_node) +def kill_service_on_gluster_pod_or_node(ocp_client, service, gluster_node): + """Kill service on Gluster pod or node. + + Args: + ocp_client (str): host on which we want to run 'oc' commands. + service (str): service which needs to be killed + gluster_node (str): Gluster node IPv4 which stores either Gluster POD + or Gluster services directly. + Raises: + AssertionError: In case killing of a service fails. + """ + # Get the pid of the service which needs to be killed + get_service_pids = cmd_run_on_gluster_pod_or_node( + ocp_client, PGREP_SERVICE % service, gluster_node=gluster_node) + service_pids = " ".join(get_service_pids.split("\n")) + cmd_run_on_gluster_pod_or_node( + ocp_client, KILL_SERVICE % service_pids, gluster_node=gluster_node) + + # Check the status of service + try: + cmd_run_on_gluster_pod_or_node( + ocp_client, IS_ACTIVE_SERVICE % service, gluster_node=gluster_node) + except exceptions.ExecutionError as err: + if "command terminated with exit code 3" not in str(err): + raise + + def oc_adm_manage_node( ocp_client, operation, nodes=None, node_selector=None): """Manage common operations on nodes for administrators. |