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

Improve hydra error messages #1378

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/core/lib/core/clients/hydra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ defmodule Core.Clients.Hydra do
do: {:ok, Poison.decode!(body, as: type)}
defp handle_response(error, _) do
Logger.error "Failed to call hydra: #{inspect(error)}"
{:error, :unauthorized}
{:error, hydra_error(error)}
end

defp user_details(user) do
Expand All @@ -156,5 +156,9 @@ defmodule Core.Clients.Hydra do

defp conf(key), do: Application.get_env(:core, __MODULE__)[key]

defp hydra_error({:error, _}), do: "internal network error"
defp hydra_error({:ok, %HTTPoison.Response{status_code: code, body: body}}),
do: "hydra error: code=#{code}, body=#{body}"

defp headers(), do: [{"accept", "application/json"}, {"content-type", "application/json"}]
end
3 changes: 2 additions & 1 deletion apps/core/test/services/cloud/workflow_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Core.Services.Cloud.WorkflowTest do
use Core.SchemaCase, async: true
use Core.SchemaCase, async: false
use Mimic
alias Core.Clients.Console
alias Core.Services.{Cloud, Cloud.Workflow}
Expand Down Expand Up @@ -28,6 +28,7 @@ defmodule Core.Services.Cloud.WorkflowTest do
expect(Req, :post, fn _, [graphql: {_, %{clusterId: ^cluster_id}}] ->
{:ok, %Req.Response{status: 200, body: %{"data" => %{"createServiceDeployment" => %{"id" => Ecto.UUID.generate()}}}}}
end)
expect(DNS, :resolve, fn _ -> {:ok, ['some-ip']} end)

{:ok, %{external_id: svc_id} = instance} = Workflow.provision(instance)

Expand Down
1 change: 1 addition & 0 deletions apps/core/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Mimic.copy(Core.Buffers.TokenAudit)
Mimic.copy(Core.Clients.Hydra)
Mimic.copy(Cloudflare.DnsRecord)
Mimic.copy(Kazan)
Mimic.copy(DNS)
Mimic.copy(Goth.Token)
Mimic.copy(GoogleApi.CloudBilling.V1.Api.Projects)
Mimic.copy(GoogleApi.CloudResourceManager.V3.Api.Projects)
Expand Down
Loading