litefs on fly with consul

Was experimenting on getting elixir running with litefs.

I noticed that fly has consul available as an experimental service: Sneak peak: global lock service

However, I cannot seem to get litefs (or anything to connect to consul).

root@757e069e:/# env|grep CONSU
FLY_CONSUL_URL=https://:8e2cec58-87ac-3626-36ce-f72a5a1b894f@consul-iad-2.fly-shared.net/polished-moon-4104-6r85yqlvw8v12pvl/


# litefs -config /app/config/litefs.yml 
initializing consul: key=https://:8e2cec58-87ac-3626-36ce-f72a5a1b894f@consul-iad-2.fly-shared.net/polished-moon-4104-6r85yqlvw8v12pvl/ url=litefs/primary advertise-url=http://:20202
LiteFS mounted to: /mnt/litefs
http server listening on: http://localhost:20202
cannot acquire lease or find primary, retrying: acquire lease: create consul session: Unexpected response code: 403 (rpc error making call: Permission denied)
cannot acquire lease or find primary, retrying: acquire lease: create consul session: Unexpected response code: 403 (rpc error making call: Permission denied)
cannot acquire lease or find primary, retrying: acquire lease: create consul session: Unexpected response code: 403 (Permission denied)

I’m not sure if the ACL’s have changed from the announcement thread, but I tried that also:

# export CONSUL_TOKEN=8e2cec58-87ac-3626-36ce-f72a5a1b894f
# curl -H "X-Consul-Token: ${CONSUL_TOKEN}" \
    "https://consul-iad-2.fly-shared.net/v1/catalog/register" \
    -XPOST \
    -d '{"Name":"polished-moon-4104-6r85yqlvw8v12pvl","Address":"fdaa:0:2fff:a7b:a45b:757e:69e:2"}'

method POST not allowed

Complete newbie at using consul and I’m finding even downloading the consul binary and connecting it to the lock service to be difficult.

Any tips?

1 Like

You may want to try litefs from main as this PR enabled shared consul usage. The simplest way is litefs from Docker Hub.

1 Like

This is very odd. I was using

FROM flyio/litefs as litefs
COPY --from=litefs /usr/local/bin/litefs /usr/local/bin/litefs

I just compiled it from github and copied that to the docker image instead and now it can acquire the lease. Guess the docker image might be out of date?

Anyway, thanks for the hint. Works now.

root@2f176b64:/# litefs -config /app/config/litefs.yml 
Using Consul to determine primary
initializing consul: key= url=https://:8e2cec58-87ac-3626-36ce-f72a5a1b894f@consul-iad-2.fly-shared.net/polished-moon-4104-6r85yqlvw8v12pvl/ hostname=2f176b64 advertise-url=http://2f176b64:20202
LiteFS mounted to: /mnt/litefs
http server listening on: http://localhost:20202
primary lease acquired, advertising as http://2f176b64:20202