chore: Remove ability to create GCP log sinks (#8298)

This has long since been removed in the Clients.
This commit is contained in:
Jamil
2025-02-28 20:57:21 +00:00
committed by GitHub
parent d71fdbf269
commit cb0bf44815
4 changed files with 0 additions and 171 deletions

View File

@@ -1,7 +1,6 @@
defmodule API.Client.Channel do
use API, :channel
alias API.Client.Views
alias Domain.Instrumentation
alias Domain.{Accounts, Clients, Actors, Resources, Gateways, Relays, Policies, Flows}
require Logger
require OpenTelemetry.Tracer
@@ -566,40 +565,6 @@ defmodule API.Client.Channel do
##### Client-initiated actions #####
####################################
# This message sent by the client to create a GSC signed url for uploading logs and debug artifacts
# TODO: This has been disabled on clients. Remove this when no more clients are requesting log sinks.
@impl true
def handle_in("create_log_sink", _attrs, socket) do
OpenTelemetry.Ctx.attach(socket.assigns.opentelemetry_ctx)
OpenTelemetry.Tracer.set_current_span(socket.assigns.opentelemetry_span_ctx)
account_slug = socket.assigns.subject.account.slug
actor_name =
socket.assigns.subject.actor.name
|> String.downcase()
|> String.replace(" ", "_")
|> String.replace(~r/[^a-zA-Z0-9_-]/iu, "")
OpenTelemetry.Tracer.with_span "client.create_log_sink" do
case Instrumentation.create_remote_log_sink(socket.assigns.client, actor_name, account_slug) do
{:ok, signed_url} ->
{:reply, {:ok, signed_url}, socket}
{:error, :disabled} ->
{:reply, {:error, %{reason: :disabled}}, socket}
{:error, reason} ->
Logger.error("Failed to create log sink for client",
client_id: socket.assigns.client.id,
reason: inspect(reason)
)
{:reply, {:error, %{reason: :retry_later}}, socket}
end
end
end
# This message is sent to the client to request a network flow with a gateway that can serve given resource.
#
# `connected_gateway_ids` is used to indicate that the client is already connected to some of the gateways,

View File

@@ -1,6 +1,5 @@
defmodule API.Client.ChannelTest do
use API.ChannelCase, async: true
alias Domain.Mocks.GoogleCloudPlatform
setup do
account =
@@ -1023,67 +1022,6 @@ defmodule API.Client.ChannelTest do
end
end
# TODO: This has been disabled on clients. Remove this when no more clients are requesting log sinks.
describe "handle_in/3 create_log_sink" do
test "returns error when feature is disabled", %{socket: socket} do
Domain.Config.put_env_override(Domain.Instrumentation, client_logs_enabled: false)
ref = push(socket, "create_log_sink", %{})
assert_reply ref, :error, %{reason: :disabled}
end
test "returns error when google api is not available", %{socket: socket} do
bypass = Bypass.open()
GoogleCloudPlatform.override_endpoint_url(
:metadata_endpoint_url,
"http://localhost:#{bypass.port}/"
)
GoogleCloudPlatform.override_endpoint_url(
:sign_endpoint_url,
"http://localhost:#{bypass.port}/service_accounts/"
)
Bypass.down(bypass)
ref = push(socket, "create_log_sink", %{})
assert_reply ref, :error, %{reason: :retry_later}
end
test "returns a signed URL which can be used to upload the logs", %{
account: account,
socket: socket,
client: client
} do
bypass = Bypass.open()
GoogleCloudPlatform.mock_instance_metadata_token_endpoint(bypass)
GoogleCloudPlatform.mock_sign_blob_endpoint(bypass, "foo")
actor = Repo.get(Domain.Actors.Actor, client.actor_id)
actor_name =
actor.name
|> String.downcase()
|> String.replace(" ", "_")
|> String.replace(~r/[^a-zA-Z0-9_-]/iu, "")
ref = push(socket, "create_log_sink", %{})
assert_reply ref, :ok, signed_url
assert signed_uri = URI.parse(signed_url)
assert signed_uri.scheme == "https"
assert signed_uri.host == "storage.googleapis.com"
assert String.starts_with?(
signed_uri.path,
"/logs/clients/#{account.slug}/#{actor_name}/#{client.id}/"
)
assert String.ends_with?(signed_uri.path, ".json")
end
end
describe "handle_in/3 create_flow" do
test "returns error when resource is not found", %{socket: socket} do
resource_id = Ecto.UUID.generate()