Add cluster name for the mothership, small UI fixes
Related-PROD: K0RQA-20
Change-Id: Ia7c8a9e20fc28d0484a17ea4c8073193817e0f9f
diff --git a/cfg_checker/common/kube_utils.py b/cfg_checker/common/kube_utils.py
index 36efcaa..eb355ab 100644
--- a/cfg_checker/common/kube_utils.py
+++ b/cfg_checker/common/kube_utils.py
@@ -313,6 +313,17 @@
f"Failed to get the k0rdent release from the '{mgmt_name}' mgmt CRD: {e}")
return "Unknown"
+ def get_cluster_name_from_kube_config(self):
+ try:
+ with open(self.kConfigPath.split(":")[1], "r") as f:
+ config = yaml.safe_load(f)
+ clusters = config.get("clusters", [])
+ return clusters[0].get("name")
+ except Exception as e:
+ logger.warning(
+ f"Failed to get the cluster name from the loaded kubeconfig: {e}")
+ return ""
+
def get_node_info(self, http=False):
# Query API for the nodes and do some presorting
_nodes = {}
diff --git a/cfg_checker/modules/network/checker.py b/cfg_checker/modules/network/checker.py
index b212845..1ad8f99 100644
--- a/cfg_checker/modules/network/checker.py
+++ b/cfg_checker/modules/network/checker.py
@@ -112,6 +112,7 @@
_report(
{
"domain": self.mapper.domain,
+ "cluster_name": self.mapper.cluster['cluster_name'],
"nodes": self.mapper.nodes,
"map": self.mapper.map,
"k0rdent_release": self.mapper.cluster['k0rdent_release']
diff --git a/cfg_checker/nodes.py b/cfg_checker/nodes.py
index eb2ebd8..9b906d8 100644
--- a/cfg_checker/nodes.py
+++ b/cfg_checker/nodes.py
@@ -103,7 +103,8 @@
_info = {
'mcp_release': self.mcp_release,
'openstack_release': self.openstack_release,
- 'k0rdent_release': self.kube.get_k0rdent_release()
+ 'k0rdent_release': self.kube.get_k0rdent_release(),
+ 'cluster_name': self.kube.get_cluster_name_from_kube_config()
}
return _info
diff --git a/templates/network_check_tmpl.j2 b/templates/network_check_tmpl.j2
index d45f55d..9e030d3 100644
--- a/templates/network_check_tmpl.j2
+++ b/templates/network_check_tmpl.j2
@@ -104,8 +104,8 @@
.down > .col_role, .skip > .col_role { padding-left: 5px; }
.head { height: 18px; }
- .col_name { width: 90px; }
- .col_role { width: 130px; }
+ .col_name { width: 130px; height: auto; }
+ .col_role { width: 90px; }
.col_vendor { width: 70px; }
.col_release { width: 100px; }
.col_kernel { min-width: 100px; }
@@ -123,7 +123,7 @@
}
.col_node_notes { width: 225px; }
- .col_cpu_notes { width: 177px; }
+ .col_cpu_notes { width: 177px; font-size: 0.8em;}
.meters {
display: inline-block;
@@ -250,8 +250,10 @@
<body onload="init()">
<div class="header">
- <div class="label">k0rdent release:</div>
- <div class="text">{{ k0rdent_release }}</div>
+ {% if k0rdent_release != "Unknown" %}
+ <div class="label">k0rdent release:</div>
+ <div class="text">{{ k0rdent_release }}</div>
+ {% endif %}
<div class="label">RAM % Warning/Critical:</div>
<div class="text">{{ const['ram_warn'] }}/{{ const['ram_critical'] }}</div>
<div class="label">Disk % Warning/Critical:</div>
@@ -315,22 +317,22 @@
{% if _status == 'down' %}
<tr class="node down">
<td class="status_{{ _status }}">.</td>
- <td class="head col_name">{{ _ndat['shortname'] }}</td>
- <td class="head col_role">{{ _ndat['role'] }}</td>
+ <td class="head col_name" title="{{ _ndat['shortname'] }}">{{ _ndat['shortname'] }}</td>
+ <td class="head col_role">{{ _ndat['labels']['node.k0sproject.io/role'] }}</td>
<td class="head col_down" colspan="7"> ...no data collected: node is down</td>
</tr>
{% elif _status == 'skip' %}
<tr class="node skip">
<td class="status_{{ _status }}">.</td>
- <td class="head col_name">{{ _ndat['shortname'] }}</td>
- <td class="head col_role">{{ _ndat['role'] }}</td>
+ <td class="head col_name" title="{{ _ndat['shortname'] }}">{{ _ndat['shortname'] }}</td>
+ <td class="head col_role">{{ _ndat['labels']['node.k0sproject.io/role'] }}</td>
<td class="head col_skip" colspan="7"> ...no skipped from processing</td>
</tr>
{% else %}
<tr class="node" onclick="toggleClassByID('info_{{ node }}')" id='info_{{ node }}_button'>
<td class="status_{{ _ndat['status'] | node_status_class }}">.</td>
- <td class="head col_name">{{ _ndat['shortname'] }}</td>
- <td class="head col_role">{{ _ndat['role'] }}</td>
+ <td class="head col_name" title="{{ _ndat['shortname'] }}">{{ _ndat['shortname'] }}</td>
+ <td class="head col_role">{{ _ndat['labels']['node.k0sproject.io/role'] }}</td>
<td class="head col_vendor">{{ _ndat['node_type'] }}</td>
<td class="head col_release">{{ _ndat['linux_arch'] }}/{{ _ndat['linux_codename'] }}</td>
<td class="head col_kernel">{{ _ndat['kernel'] }}</td>
@@ -493,7 +495,11 @@
<!-- Cluster nodes page -->
{% call nodes_page(nodes, "nodes") %}
- Cluster nodes status and simple metrics
+ {% if cluster_name %}
+ Cluster {{ cluster_name }} nodes status and simple metrics
+ {% else %}
+ Cluster nodes status and simple metrics
+ {% endif %}
{% endcall %}
<!-- Cluster nodes page -->