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

Health check fails on alarm report #250

Open
elinol opened this issue Nov 28, 2024 · 0 comments
Open

Health check fails on alarm report #250

elinol opened this issue Nov 28, 2024 · 0 comments

Comments

@elinol
Copy link

elinol commented Nov 28, 2024

Health reports are failing because :alarm_handler.get_alarms() can return a single tuple instead of a list which is expected in the alarm report:

 @impl Report
  def alarms do
    for {id, description} <- :alarm_handler.get_alarms(), into: %{} do
      try do
        {inspect(id), inspect(description)}
      catch
        _, _ ->
          {"bad alarm term", ""}
      end
    end
  end

This prevents the health report from proceeding with the other reports like metrics and connectivity.

On a test device:

iex(39)> NervesHubLink.Extensions.Health.DefaultReport.alarms
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:error, :bad_module} of type Tuple. This protocol is implemented for the following type(s): CircularBuffer, Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Range, Stream
    (elixir 1.17.2) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.17.2) lib/enum.ex:166: Enumerable.reduce/3
    (elixir 1.17.2) lib/enum.ex:4423: Enum.reduce/3
    (nerves_hub_link 2.5.2) lib/nerves_hub_link/extensions/health/default_report.ex:25: NervesHubLink.Extensions.Health.DefaultReport.alarms/0
    iex:39: (file)
iex(39)> :alarm_handler.get_alarms()
{:error, :bad_module}
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

No branches or pull requests

1 participant