ceph: prevent operator crash with host networking and mon not found

When the node is not found for mon assignment with host networking
enabled, the operator may crash. This change ensures the node is
not nil and returns an error instead of crashing.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
This commit is contained in:
Travis Nielsen committed 2021-01-27 15:34:16 -07:00
1 parent c0fabef5c3
commit 5cf3338bcd
1 file changed
+2 -2
+2 -2
View File
@@ -789,8 +789,8 @@ func (c *Cluster) initMonIPs(mons []*monConfig) error {
if c.spec.Network.IsHost() {
logger.Infof("setting mon endpoints for hostnetwork mode")
node, ok := c.mapping.Schedule[m.DaemonName]
if !ok {
return errors.New("mon doesn't exist in assignment map")
if !ok || node == nil {
return fmt.Errorf("node for mon %q doesn't exist in assignment map", m.DaemonName)
}
m.PublicIP = node.Address
} else {