-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Fly.io runtime #2708
Introduce Fly.io runtime #2708
Conversation
# TODO: do not rely on private APIs. Also, ideally we should still | ||
# be able to use Req.Test.expect/2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @wojtekmach :D
Uffizzi Preview |
Note that this relies on Docker images, so if you want to try this PR locally, change this line: livebook/lib/livebook/runtime/fly.ex Line 163 in 2fe9be2
to image = "jonatanklosko/livebook-main:main" |
node = :"#{node_base}@#{machine_id}.vm.#{app}.internal" | ||
|
||
# We persist the information before the node is reachable | ||
:persistent_term.put(:livebook_runtime_info, %{ | ||
pid: self(), | ||
elixir_version: System.version() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, you could move this to the runtime itself? And then you put the runtime module inside LIVEBOOK_RUNTIME env var and call it here? Then this whole code becomes generic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, we should talk about the initialization flow. :)
This adds a new runtime "Fly.io machine". In the runtime configuration UI, we ask the user for API token, which can be generated in the Fly dashboard. We create a new app (if needed) and the user can configure resources and storage. When connecting to the runtime, we create a new machine, which is automatically destroyed once the runtime is disconnected.
Changes
There are a few elements to this PR:
Now that connecting is a longer operation, I made
Runtime.connect
async. Following this, there were a lot of changes aroundLivebook.Session.Data
to account for the new "connecting" state during operations, and a fair amount of tests that needed adjusting. On a sidenote, this shifted some logic fromSession
and even the LV directly toData
, which is more consistent with other operations and easier to test.For the Fly runtime, we need a custom EPMD module, so I removed EPMD-less mode and now we always use the custom EPMD module. In Docker, Desktop and Escript we set the VM args automatically, however when running from source or in dev it is necessary to set
ELIXIR_ERL_OPTIONS
. I plan a patch to OTP, such that we can set it after boot in the future.The Fly runtime. The runtime is implemented in
Livebook.Runtime.Fly
and there much more details in the module docs. The UI flow is handled inFlyRuntimeComponent
andFlyAPI
.Demo
flyrt.mp4