Skip to content

Commit

Permalink
ceph: use node externalIP if no internalIP defined
Browse files Browse the repository at this point in the history
In some cases node internalIP is not defined. Then use externalIP if it
exists.

Signed-off-by: JrCs <90z7oey02@sneakemail.com>
  • Loading branch information
JrCs committed Sep 7, 2021
1 parent d0366dc commit 2cf5b77
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/operator/ceph/cluster/mon/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ func getNodeInfoFromNode(n v1.Node) (*MonScheduleInfo, error) {
break
}
}

// If no internal IP found try to use an external IP
if nr.Address == "" {
for _, ip := range n.Status.Addresses {
if ip.Type == v1.NodeExternalIP {
logger.Debugf("using external IP %s for node %s", ip.Address, n.Name)
nr.Address = ip.Address
break
}
}
}

if nr.Address == "" {
return nil, errors.Errorf("failed to find any internal IP on node %s", nr.Name)
return nil, errors.Errorf("failed to find any internal or external IP on node %s", nr.Name)
}
return nr, nil
}

0 comments on commit 2cf5b77

Please sign in to comment.