From 995a8f800c9e3b137f105e676d83d481baa70a6e Mon Sep 17 00:00:00 2001 From: Nate Shoemaker Date: Thu, 5 Dec 2024 08:38:18 -0800 Subject: [PATCH] Disconnect device after its moved product so it can go through the reconnect process, display device.deployment_conflict when viewing device --- lib/nerves_hub/devices.ex | 3 ++- lib/nerves_hub_web/channels/device_channel.ex | 14 -------------- lib/nerves_hub_web/live/devices/show.html.heex | 11 +++++++++++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/nerves_hub/devices.ex b/lib/nerves_hub/devices.ex index bef55a894..d3e38a4e0 100644 --- a/lib/nerves_hub/devices.ex +++ b/lib/nerves_hub/devices.ex @@ -28,6 +28,7 @@ defmodule NervesHub.Devices do alias NervesHub.Products.Product alias NervesHub.Repo alias NervesHub.TaskSupervisor, as: Tasks + alias NervesHubWeb.Endpoint @min_fwup_delta_updatable_version ">=1.10.0" @@ -1086,7 +1087,7 @@ defmodule NervesHub.Devices do |> Repo.transaction() |> case do {:ok, %{move: updated}} -> - _ = broadcast(updated, "moved") + _ = Endpoint.broadcast("device_socket:#{updated.id}", "disconnect", %{}) {:ok, updated} err -> diff --git a/lib/nerves_hub_web/channels/device_channel.ex b/lib/nerves_hub_web/channels/device_channel.ex index b0efab8da..45c23b52a 100644 --- a/lib/nerves_hub_web/channels/device_channel.ex +++ b/lib/nerves_hub_web/channels/device_channel.ex @@ -48,11 +48,6 @@ defmodule NervesHubWeb.DeviceChannel do subscribe("device:#{device.id}") subscribe(deployment_channel) - if device_health_check_enabled?() do - send(self(), :health_check) - schedule_health_check() - end - send(self(), :device_registration) socket = @@ -480,14 +475,5 @@ defmodule NervesHubWeb.DeviceChannel do socket end - defp schedule_health_check() do - if device_health_check_enabled?() do - Process.send_after(self(), :health_check, device_health_check_interval()) - :ok - else - :ok - end - end - defp is_safe_to_request_extensions?(version), do: Version.match?(version, ">= 2.2.0") end diff --git a/lib/nerves_hub_web/live/devices/show.html.heex b/lib/nerves_hub_web/live/devices/show.html.heex index 62a431d25..4ecaa64b1 100644 --- a/lib/nerves_hub_web/live/devices/show.html.heex +++ b/lib/nerves_hub_web/live/devices/show.html.heex @@ -67,6 +67,17 @@ Device has disabled extensions: <%= Enum.join(@extension_overrides, ", ") %> + <%= if reason = @device.deployment_conflict do %> +
+
+ Deployment Conflict Reason + + When a device connects and it's firmware and/or architecture don't match it's deployment, it's removed from the deployment and the conflict reason is set. +
+ <%= Phoenix.Naming.humanize(reason) %> +
+ <% end %> +
Tags

No Tags