Skip to content

Watch config file for token changes#3418

Merged
btoews merged 5 commits into
masterfrom
watch-config
Apr 8, 2024
Merged

Watch config file for token changes#3418
btoews merged 5 commits into
masterfrom
watch-config

Conversation

@btoews

@btoews btoews commented Apr 1, 2024

Copy link
Copy Markdown
Contributor

Change Summary

What and Why:

The macaroons that flyctl gets have a short lifespan. Commands with RequireSession refresh macaroons that are about to expire before the command runs. Similarly, the agent checks every minute if macaroons need to be refreshed soon. This setup works great for commands that run quickly, but I've had some slower deploys fail because my macaroons expired partway through. I've also had issues with long running fly logs where the NATS client has to reconnect but no longer has a valid token. This PR fixes that.

How:

This PR adds an API for watching for changes to the config file. Both the agent and other commands load changes to auth tokens that are written to the config. The agent still checks periodically if tokens need to be updated, and writes those updates to the config. This way, a long running command will start using the new macaroons that were refreshed by the running agent.

I had to submit a PR to the NATS library to allow dynamically changing tokens to be used when reconnecting after an error. I'm hoping nats-io/nats.go#1599 will merge soon so I don't need to point flyctl at my fork.

Related to:


Documentation

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

@btoews

btoews commented Apr 2, 2024

Copy link
Copy Markdown
Contributor Author

I'm going to sit on this for another day or two to see if the nats PR merges.

@btoews btoews force-pushed the watch-config branch 5 times, most recently from d3846a9 to 0bef372 Compare April 8, 2024 15:10
@btoews btoews merged commit 8ba3af5 into master Apr 8, 2024
@btoews btoews deleted the watch-config branch April 8, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants