Skip to content

Commit

Permalink
ISSUE-779 - check for agent status before deregistration
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasKohout committed Oct 19, 2021
1 parent de72393 commit aa6d5ac
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions control-plane/connect-inject/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,18 @@ func (r *EndpointsController) deregisterServiceOnAllAgents(ctx context.Context,

// On each agent, we need to get services matching "k8s-service-name" and "k8s-namespace" metadata.
for _, agent := range agents.Items {

ready := false
for _, status := range agent.Status.Conditions {
if status.Type == corev1.PodReady {
ready = status.Status == corev1.ConditionTrue
}
}
if !ready {
r.Log.Info("Consul agent is not ready, skipping sync", "consul-agent", agent.Name)
continue
}

client, err := r.remoteConsulClient(agent.Status.PodIP, r.consulNamespace(k8sSvcNamespace))
if err != nil {
r.Log.Error(err, "failed to create a new Consul client", "address", agent.Status.PodIP)
Expand Down

0 comments on commit aa6d5ac

Please sign in to comment.