Add RetryPolicy CRUD API and armadactl support#4805
Add RetryPolicy CRUD API and armadactl support#4805dejanzele wants to merge 1 commit intoarmadaproject:masterfrom
Conversation
Greptile SummaryThis PR introduces Key highlights:
Confidence Score: 4/5Safe to merge after confirming the migration numbering gap will not conflict with any other in-flight PR The implementation is well-structured and cleanly mirrors the queue CRUD pattern. All concerns from the prior review iteration have been addressed. One P1 remains: the migration numbering gap (030→032) could cause migration 031 to be permanently skipped if another concurrent PR claims that number and is merged after this one. Once that ordering is confirmed or the numbering is coordinated, the remaining findings are P2 style/quality suggestions that do not block merge. internal/lookout/schema/migrations/032_create_retry_policy.sql — migration numbering gap needs confirmation before merging Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as armadactl
participant Submit as Submit Server (REST gateway)
participant RPS as RetryPolicyService Server
participant Repo as PostgresRetryPolicyRepository
participant DB as PostgreSQL (retry_policy table)
Note over CLI,DB: Create / Update / Delete (auth required)
CLI->>Submit: POST /v1/retry-policy (CreateRetryPolicy)
Submit->>RPS: delegate CreateRetryPolicy(policy)
RPS->>RPS: AuthorizeAction(CreateRetryPolicy)
RPS->>RPS: validate name != ""
RPS->>Repo: CreateRetryPolicy(ctx, policy)
Repo->>DB: INSERT INTO retry_policy ON CONFLICT DO NOTHING
DB-->>Repo: RowsAffected
Repo-->>RPS: nil or ErrAlreadyExists
RPS-->>Submit: Empty or gRPC status error
Submit-->>CLI: HTTP 200 or 4xx/5xx
Note over CLI,DB: Read (unauthenticated, consistent with GetQueue)
CLI->>Submit: GET /v1/retry-policy/{name}
Submit->>RPS: delegate GetRetryPolicy(req)
RPS->>RPS: validate name != ""
RPS->>Repo: GetRetryPolicy(ctx, name)
Repo->>DB: SELECT definition FROM retry_policy WHERE name=$1
DB-->>Repo: definition bytes or ErrNoRows
Repo-->>RPS: *RetryPolicy or ErrNotFound
RPS-->>Submit: RetryPolicy or NotFound status
Submit-->>CLI: HTTP 200 + JSON or 404
Reviews (9): Last reviewed commit: "Add RetryPolicy CRUD API and armadactl s..." | Re-trigger Greptile |
1d4f603 to
45023c8
Compare
45023c8 to
2119aab
Compare
a797d8b to
63f1c89
Compare
63f1c89 to
513e46f
Compare
Introduce RetryPolicy as a first-class API resource with full CRUD operations. This is pure infrastructure with no scheduling behavior changes. Proto: Add RetryPolicy, RetryRule, RetryExitCodeMatcher messages and RetryPolicyService gRPC service with REST gateway bindings on the Submit service. Add retry_policy field to Queue message. Server: Add retrypolicy package with PostgresRetryPolicyRepository (stores serialized proto in retry_policy table) and Server handler with authorization checks. Wire into server startup and register the gRPC service. Add CreateRetryPolicy/DeleteRetryPolicy permissions. Client: Add pkg/client/retrypolicy with Create/Update/Delete/Get/GetAll functions matching the queue client pattern. CLI: Add armadactl commands for create/update/delete/get retry-policy and get retry-policies, all using file-based input for create/update. Add --retry-policy flag to queue create and update commands. Add RetryPolicy as a valid ResourceKind for file-based creation. Signed-off-by: Dejan Zele Pejchev <pejchev@gmail.com> Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
513e46f to
07bffb3
Compare
What type of PR is this?
Feature (retry policy PR 2 of 4)
What this PR does / why we need it
Adds RetryPolicy as a first-class API resource with full CRUD operations, following the same patterns as Queue. Operators can create retry policies and assign them to queues by name.
RetryPolicy,RetryRule,RetryExitCodeMatcherproto messages andRetryActionenum tosubmit.protoRetryPolicyServicegRPC service with Create/Update/Delete/Get/List RPCs/v1/retry-policy/...)retry_policyfield (string, references policy by name) to the Queue proto messageinternal/server/retrypolicy/- repository (PostgreSQL) and gRPC handler, mirroringinternal/server/queue/pkg/client/retrypolicy/- client library for all CRUD operationscmd/armadactl/cmd/retrypolicy.go- CLI commands for managing retry policies--retry-policyflag to queue create/update commandsRetryPolicyresource kind for file-based creation (armadactl create -f policy.yaml)Usage:
Which issue(s) this PR fixes
Part of #4683 (Retry Policy)
Special notes for your reviewer
retry_policytable (name text PK, definition bytea) stores serialized proto, same as thequeuetable