TritonDataCenter / cosbench-manta

COSBench Adaptor for Manta
MIT License
5 stars 7 forks source link

Consul fails to start when multiple private networks are attached #5

Open misterbisson opened 7 years ago

misterbisson commented 7 years ago

This was discussed previously in https://github.com/joyent/containerpilot/issues/258, but @khangngu tells me it's manifesting in this project now.

From the Consul docs:

If there are multiple private IPv4 addresses available, Consul will exit with an error at startup.

The solution is to supply an explicit -bind=<ip addr>, but sadly we can't to that in the co-process startup stanza for Consul. The issue is that we don't know what to advertise there.

Instead, we'll need to add a Consul config file at /etc/consul/consul.json with a placeholder for the bind address, then add a line like the following to a preStart script:

sed -i "s/IP_ADDRESS/${CONTAINERPILOT_<SERVICE>_IP}/" /etc/consul/consul.json

The awkward issue is figuring out the service name. That's set to cosbench-{{ .MODE }} in the containerpilot.json, but I don't know if bash supports variable variable names. Alternatively, it's possible that ContainerPilot also exposes the CONTAINERPILOT_CONTAINERPILOT_IP var as used for ContainerPilot telemetry. The interface/network used in any of these vars is defined using the interfaces spec in the config file. For the telemetry, that might look like:

  "telemetry": {
    "port": 9090,
    "interfaces": ["192.168.0.0/16"]
  }
lucj commented 7 years ago

Hi, I encounter this problem with ContainerPilot v3. Currently, compose file can be changed to that consul server starts with something like:

 agent -server -client=0.0.0.0 -bootstrap -ui -bind='{{ GetInterfaceIP "eth1" }}'

I'm using ContainerPilot v3, but it does not seem to be any env var with a format like CONTAINERPILOT__IP in the service's container.