Interpolate environment variables in the config #756
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Does an extra round of environment variable interpolation on config values.
Original
Another very nice thing to have:
Right now fendermint doesn't seem to interpolate env variables inside env variables.
A bit of context on NOMAD_PORT_* thing:
this is an env variable set by container orchestrator inside container so I can easily bind to a random port assigned by Nomad. The ports are defined in nomad deployment file.
Very useful for avoiding port collisions.
For example:
If I want to run another subnet on the same pool of hosts. To avoid port collision with another IPC deployment I want to change ports. When I hardcode ports like this:
FM_ABCI__LISTEN__PORT = 27658
I have to not forget to change it in multiple places (like cometbft configuration). When I use templating like thisFM_ABCI__LISTEN__PORT = NOMAD_PORT_fendermint_abci
it is automatically changed when I change it in port declaration in Nomad:In this situation ports are hardcoded in declaration too so I cannot run two IPC nodes on the same host.
I can make Nomad assign a random port
And it can be useful in situation where I have only 4 physical servers and 4 IPC nodes. Affinity would make one IPC run on one server, but in case I do some upgrades to a server and it comes offline for an hour 2 IPC nodes can run on one physical server. And if 3 servers is suddenly offline instead of having whole network down 4 IPC nodes can temporarily run on one physical server. Automatically, so no downtime. And when everything is up again they will migrate gracefully.
This will interpolate to whatever ip:port cometbft runs now so other nodes can find it.