From 2d824b5639a4b8c3b673d13b08b2b97c69aafe0d Mon Sep 17 00:00:00 2001 From: Utku Ozdemir Date: Fri, 21 Apr 2023 11:57:32 +0200 Subject: [PATCH] fix: do not show control plane status for workers on dashboard Hide kube-apiserver, kube-controller-manager and kube-scheduler statuses on the dashboard for the worker nodes, instead of showing them as n/a. Also display the cluster name as n/a for workers (instead of an empty string), as that information is not available to them. Closes siderolabs/talos#7103. Signed-off-by: Utku Ozdemir --- .../dashboard/components/kubernetesinfo.go | 42 ++++++++++++------- .../pkg/dashboard/components/talosinfo.go | 5 ++- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/internal/pkg/dashboard/components/kubernetesinfo.go b/internal/pkg/dashboard/components/kubernetesinfo.go index 5547ff1f0..e002d621f 100644 --- a/internal/pkg/dashboard/components/kubernetesinfo.go +++ b/internal/pkg/dashboard/components/kubernetesinfo.go @@ -13,6 +13,8 @@ import ( "github.com/siderolabs/talos/internal/pkg/dashboard/apidata" "github.com/siderolabs/talos/internal/pkg/dashboard/resourcedata" + "github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1/machine" + "github.com/siderolabs/talos/pkg/machinery/resources/config" "github.com/siderolabs/talos/pkg/machinery/resources/k8s" ) @@ -23,6 +25,7 @@ type staticPodStatuses struct { } type kubernetesInfoData struct { + isControlPlane bool kubernetesVersion string kubeletStatus string @@ -102,6 +105,8 @@ func (widget *KubernetesInfo) updateNodeData(data resourcedata.Data) { } nodeData.podStatuses = widget.staticPodStatuses(maps.Values(nodeData.staticPodStatusMap)) + case *config.MachineType: + nodeData.isControlPlane = !data.Deleted && res.MachineType() == machine.TypeControlPlane } } @@ -142,29 +147,36 @@ func (widget *KubernetesInfo) getOrCreateNodeData(node string) *kubernetesInfoDa func (widget *KubernetesInfo) redraw() { data := widget.getOrCreateNodeData(widget.selectedNode) - fields := fieldGroup{ - fields: []field{ - { - Name: "KUBERNETES", - Value: data.kubernetesVersion, - }, - { - Name: "KUBELET", - Value: data.kubeletStatus, - }, - { + fieldList := make([]field, 0, 5) + + fieldList = append(fieldList, + field{ + Name: "KUBERNETES", + Value: data.kubernetesVersion, + }, + field{ + Name: "KUBELET", + Value: data.kubeletStatus, + }) + + if data.isControlPlane { + fieldList = append(fieldList, + field{ Name: "APISERVER", Value: data.podStatuses.apiServer, }, - { + field{ Name: "CONTROLLER-MANAGER", Value: data.podStatuses.controllerManager, }, - { + field{ Name: "SCHEDULER", Value: data.podStatuses.scheduler, - }, - }, + }) + } + + fields := fieldGroup{ + fields: fieldList, } widget.SetText(fields.String()) diff --git a/internal/pkg/dashboard/components/talosinfo.go b/internal/pkg/dashboard/components/talosinfo.go index 3164f63e3..fde3794ba 100644 --- a/internal/pkg/dashboard/components/talosinfo.go +++ b/internal/pkg/dashboard/components/talosinfo.go @@ -79,10 +79,11 @@ func (widget *TalosInfo) updateNodeData(data resourcedata.Data) { nodeData.uuid = res.TypedSpec().UUID } case *cluster.Info: - if data.Deleted { + clusterName := res.TypedSpec().ClusterName + if data.Deleted || clusterName == "" { nodeData.clusterName = notAvailable } else { - nodeData.clusterName = res.TypedSpec().ClusterName + nodeData.clusterName = clusterName } case *runtime.MachineStatus: if data.Deleted {