From eae053f1ada1db87f791c265eea8f3e108e92dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Sat, 5 Oct 2024 03:40:26 +0800 Subject: [PATCH] Check if app deployment is still applicable before retrying failed deployment --- lib/livebook/apps/manager.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/livebook/apps/manager.ex b/lib/livebook/apps/manager.ex index 8b7f3d0cb..54389589c 100644 --- a/lib/livebook/apps/manager.ex +++ b/lib/livebook/apps/manager.ex @@ -315,13 +315,21 @@ defmodule Livebook.Apps.Manager do end defp retry(state, slug) do - if app_definitely_down?(slug) do - %{app_spec: app_spec} = state.deployments[slug] + %{app_spec: app_spec} = state.deployments[slug] + + permanent_app_specs = Apps.get_permanent_app_specs() + + # Check if the app spec has not been retracted or overridden with + # a new version + valid? = Enum.any?(permanent_app_specs, &(&1.slug == slug and &1.version == app_spec.version)) + + if valid? and app_definitely_down?(slug) do ref = deploy(app_spec) put_in(state.deployments[slug].ref, ref) else {_, state} = pop_in(state.deployments[slug]) - state + # If there is a new version, we want to deploy it right away + sync_apps(state) end end