From c3181ad2210ad76a1f27be046b43b108a71dc4f1 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Thu, 30 May 2019 18:49:18 +0530 Subject: 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 --- .../openshiftstoragelibs/openshift_ops.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'openshift-storage-libs') 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. -- cgit