mirror of
https://github.com/krkn-chaos/krkn.git
synced 2026-08-25 09:27:36 +00:00
Starts fixing small parts of issue #185
This commit is contained in:
@@ -23,6 +23,32 @@ def initialize_clients(kubeconfig_path):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def get_host() -> str:
|
||||
"""Returns the Kubernetes server URL"""
|
||||
return client.configuration.Configuration.get_default_copy().host
|
||||
|
||||
|
||||
def get_clusterversion_string() -> str:
|
||||
"""Returns clusterversion status text on OpenShift, empty string on other distributions"""
|
||||
try:
|
||||
custom_objects_api = client.CustomObjectsApi()
|
||||
cvs = custom_objects_api.list_cluster_custom_object(
|
||||
"config.openshift.io",
|
||||
"v1",
|
||||
"clusterversions",
|
||||
)
|
||||
for cv in cvs["items"]:
|
||||
for condition in cv["status"]["conditions"]:
|
||||
if condition["type"] == "Progressing":
|
||||
return condition["message"]
|
||||
return ""
|
||||
except client.exceptions.ApiException as e:
|
||||
if e.status == 404:
|
||||
return ""
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
# List all namespaces
|
||||
def list_namespaces(label_selector=None):
|
||||
namespaces = []
|
||||
|
||||
+7
-6
@@ -9,7 +9,6 @@ import pyfiglet
|
||||
import uuid
|
||||
import time
|
||||
import kraken.kubernetes.client as kubecli
|
||||
import kraken.invoke.command as runcommand
|
||||
import kraken.litmus.common_litmus as common_litmus
|
||||
import kraken.time_actions.common_time_functions as time_actions
|
||||
import kraken.performance_dashboards.setup as performance_dashboards
|
||||
@@ -97,11 +96,13 @@ def main(cfg):
|
||||
|
||||
# Cluster info
|
||||
logging.info("Fetching cluster info")
|
||||
cluster_version = runcommand.invoke("kubectl get clusterversion", 60)
|
||||
cluster_info = runcommand.invoke(
|
||||
"kubectl cluster-info | awk 'NR==1' | sed -r " "'s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g'", 60
|
||||
) # noqa
|
||||
logging.info("\n%s%s" % (cluster_version, cluster_info))
|
||||
cv = kubecli.get_clusterversion_string()
|
||||
if cv != "":
|
||||
logging.info(cv)
|
||||
else:
|
||||
logging.info("Cluster version CRD not detected, skipping")
|
||||
|
||||
logging.info("Server URL: %s" % kubecli.get_host())
|
||||
|
||||
# Deploy performance dashboards
|
||||
if deploy_performance_dashboards:
|
||||
|
||||
Reference in New Issue
Block a user