Skip to content

Commit

Permalink
adding ibm shut down scenario
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED

Signed-off-by: Auto User <[email protected]>
  • Loading branch information
paigerube14 authored and Auto User committed Sep 19, 2024
1 parent 34bfc0d commit cb60055
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/cluster_shut_down_scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Current accepted cloud types:
* [GCP](cloud_setup.md#gcp)
* [AWS](cloud_setup.md#aws)
* [Openstack](cloud_setup.md#openstack)
* [IBMCloud](cloud_setup.md#ibmcloud)


```
Expand Down
11 changes: 10 additions & 1 deletion kraken/plugins/node_scenarios/ibmcloud_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ def __init__(self):
self.service.set_service_url(service_url)
except Exception as e:
logging.error("error authenticating" + str(e))
sys.exit(1)


# Get the instance ID of the node
def get_instance_id(self, node_name):
node_list = self.list_instances()
for node in node_list:
if node_name == node["vpc_name"]:
return node["vpc_id"]
logging.error("Couldn't find node with name " + str(node_name) + ", you could try another region")
sys.exit(1)

def delete_instance(self, instance_id):
"""
Expand Down
8 changes: 4 additions & 4 deletions kraken/shut_down/common_shut_down_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ..post_actions import actions as post_actions
from ..node_actions.aws_node_scenarios import AWS
from ..node_actions.openstack_node_scenarios import OPENSTACKCLOUD
from ..plugins.node_scenarios.ibmcloud_plugin import IbmCloud
from ..node_actions.az_node_scenarios import Azure
from ..node_actions.gcp_node_scenarios import GCP
from krkn_lib.k8s import KrknKubernetes
Expand Down Expand Up @@ -61,6 +62,8 @@ def cluster_shut_down(shut_down_config, kubecli: KrknKubernetes):
cloud_object = OPENSTACKCLOUD()
elif cloud_type.lower() in ["azure", "az"]:
cloud_object = Azure()
elif cloud_type.lower() in ["ibm", "ibmcloud"]:
cloud_object = IbmCloud()
else:
logging.error(
"Cloud type %s is not currently supported for cluster shut down" %
Expand All @@ -69,13 +72,11 @@ def cluster_shut_down(shut_down_config, kubecli: KrknKubernetes):
# removed_exit
# sys.exit(1)
raise RuntimeError()

nodes = kubecli.list_nodes()
node_id = []
for node in nodes:
instance_id = cloud_object.get_instance_id(node)
node_id.append(instance_id)
logging.info("node id list " + str(node_id))
for _ in range(runs):
logging.info("Starting cluster_shut_down scenario injection")
stopping_nodes = set(node_id)
Expand Down Expand Up @@ -164,8 +165,7 @@ def run(scenarios_list,

with open(config_path, "r") as f:
shut_down_config_yaml = yaml.full_load(f)
shut_down_config_scenario = \
shut_down_config_yaml["cluster_shut_down_scenario"]
shut_down_config_scenario = shut_down_config_yaml["cluster_shut_down_scenario"]
start_time = int(time.time())
try:
cluster_shut_down(shut_down_config_scenario, telemetry.kubecli)
Expand Down

0 comments on commit cb60055

Please sign in to comment.