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

Allow Livebook to proxy requests to the runtime #2608

Merged
merged 14 commits into from
May 20, 2024

Conversation

aleDsz
Copy link
Member

@aleDsz aleDsz commented May 16, 2024

@aleDsz aleDsz self-assigned this May 16, 2024
Copy link

github-actions bot commented May 16, 2024

Uffizzi Preview deployment-51844 was deleted.

lib/livebook/runtime.ex Outdated Show resolved Hide resolved
mix.exs Outdated Show resolved Hide resolved
config/test.exs Outdated Show resolved Hide resolved

def call(%{path_info: ["apps", slug, "proxy" | path_info]} = conn, _opts) do
app = fetch_app!(slug)
id = App.get_session_id(app.pid)
Copy link
Member

Choose a reason for hiding this comment

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

@josevalim should we validate that the app is single-session? Also, auto_shutdown_ms would be an issue for the first request.

Copy link
Contributor

@josevalim josevalim May 17, 2024

Choose a reason for hiding this comment

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

Good call. We should validate single session app here but also add a route to support multi-session apps. What would be the URL in this case? This?

def call(%{path_info: ["apps", slug, session_id, "proxy" | path_info]} = conn, _opts) do

Copy link
Member

Choose a reason for hiding this comment

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

Technically each app session has that URL, for single-session we redirect the user to that specific URL right away.

The main concern is hitting the app at start, while the proxy is not started yet. So your idea is that the user would start the multi-session app session, perhaps enter some data, and then they could query that session's proxy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly. We need to document on Kino.Proxy.listen that:

  1. For single session apps, you can access it at /apps/slug/proxy for the other apps and session, you need the session URL
  2. You must not enable automatic shutdowns, we don't automatically start apps on demand at the moment

Copy link
Member

Choose a reason for hiding this comment

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

we don't automatically start apps on demand at the moment

With the current code we do, but they need time to setup :D So should we change it to only use existing single-session and error otherwise?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm... I am worried someone may have a never completing app and then those would never work under any URL and having a distinction between them could be helpful? I don't know.

Copy link
Contributor

Choose a reason for hiding this comment

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

Like, given we need to have a session_id, it means you need to manually go and boot it up, I think it is fine to assume it is running.

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, we can decide this later. Let's keep this on the path to merging now. I will resolve the conversation and drop a more precise feedback for Ale.

Copy link
Member

Choose a reason for hiding this comment

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

it means you need to manually go and boot it up

For single session it's just started on deployment, so there's a race condition when someone hits the app too soon.

I am worried someone may have a never completing app

I would error on errors and interrupts, if it takes forever to execute, then it's actually something the user should know and fix, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it is fair and the request will eventually timeout anyway. But yeah, let's implement this later. :)

@jonatanklosko
Copy link
Member

LGTM :)

@aleDsz aleDsz merged commit 16bd46b into livebook-dev:main May 20, 2024
8 checks passed
@aleDsz aleDsz deleted the ale-proxy-request branch May 20, 2024 20:04
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.

Allow Livebook to proxy requests to the runtime
3 participants