feat: extend node definition used in health checks

Introduce `cluster.NodeInfo` to represent the basic info about a node which can be used in the health checks. This information, where possible, will be populated by the discovery service in following PRs. Part of siderolabs#5554.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
This commit is contained in:
Utku Ozdemir
2022-06-08 13:22:55 +02:00
parent 7a11b4def7
commit 8d2be5e315
52 changed files with 569 additions and 254 deletions

View File

@@ -8,31 +8,22 @@
package base
import (
"fmt"
"github.com/talos-systems/talos/pkg/cluster"
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/machine"
)
type infoWrapper struct {
masterNodes []string
workerNodes []string
nodeInfos []cluster.NodeInfo
nodeInfosByType map[machine.Type][]cluster.NodeInfo
}
func (wrapper *infoWrapper) Nodes() []string {
return append([]string(nil), append(wrapper.masterNodes, wrapper.workerNodes...)...)
func (wrapper *infoWrapper) Nodes() []cluster.NodeInfo {
return wrapper.nodeInfos
}
func (wrapper *infoWrapper) NodesByType(t machine.Type) []string {
switch t {
case machine.TypeInit:
return nil
case machine.TypeControlPlane:
return append([]string(nil), wrapper.masterNodes...)
case machine.TypeWorker:
return append([]string(nil), wrapper.workerNodes...)
case machine.TypeUnknown:
fallthrough
default:
panic(fmt.Sprintf("unexpected machine type %v", t))
}
func (wrapper *infoWrapper) NodesByType(t machine.Type) []cluster.NodeInfo {
return wrapper.nodeInfosByType[t]
}