Skip to content
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

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Introduce Fly.io runtime #2708

merged 4 commits into from
Jul 15, 2024

Conversation

jonatanklosko
Copy link
Member

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:

  1. Now that connecting is a longer operation, I made Runtime.connect async. Following this, there were a lot of changes around Livebook.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 from Session and even the LV directly to Data, which is more consistent with other operations and easier to test.

  2. 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.

  3. 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 in FlyRuntimeComponent and FlyAPI.

Demo

flyrt.mp4

Comment on lines +249 to +250
# TODO: do not rely on private APIs. Also, ideally we should still
# be able to use Req.Test.expect/2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @wojtekmach :D

Copy link

github-actions bot commented Jul 12, 2024

Uffizzi Preview deployment-54146 was deleted.

@jonatanklosko
Copy link
Member Author

Note that this relies on Docker images, so if you want to try this PR locally, change this line:

image = "ghcr.io/livebook-dev/livebook:#{base_image.tag}"

to

image = "jonatanklosko/livebook-main:main"

Comment on lines +12 to +18
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()
})
Copy link
Contributor

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?

Copy link
Contributor

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. :)

@jonatanklosko jonatanklosko merged commit c5ba8f8 into main Jul 15, 2024
7 checks passed
@jonatanklosko jonatanklosko deleted the jk-fly branch July 15, 2024 04:19
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