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 <utku.ozdemir@siderolabs.com>
This commit is contained in:
Utku Ozdemir 2023-04-21 11:57:32 +02:00
parent e5491ddade
commit 2d824b5639
No known key found for this signature in database
GPG Key ID: 65933E76F0549B0D
2 changed files with 30 additions and 17 deletions

View File

@ -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())

View File

@ -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 {