From 7a21d1f7898ba02fffcb26ca199f64fc82b54387 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Fri, 12 Nov 2021 17:54:02 -0500 Subject: [PATCH] Stub out isRegistered --- .../connect-inject/endpoints_controller.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/control-plane/connect-inject/endpoints_controller.go b/control-plane/connect-inject/endpoints_controller.go index 4c52a2b98d..2e2563ad3b 100644 --- a/control-plane/connect-inject/endpoints_controller.go +++ b/control-plane/connect-inject/endpoints_controller.go @@ -149,7 +149,10 @@ func (r *EndpointsController) Reconcile(ctx context.Context, req ctrl.Request) ( // If the endpoints object has the label "connect-ignore" set to true, deregister all instances in Consul for this service. // It is possible that the endpoints object has never been registered, in which case deregistration is a no-op. if value, ok := serviceEndpoints.Labels[labelServiceIgnore]; ok && value == "true" { - return r.deregisterServiceOnAllAgents(ctx, req.Name, req.Namespace, nil, endpointPods) + if isRegistered() { + return r.deregisterServiceOnAllAgents(ctx, req.Name, req.Namespace, nil, endpointPods) + } + return ctrl.Result{}, nil } r.Log.Info("retrieved", "name", serviceEndpoints.Name, "ns", serviceEndpoints.Namespace) @@ -1019,3 +1022,11 @@ func mapAddresses(addresses corev1.EndpointSubset) map[corev1.EndpointAddress]st return m } + +// isRegistered checks if the endpoint is registered in Consul. +func isRegistered() bool { + // TODO: Implement this. + // _, err := r.consul.Catalog().Service(endpoint.ServiceName, "", nil) + // return err == nil + return true +}