MCPcopy
hub / github.com/fluid-cloudnative/fluid / GetWorkerNodes

Method GetWorkerNodes

pkg/ctrl/worker.go:63–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61}
62
63func (e *Helper) GetWorkerNodes() (nodes []corev1.Node, err error) {
64 var (
65 nodeList = &corev1.NodeList{}
66 // runtimeLabel indicates the specific runtime pod is on the node
67 // e.g. fluid.io/s-alluxio-default-hbase=true
68 runtimeLabelKey = e.runtimeInfo.GetRuntimeLabelName()
69 )
70
71 labelNames := []string{runtimeLabelKey}
72 e.log.Info("check node labels", "labelNames", labelNames)
73 runtimeLabelSelector, err := labels.Parse(fmt.Sprintf("%s=true", runtimeLabelKey))
74 if err != nil {
75 return
76 }
77
78 err = e.client.List(context.TODO(), nodeList, &client.ListOptions{
79 LabelSelector: runtimeLabelSelector,
80 })
81 if err != nil {
82 return nodes, err
83 }
84
85 nodes = nodeList.Items
86 if len(nodes) == 0 {
87 e.log.Info("No node with runtime label is found")
88 return
89 } else {
90 e.log.Info("Find the runtime label for nodes", "len", len(nodes))
91 }
92
93 return
94}
95
96// GetIpAddressesOfWorker gets Ipaddresses from the Worker Node
97func (e *Helper) GetIpAddressesOfWorker() (ipAddresses []string, err error) {

Callers 1

Calls 1

GetRuntimeLabelNameMethod · 0.65

Tested by

no test coverage detected