Skip to content

Commit 63d1999

Browse files
committed
feat(zebra): implement data deletion workers
1 parent c2c922c commit 63d1999

22 files changed

+2667
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddExpiresAtToJobs < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :jobs, :expires_at, :datetime
4+
end
5+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddExpiresCreatedIndexAtJobsTable < ActiveRecord::Migration[6.1]
2+
disable_ddl_transaction!
3+
4+
def change
5+
add_index :jobs,
6+
%i[expires_at created_at],
7+
name: "index_jobs_on_expires_created_not_null",
8+
algorithm: :concurrently,
9+
where: "expires_at IS NOT NULL"
10+
end
11+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddOrganizationCreatedIndexAtJobsTable < ActiveRecord::Migration[6.1]
2+
disable_ddl_transaction!
3+
4+
def change
5+
add_index :jobs,
6+
%i[organization_id created_at],
7+
name: "index_jobs_on_organization_created_expires_is_null",
8+
algorithm: :concurrently,
9+
where: "expires_at IS NULL"
10+
end
11+
end

zebra/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ZEBRA_CALLBACK_TOKEN_KEYS?="testing"
3636
CONTAINER_ENV_VARS= \
3737
-e CI=$(CI) \
3838
-e MIX_ENV=$(MIX_ENV) \
39+
-e START_JOB_DELETION_POLICY_MARKER=$(START_JOB_DELETION_POLICY_MARKER) \
40+
-e START_JOB_DELETION_POLICY_WORKER=$(START_JOB_DELETION_POLICY_WORKER) \
3941
-e START_PUBLIC_JOB_API=$(START_PUBLIC_JOB_API) \
4042
-e START_INTERNAL_JOB_API=$(START_INTERNAL_JOB_API) \
4143
-e START_INTERNAL_TASK_API=$(START_INTERNAL_TASK_API) \

zebra/config/config.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ config :zebra, Zebra.Workers.TaskFinisher, timeout: 10_000
2424
config :zebra, Zebra.Workers.Dispatcher, timeout: 1_000
2525
config :zebra, Zebra.Workers.Monitor, timeout: 60_000
2626

27+
config :zebra, Zebra.Workers.JobDeletionPolicyWorker,
28+
naptime: 1_000, # 1 second
29+
longnaptime: 3_600_000, # 1 hour
30+
limit: 100
31+
32+
config :zebra, Zebra.Workers.JobDeletionPolicyMarker,
33+
days: 14
34+
2735
config :zebra, Zebra.Workers.Scheduler,
2836
cooldown_period: 1_000,
2937
batch_size: 3

zebra/junit.json

37.4 KB
Binary file not shown.

zebra/junit.xml

Lines changed: 1368 additions & 0 deletions
Large diffs are not rendered by default.

zebra/lib/protos/internal_api/artifacthub.pb.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,14 @@ defmodule InternalApi.Artifacthub.ListItem do
388388

389389
@type t :: %__MODULE__{
390390
name: String.t(),
391-
is_directory: boolean
391+
is_directory: boolean,
392+
size: integer
392393
}
393-
defstruct [:name, :is_directory]
394+
defstruct [:name, :is_directory, :size]
394395

395396
field(:name, 1, type: :string)
396397
field(:is_directory, 2, type: :bool)
398+
field(:size, 3, type: :int64)
397399
end
398400

399401
defmodule InternalApi.Artifacthub.Artifact do

zebra/lib/protos/internal_api/rbac.pb.ex

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,39 @@ defmodule InternalApi.RBAC.Permission do
508508
field(:scope, 4, type: InternalApi.RBAC.Scope, enum: true)
509509
end
510510

511+
defmodule InternalApi.RBAC.ListSubjectsRequest do
512+
@moduledoc false
513+
use Protobuf, syntax: :proto3
514+
515+
@type t :: %__MODULE__{
516+
org_id: String.t(),
517+
subject_ids: [String.t()]
518+
}
519+
defstruct [:org_id, :subject_ids]
520+
521+
field(:org_id, 1, type: :string)
522+
field(:subject_ids, 2, repeated: true, type: :string)
523+
end
524+
525+
defmodule InternalApi.RBAC.ListSubjectsResponse do
526+
@moduledoc false
527+
use Protobuf, syntax: :proto3
528+
529+
@type t :: %__MODULE__{
530+
subjects: [InternalApi.RBAC.Subject.t()]
531+
}
532+
defstruct [:subjects]
533+
534+
field(:subjects, 1, repeated: true, type: InternalApi.RBAC.Subject)
535+
end
536+
511537
defmodule InternalApi.RBAC.SubjectType do
512538
@moduledoc false
513539
use Protobuf, enum: true, syntax: :proto3
514540

515541
field(:USER, 0)
516542
field(:GROUP, 1)
543+
field(:SERVICE_ACCOUNT, 2)
517544
end
518545

519546
defmodule InternalApi.RBAC.Scope do
@@ -588,6 +615,8 @@ defmodule InternalApi.RBAC.RBAC.Service do
588615
InternalApi.RBAC.RefreshCollaboratorsRequest,
589616
InternalApi.RBAC.RefreshCollaboratorsResponse
590617
)
618+
619+
rpc(:ListSubjects, InternalApi.RBAC.ListSubjectsRequest, InternalApi.RBAC.ListSubjectsResponse)
591620
end
592621

593622
defmodule InternalApi.RBAC.RBAC.Stub do

0 commit comments

Comments
 (0)