diff --git a/apps/core/lib/core/clients/console.ex b/apps/core/lib/core/clients/console.ex index 1d4f3a3c7..60ceebc26 100644 --- a/apps/core/lib/core/clients/console.ex +++ b/apps/core/lib/core/clients/console.ex @@ -49,7 +49,8 @@ defmodule Core.Clients.Console do def clusters(client) do Req.post(client, graphql: @clusters_q) |> case do - {:ok, %Req.Response{body: %{"clusters" => %{"edges" => edges}}}} -> {:ok, Enum.map(edges, & &1["node"])} + {:ok, %Req.Response{body: %{"data" => %{"clusters" => %{"edges" => edges}}}}} -> + {:ok, Enum.map(edges, & &1["node"])} res -> Logger.warn "Failed to fetch clusters: #{inspect(res)}" {:error, "could not fetch clusters"} diff --git a/apps/core/lib/core/schema/cockroach_cluster.ex b/apps/core/lib/core/schema/cockroach_cluster.ex index 0e92016a5..f4cff9294 100644 --- a/apps/core/lib/core/schema/cockroach_cluster.ex +++ b/apps/core/lib/core/schema/cockroach_cluster.ex @@ -29,6 +29,6 @@ defmodule Core.Schema.CockroachCluster do model |> cast(attrs, ~w(name cloud region url certificate endpoints)a) |> unique_constraint(:name) - |> validate_required(~w(name cloud region url certificate endpoints)a) + |> validate_required(~w(name cloud url certificate endpoints)a) end end diff --git a/apps/core/lib/core/services/cloud/poller.ex b/apps/core/lib/core/services/cloud/poller.ex index 46c35fb5e..22d780f26 100644 --- a/apps/core/lib/core/services/cloud/poller.ex +++ b/apps/core/lib/core/services/cloud/poller.ex @@ -61,6 +61,7 @@ defmodule Core.Services.Cloud.Poller do cloud: to_cloud(distro), region: meta["region"] }, name) + |> log_err("failed to insert cloud cluster: ") end defp upsert_roach(%{"name" => name} = roach) do @@ -70,6 +71,7 @@ defmodule Core.Services.Cloud.Poller do certificate: roach["certificate"], endpoints: roach["endpoints"] }, name) + |> log_err("failed to insert cockroach cluster: ") end defp read_secret() do @@ -77,7 +79,8 @@ defmodule Core.Services.Cloud.Poller do |> Kazan.run() |> case do {:ok, %CoreV1.Secret{data: %{"cockroaches" => roaches}}} -> - Jason.decode(roaches) + Base.decode64!(roaches) + |> Jason.decode() _ -> {:error, "could not find secret"} end end @@ -86,4 +89,7 @@ defmodule Core.Services.Cloud.Poller do defp to_cloud("GKE"), do: :gcp defp to_cloud("AKS"), do: :azure defp to_cloud(_), do: :aws + + defp log_err({:error, _} = err, msg), do: "#{msg} #{inspect(err)}" + defp log_err(pass, _), do: pass end