flyctl icon indicating copy to clipboard operation
flyctl copied to clipboard

phx: less brittle node naming for dns_cluster

Open clutterstack opened this issue 1 year ago • 0 comments

Change Summary

What and Why: The node naming in env.sh.eex as generated by the Phoenix scanner works great if it gets a default tag of the form "deployment-", but broke with an invalid Erlang node name when I deployed using the --image-label flag to get a custom tag containing no hyphen.

How: As described in #2554, the launch callback as-is creates a node name that uses the unique part of the default image tag when it's of the expected form. This PR suggests a way to strip deployment- if present, and otherwise just use the tag to identify the image version.

Build of app garbage with default tagging by fly deploy:

iex(garbage-01J9ST7EVHM23NPVE448VR2RW7@fdaa:0:3b99:a7b:ef:7c89:2bca:2)1> 

and on a different build using fly deploy --image-label test (FLY_IMAGE_REF=registry.fly.io/garbage:test):

iex(garbage-test@fdaa:0:3b99:a7b:ef:7c89:2bca:2)1> 

And with three nodes running:

iex(garbage-test@fdaa:0:3b99:a7b:174:d855:55b8:2)1> Node.list()
[:"garbage-test@fdaa:0:3b99:a7b:ef:7c89:2bca:2",
 :"garbage-test@fdaa:0:3b99:a7b:1d4:7a95:987b:2"]

Documentation

  • [ ] Fresh Produce
  • [ ] In superfly/docs, or asked for help from docs team
  • [x] n/a

clutterstack avatar Oct 10 '24 01:10 clutterstack