From c9e115f67bfa18fa1af054f173b5b549e13c3bc0 Mon Sep 17 00:00:00 2001 From: Sridhar Gaddam Date: Thu, 14 Sep 2023 00:59:30 +0530 Subject: [PATCH] Use endpoints from Broker while validating overlapping CIDRs As part of the following PR[1], we no longer sync an endpoint from the Broker if the endpoint has any overlapping CIDRs with the local cluster. This was done to avoid issues on the Gateway node. Consequently, the subctl diagnose code should ideally examine the endpoints on Broker when validating overlapping CIDRs instead of inspecting the endpoints on the local cluster. This PR addresses this issue. [1] https://github.com/submariner-io/submariner/pull/2263 Signed-off-by: Sridhar Gaddam --- pkg/diagnose/deployments.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/diagnose/deployments.go b/pkg/diagnose/deployments.go index a73874528..778388b4d 100644 --- a/pkg/diagnose/deployments.go +++ b/pkg/diagnose/deployments.go @@ -23,6 +23,8 @@ import ( "github.com/submariner-io/admiral/pkg/reporter" "github.com/submariner-io/subctl/internal/constants" + "github.com/submariner-io/subctl/internal/restconfig" + "github.com/submariner-io/subctl/pkg/client" "github.com/submariner-io/subctl/pkg/cluster" "github.com/submariner-io/submariner/pkg/cidr" "github.com/submariner-io/submariner/pkg/cni" @@ -45,11 +47,22 @@ func checkOverlappingCIDRs(clusterInfo *cluster.Info, status reporter.Interface) defer status.End() - endpointList, err := clusterInfo.ClientProducer.ForSubmariner().SubmarinerV1().Endpoints(clusterInfo.Submariner.Namespace).List( - context.TODO(), metav1.ListOptions{}) + brokerRestConfig, brokerNamespace, err := restconfig.ForBroker(clusterInfo.Submariner, nil) if err != nil { - status.Failure("Error listing the Submariner endpoints: %v", err) - return false + return status.Error(err, "Error getting the Broker's REST config") + } + + clientProducer, err := client.NewProducerFromRestConfig(brokerRestConfig) + if err != nil { + return status.Error(err, "Error creating broker client Producer") + } + + endpointList := &submarinerv1.EndpointList{} + + err = clientProducer.ForGeneral().List(context.TODO(), endpointList, + controllerClient.InNamespace(brokerNamespace)) + if err != nil { + return status.Error(err, "Error listing the Submariner endpoints from the Broker cluster") } tracker := reporter.NewTracker(status)