Skip to content

Commit 3283e27

Browse files
fix(zebra): add ff for cachehub protection (#486)
## 📝 Description renderedtext/project-tasks#2647 ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent 4fa2a94 commit 3283e27

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

zebra/lib/zebra/workers/job_request_factory.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ defmodule Zebra.Workers.JobRequestFactory do
7272
Task.async(fn ->
7373
if Job.self_hosted?(job.machine_type),
7474
do: {:ok, nil},
75-
else: Cache.find(project.cache_id, repo_proxy)
75+
else: Cache.find(project.cache_id, repo_proxy, org_id)
7676
end),
7777
find_secrets <-
7878
Task.async(fn -> Secrets.load(org_id, job.id, spec, project, repo_proxy) end),

zebra/lib/zebra/workers/job_request_factory/cache.ex

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ defmodule Zebra.Workers.JobRequestFactory.Cache do
1313
# Overall, if cache system is down, we ignore every issue.
1414
#
1515

16-
def find(nil, _repo_proxy) do
16+
def find(nil, _repo_proxy, _org_id) do
1717
# We don't fail any jobs due to a missing cache connection,
1818
# but we should make sure we are aware of any issues in this area.
1919
Watchman.increment("external.cachehub.describe.failed")
2020

2121
{:ok, nil}
2222
end
2323

24-
def find(cache_id, repo_proxy) do
24+
def find(cache_id, repo_proxy, org_id) do
2525
Watchman.benchmark("external.cachehub.describe", fn ->
2626
req = Request.new(cache_id: cache_id)
2727

28-
with false <- forked_pr?(repo_proxy),
28+
with false <-
29+
forked_pr?(repo_proxy) and
30+
FeatureProvider.feature_enabled?(:disable_forked_pr_cache, param: org_id),
2931
{:ok, endpoint} <- Application.fetch_env(:zebra, :cachehub_api_endpoint),
3032
{:ok, channel} <- GRPC.Stub.connect(endpoint),
3133
{:ok, response} <- Stub.describe(channel, req, timeout: 30_000) do
@@ -40,7 +42,10 @@ defmodule Zebra.Workers.JobRequestFactory.Cache do
4042
end
4143
else
4244
true ->
43-
Logger.info("Skipping fetching of the cache as the job is part of Forked PR build.")
45+
Logger.info(
46+
"Skipping fetching of the cache as the job is part of Forked PR build. Cache id #{inspect(cache_id)}"
47+
)
48+
4449
{:ok, nil}
4550

4651
e ->

0 commit comments

Comments
 (0)