From bfa3b4daf46a3e9dcbc70e19b522354e022fba57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 4 Jun 2020 12:56:04 +0200 Subject: [PATCH] ceph: do not use external node IP for mon endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the cluster is using HostNetworking, Rook was either picking up the external or internal IP of the node. This resulted in mon endpoints have public IP addresses. Those IP are not reachable from within the cluster so OSD/CSI couldn't access the monitors from the configmap endpoint. Also, exposing the cluster on a public network does not seem realistic, so sticky with private/internal IP addresses is better. Closes: https://github.com/rook/rook/issues/5495 Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/mon/node.go | 6 +++--- pkg/operator/ceph/cluster/mon/node_test.go | 8 ++++++-- pkg/operator/test/client.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/operator/ceph/cluster/mon/node.go b/pkg/operator/ceph/cluster/mon/node.go index 5cde108c7..408ca7af5 100644 --- a/pkg/operator/ceph/cluster/mon/node.go +++ b/pkg/operator/ceph/cluster/mon/node.go @@ -52,14 +52,14 @@ func getNodeInfoFromNode(n v1.Node) (*NodeInfo, error) { } for _, ip := range n.Status.Addresses { - if ip.Type == v1.NodeExternalIP || ip.Type == v1.NodeInternalIP { - logger.Debugf("using IP %s for node %s", ip.Address, n.Name) + if ip.Type == v1.NodeInternalIP { + logger.Debugf("using internal IP %s for node %s", ip.Address, n.Name) nr.Address = ip.Address break } } if nr.Address == "" { - return nil, errors.Errorf("couldn't get IP of node %s", nr.Name) + return nil, errors.Errorf("failed to find any internal IP on node %s", nr.Name) } return nr, nil } diff --git a/pkg/operator/ceph/cluster/mon/node_test.go b/pkg/operator/ceph/cluster/mon/node_test.go index 6ea232015..96df950c7 100644 --- a/pkg/operator/ceph/cluster/mon/node_test.go +++ b/pkg/operator/ceph/cluster/mon/node_test.go @@ -212,7 +212,11 @@ func TestGetNodeInfoFromNode(t *testing.T) { var info *NodeInfo info, err = getNodeInfoFromNode(*node) - assert.Nil(t, err) + assert.NotNil(t, err) - assert.Equal(t, "1.1.1.1", info.Address) + node.Status.Addresses[0].Type = v1.NodeInternalIP + node.Status.Addresses[0].Address = "172.17.0.1" + info, err = getNodeInfoFromNode(*node) + assert.Nil(t, err) + assert.Equal(t, "172.17.0.1", info.Address) } diff --git a/pkg/operator/test/client.go b/pkg/operator/test/client.go index c632234f2..bf30c049e 100644 --- a/pkg/operator/test/client.go +++ b/pkg/operator/test/client.go @@ -42,7 +42,7 @@ func New(t *testing.T, nodes int) *fake.Clientset { }, Addresses: []v1.NodeAddress{ { - Type: v1.NodeExternalIP, + Type: v1.NodeInternalIP, Address: fmt.Sprintf("%d.%d.%d.%d", i, i, i, i), }, },