This repository was archived by the owner on Jan 16, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,17 @@ func (w *Watcher) args(node *v1.Node, category string) []types.DeviceOption {
151151
152152// getInternalAddress finds the node's internal address.
153153func getInternalAddress (addresses []v1.NodeAddress ) * v1.NodeAddress {
154+ var hostname v1.NodeAddress
154155 for _ , address := range addresses {
155156 if address .Type == v1 .NodeInternalIP {
156157 return & address
157158 }
159+ if address .Type == v1 .NodeHostName {
160+ hostname = address
161+ }
158162 }
159-
160- return nil
163+ //if there is no internal IP for this node, the host name will be used
164+ return & hostname
161165}
162166
163167func (w * Watcher ) createRoleDeviceGroup (labels map [string ]string ) {
@@ -201,7 +205,11 @@ func GetNodesMap(k8sClient *kubernetes.Clientset) (map[string]string, error) {
201205 return nil , err
202206 }
203207 for _ , nodeInfo := range nodeList .Items {
204- nodesMap [nodeInfo .Name ] = getInternalAddress (nodeInfo .Status .Addresses ).Address
208+ address := getInternalAddress (nodeInfo .Status .Addresses )
209+ if address == nil {
210+ continue
211+ }
212+ nodesMap [nodeInfo .Name ] = address .Address
205213 }
206214
207215 return nodesMap , nil
You can’t perform that action at this time.
0 commit comments