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 adds Confidence Score: 5/5Safe to merge — all prior P0/P1 concerns are resolved; remaining findings are P2 design suggestions for future PRs. All blocking issues from the previous review round are addressed. The remaining inline comments are P2: missing repository integration tests (no runtime breakage) and proto design considerations around retry_limit = 0 ambiguity and on_conditions typing (both can be addressed before the scheduler wiring lands in PRs 3/4). No P0 or P1 issues remain. pkg/api/submit.proto (retry_limit uint32 ambiguity, on_conditions string typing) and internal/server/retrypolicy/repository.go (no integration tests). Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as armadactl
participant REST as REST Client
participant Submit as Submit gRPC Service
participant RPSS as RetryPolicyService gRPC
participant Repo as PostgresRetryPolicyRepository
participant DB as PostgreSQL (retry_policy table)
Note over CLI,REST: Write operations require auth (create/update/delete)
Note over REST,Submit: HTTP REST via Submit gateway (/v1/retry-policy/...)
CLI->>RPSS: CreateRetryPolicy(RetryPolicy)
REST->>Submit: POST /v1/retry-policy
Submit->>RPSS: CreateRetryPolicy(ctx, policy)
RPSS->>RPSS: AuthorizeAction(CreateRetryPolicy)
RPSS->>Repo: CreateRetryPolicy(ctx, policy)
Repo->>DB: INSERT INTO retry_policy ON CONFLICT DO NOTHING
DB-->>Repo: RowsAffected
Repo-->>RPSS: nil or ErrAlreadyExists
RPSS-->>Submit: Empty or status error
Submit-->>REST: 200 OK or error
CLI->>RPSS: GetRetryPolicy(name)
REST->>Submit: GET /v1/retry-policy/{name}
Submit->>RPSS: GetRetryPolicy(ctx, req)
Note over RPSS: No auth check (intentional, mirrors GetQueue)
RPSS->>Repo: GetRetryPolicy(ctx, name)
Repo->>DB: SELECT definition FROM retry_policy WHERE name=$1
DB-->>Repo: definition bytes or ErrNoRows
Repo-->>RPSS: RetryPolicy or ErrNotFound
RPSS-->>Submit: RetryPolicy or NotFound status
Submit-->>REST: 200 + JSON or 404
Reviews (11): 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
513e46f to
07bffb3
Compare
07bffb3 to
aed9ba2
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>
aed9ba2 to
180cd5b
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