Skip to content

Commit 0129590

Browse files
Need to add secret read perms to plural sa (#1334)
1 parent fc91f9b commit 0129590

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

apps/core/lib/core/clients/console.ex

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ defmodule Core.Clients.Console do
4242
"""
4343

4444
def new(url, token) do
45-
Req.new(base_url: url, auth: "Token #{token}")
45+
Req.new(base_url: with_gql(url), auth: "Token #{token}")
4646
|> AbsintheClient.attach()
4747
end
4848

@@ -93,4 +93,11 @@ defmodule Core.Clients.Console do
9393
Logger.error "failed to fetch from console: #{inspect(resp)}"
9494
{:error, "console error"}
9595
end
96+
97+
defp with_gql(url) do
98+
case String.ends_with?(url, "/gql") do
99+
true -> url
100+
_ -> "#{url}/gql"
101+
end
102+
end
96103
end

apps/core/lib/core/services/cloud/poller.ex

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defmodule Core.Services.Cloud.Poller do
33
alias Core.Clients.Console
44
alias Core.Services.Cloud
55
alias Kazan.Apis.Core.V1, as: CoreV1
6+
require Logger
67

78
@poll :timer.minutes(5)
89

@@ -28,7 +29,9 @@ defmodule Core.Services.Cloud.Poller do
2829
def handle_info(:repo, %{client: client} = state) do
2930
case Console.repo(client, Core.conf(:mgmt_repo)) do
3031
{:ok, id} -> {:noreply, %{state | repo: id}}
31-
_ -> {:noreply, state}
32+
err ->
33+
Logger.warn "failed to find mgmt repo: #{inspect(err)}"
34+
{:noreply, state}
3235
end
3336
end
3437

@@ -41,8 +44,11 @@ defmodule Core.Services.Cloud.Poller do
4144
end
4245

4346
def handle_info(:roaches, state) do
44-
with {:ok, roaches} <- read_secret() do
45-
Enum.each(roaches, &upsert_roach/1)
47+
case read_secret() do
48+
{:ok, roaches} ->
49+
Enum.each(roaches, &upsert_roach/1)
50+
err ->
51+
Logger.warn "failed to fetch available cockroach clusters: #{inspect(err)}"
4652
end
4753
{:noreply, state}
4854
end

plural/helm/plural/templates/rbac.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ rules:
88
- apiGroups: [""]
99
resources: ["endpoints", "pods"]
1010
verbs: ["get", "list", "watch"]
11+
- apiGroups: [""]
12+
resources: ["secrets"]
13+
verbs: ["get", "list", "watch"]
1114
- apiGroups: ["batch", "extensions"]
1215
resources: ["jobs"]
1316
verbs: ["get", "list", "watch"]

0 commit comments

Comments
 (0)