Consul Connector - Port Error

Hi,

we have been using cbes in autonomous mode for some time. We’re happy with it but we have got a problem. Whenever we use prebuilt images, we got this error on startup:

Cannot construct instance of com.orbitz.consul.model.health.ImmutableService, problem: Cannot build Service, some of required attributes are not set [port]


We deep dived into couchbase-elasticsearch-connector and find this code in SessionTask.java file:

ctx.consul().agentClient().register(0, sessionTtlSeconds, ctx.serviceName(), ctx.serviceId(), tags, meta);

We thought this is the cause and changed this line with this:

ctx.consul().agentClient().register(Consul.DEFAULT_HTTP_PORT, sessionTtlSeconds, ctx.serviceName(), ctx.serviceId(), tags, meta);

When we build our custom image with this modification, the connector runs without any errors or problems. Everything works as expected.

We started to get this problem after upgrading our consul to 1.10.0 version. Are you aware of this problem? What may be the cause of this and what do you think of our custom fix?

Thanks.

1 Like

Hi Emre,

Thank you for sharing the results of your deep dive.

Consul 1.10.0 currently isn’t one of the versions we test against and support, so I’m glad you reported this issue. I’ve filed CBES-237 for adding recent versions of Consul to the compatibility matrix and investigating the failure you’re seeing.

Thanks,
David

1 Like

Hi Emre,

I believe the root cause is that Consul 1.10 only includes the port field in the service definition JSON if the value is non-zero. You’re seeing this error because the Consul client library used by the connector always expects the port field to be present in the JSON.

Your workaround of supplying a non-zero port number looks okay to me. I believe any non-zero port would work, since the connector doesn’t actually expose a service at this port.

We’re tracking this as CBES-238, to be fixed in the 4.3.5 release tentatively scheduled for Jan 18, 2022.

Thanks,
David

1 Like