mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-24 06:48:07 +08:00
Improve waiting for Fly machine startup (#2720)
This commit is contained in:
parent
d71dedd842
commit
5686771646
2 changed files with 11 additions and 7 deletions
|
@ -193,11 +193,18 @@ defmodule Livebook.FlyAPI do
|
||||||
"""
|
"""
|
||||||
@spec await_machine_started(String.t(), String.t(), String.t()) :: :ok | {:error, error}
|
@spec await_machine_started(String.t(), String.t(), String.t()) :: :ok | {:error, error}
|
||||||
def await_machine_started(token, app_name, machine_id) do
|
def await_machine_started(token, app_name, machine_id) do
|
||||||
|
# The maximum supported timeout is 60s, but the machine may take
|
||||||
|
# longer to start if it uses a large Docker image (such as CUDA),
|
||||||
|
# provided the image is not already in the Fly cache. To achieve
|
||||||
|
# a longer wait, we retry request timeouts (and possible network
|
||||||
|
# errors).
|
||||||
with {:ok, _data} <-
|
with {:ok, _data} <-
|
||||||
flaps_request(token, "/v1/apps/#{app_name}/machines/#{machine_id}/wait",
|
flaps_request(token, "/v1/apps/#{app_name}/machines/#{machine_id}/wait",
|
||||||
params: %{state: "started", timeout: 60},
|
params: %{state: "started", timeout: 60},
|
||||||
receive_timeout: 90_000,
|
receive_timeout: 90_000,
|
||||||
retry: false
|
retry: :safe_transient,
|
||||||
|
max_retries: 4,
|
||||||
|
retry_log_level: false
|
||||||
) do
|
) do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
|
@ -214,13 +214,10 @@ defmodule Livebook.Runtime.Fly do
|
||||||
:ok ->
|
:ok ->
|
||||||
:ok
|
:ok
|
||||||
|
|
||||||
{:error, %{status: 408}} ->
|
|
||||||
{:error,
|
|
||||||
"timed out while waiting for the machine to start. See the app" <>
|
|
||||||
" logs in the Fly.io dashboard to determine the reason"}
|
|
||||||
|
|
||||||
{:error, %{message: message}} ->
|
{:error, %{message: message}} ->
|
||||||
{:error, "failed while waiting for the machine to started, reason: #{message}"}
|
{:error,
|
||||||
|
"failed while waiting for the machine to start, reason: #{message}." <>
|
||||||
|
" See the app logs in the Fly.io dashbaord to determine the reason"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue