mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-10 06:01:44 +08:00
Check attached node elixir version (#1654)
The attached node should have a minimum elixir version, to avoid problems at runtime. For example, Livebook version 0.8 introduced a dependency on `Code.eval_quoted_with_env/4` which is new since elixir 1.14.2.
This commit is contained in:
parent
f5dbc2de9f
commit
9f3ea5856a
1 changed files with 22 additions and 9 deletions
|
|
@ -39,17 +39,30 @@ defmodule Livebook.Runtime.Attached do
|
||||||
# Set cookie for connecting to this specific node
|
# Set cookie for connecting to this specific node
|
||||||
Node.set_cookie(node, cookie)
|
Node.set_cookie(node, cookie)
|
||||||
|
|
||||||
case Node.ping(node) do
|
with :pong <- Node.ping(node),
|
||||||
:pong ->
|
:ok <- check_attached_node_version(node) do
|
||||||
server_pid =
|
server_pid =
|
||||||
Livebook.Runtime.ErlDist.initialize(node,
|
Livebook.Runtime.ErlDist.initialize(node,
|
||||||
node_manager_opts: [parent_node: node(), capture_orphan_logs: false]
|
node_manager_opts: [parent_node: node(), capture_orphan_logs: false]
|
||||||
)
|
)
|
||||||
|
|
||||||
{:ok, %{runtime | node: node, server_pid: server_pid}}
|
{:ok, %{runtime | node: node, server_pid: server_pid}}
|
||||||
|
else
|
||||||
|
:pang -> {:error, "node #{inspect(node)} is unreachable"}
|
||||||
|
{:error, msg} -> {:error, msg}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
:pang ->
|
@elixir_version_requirement Keyword.fetch!(Mix.Project.config(), :elixir)
|
||||||
{:error, "node #{inspect(node)} is unreachable"}
|
|
||||||
|
defp check_attached_node_version(node) do
|
||||||
|
attached_node_version = :erpc.call(node, System, :version, [])
|
||||||
|
|
||||||
|
if Version.match?(attached_node_version, @elixir_version_requirement) do
|
||||||
|
:ok
|
||||||
|
else
|
||||||
|
{:error,
|
||||||
|
"the node uses Elixir #{attached_node_version}, but #{@elixir_version_requirement} is required"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue