Consul Connect Question


We have been using consul-connect (we actually made some code change for our own needs - yes somehow we choosen to do so…). It actually works, but we were wondering if we would of have missed something.

We added some extra debug informations inside:
command/connect/proxy/register.go looks like while the proxy is running its keeps calling the register function

ie: r.Client.Agent().ServiceRegister(...)

We ware wondering if we missed something that we might have missed?

Looking at the code it looks like its normal that the system resync the service quite often…

        for {
                select {
                case <-reconcileTimer.C:

                case <-heartbeatTimer.C:
                        heartbeatTimer.Reset(r.TTLPeriod / 3)

                case <-stopCh:
                        r.Logger.Printf("[INFO] proxy: stop request received, deregistering")

If we read this part right, the services keeps registering itself to the agent until it exists ?

What would be the reason behind the multiple register on every 30 seconds?

Also could this at some point cause some kind of ulimit issues? We actually had some too many open files on our testing servers (but we were dong many tests…).

There is this bit of code in the register function:

	// If we have a matching service, then we verify if we need to reregister
	// by comparing if it matches what we expect.
	if currentService != nil &&
		currentService.ServiceAddress == r.LocalAddress &&
		currentService.ServicePort == r.LocalPort {
		r.Logger.Printf("[DEBUG] proxy: service already registered, not re-registering")

So it shouldn’t re-register if we see that the services ip and port are correct for the service. If its actually performing the registration again its because something else has updated/removed the service.

Oh… damn :man_facepalming: i missed that part the register function …

Indeed, this is exactly the reason. I was finding that odd that the service was kept sending a registration process.

Well thank you a lot of taking the time to debug me :). I was finding it weird that it was keeping registrating itself again and again… and was assuming I had missed something.

Btw, consul and consul connect are amazing. Just saying!

1 Like