Repository navigation
Add bundle auto-deploy attempts - #7943
atreyadbrx wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Automated review at 8008385. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.
This PR adds bundle auto-deploy attempts, which lists a target's auto-deploy attempts or shows one of them. It also adds the attempts list and get endpoints to the fake server, which queues an attempt when it creates a trigger. The main paths work. The issues I'd fix are an attempt ID that goes into the request path without any check, and a failed-attempt test that uses a [[Server]] stub for a route the fake now handles. There is also an open question about what happens to attempt history once a trigger is deleted.
Questions
attemptsalways resolves the target's current trigger throughfindTriggerfirst.DeleteWebhookTriggersays a trigger's attempts survive its deletion, yet afterauto-deploy deletethe command fails with "has no auto-deploy trigger", and after delete pluscreateit only shows the new trigger's attempts. The fake also disagrees with itself here: get still works for a deleted trigger, but list returns 404. Should the command accept a trigger ID or a full attempt name so older history stays reachable, or should the help text say that history is no longer visible afterdelete? (non-blocking)
| if len(args) == 0 { | ||
| return cmdio.RenderIterator(ctx, api.ListAutoDeployAttempts(ctx, gitwebhooks.ListAutoDeployAttemptsRequest{Parent: found.Name})) | ||
| } | ||
| attempt, err := api.GetAutoDeployAttempt(ctx, gitwebhooks.GetAutoDeployAttemptRequest{Name: found.Name + "/attempts/" + args[0]}) |
There was a problem hiding this comment.
[nice to have] args[0] is appended to the name as is, and EncodeMultiSegmentPathParameter in GetAutoDeployAttempt keeps / as a path separator. So attempts "" sends GET .../webhook-triggers/T/attempts/, which is the list route with a trailing slash. And pasting the name that -o json prints (webhook-triggers/T/attempts/A) requests .../attempts/webhook-triggers/T/attempts/A, so the user gets a 404 for a path they never typed. Could we reject an empty ID or one containing / before building the name? Or accept the full name as well?
| @@ -0,0 +1,20 @@ | |||
| # The fake has no runner to fail an attempt, so this one is stubbed. | |||
| [[Server]] | |||
| Pattern = "GET /api/2.0/git-webhooks/webhook-triggers/{trigger_id}/attempts/11111111-1111-4111-8111-111111111111" | |||
There was a problem hiding this comment.
[nice to have] .agents/rules/testing.md says to reserve [[Server]] for routes the testserver doesn't model and for responses a stateful handler can't express. This PR adds a handler for this exact route, and a failed attempt is a state GitWebhookAttempts could hold. Because the pattern matches any {trigger_id} and the body names trigger aaaaaaaa-…, the "A failed attempt" case passes no matter which trigger the CLI looked up or put in the path. Could the test put a failed attempt into the fake for the real trigger instead?
| trace musterr $CLI bundle auto-deploy attempts | ||
|
|
||
| $CLI bundle auto-deploy create >> LOG.setup 2>&1 | ||
| attempt_id=$($CLI bundle auto-deploy attempts -o json | jq -r '.[0].attempt_id') |
There was a problem hiding this comment.
[nit] .agents/rules/testing.md asks for the acceptance/bin/ helpers instead of inline jq pipelines, and prefers gron.py | grep field for single values. This line pulls .[0].attempt_id with jq -r. Can it use the helpers instead?
Regression test report ✅Commit: Selected 5 changed tests (limit=20, 0 not selected) 5 tests: regression=5 unreleased=0 coverage=0 failing=0
TestAccept/bundle/auto-deploy/attempts: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): same output as main (4c4f104) TestAccept/bundle/auto-deploy/create: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): same output as main (4c4f104) TestAccept/bundle/auto-deploy/delete: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): same output as main (4c4f104) TestAccept/bundle/auto-deploy/get: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): same output as main (4c4f104) TestAccept/bundle/auto-deploy/list: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): same output as main (4c4f104) |
✅ Integration test reportCommit: a3949bf
Top 3 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at 8008385. Each finding was verified against the code.
No blocking issues found. 5 non-blocking comment(s) below.
This adds bundle auto-deploy attempts, which lists a target's attempts or shows one. It comes with the API methods, the models and fake-server support that queues an attempt when a trigger is created. The happy path works. The main gap is that attempts can't reach any attempt after delete, even though the delete help says past attempts are kept, and the fake's list and get routes behave differently for a deleted trigger. The remaining comments are about the test: the stubbed failure case, an inline jq, and no coverage of attempt paging.
| return err | ||
| } | ||
| ctx := cmd.Context() | ||
| found, err := findTrigger(ctx, api, t) |
There was a problem hiding this comment.
[nice to have] attempts finds the trigger through findTrigger before it lists or gets anything. After bundle auto-deploy delete, that lookup fails with "target dev has no auto-deploy trigger that you can view. To create one, run: … create". But delete's help (delete.go:19) says "The target's past attempts stay", and DeleteWebhookTrigger's doc says the same. Running create again makes a new trigger ID, so the old attempts stay out of reach. After a failed deploy and a delete, the user can't see why the deploy failed. Can attempts be looked up without a live trigger? If not, the delete help should say they can no longer be viewed from the CLI.
| func (s *FakeWorkspace) GitWebhooksListAttempts(req Request, triggerID string) Response { | ||
| defer s.LockUnlock()() | ||
|
|
||
| if _, ok := s.GitWebhookTriggers[triggerID]; !ok { |
There was a problem hiding this comment.
[nice to have] For a deleted trigger, GitWebhooksListAttempts returns 404 "Webhook trigger … does not exist". GitWebhooksGetAttempt (line 180) still serves that trigger's attempts from GitWebhookAttempts, which the comment says stay after delete. Which of these matches the service? The two routes should behave the same way, so tests against the fake don't encode an API contract that may not exist.
| @@ -0,0 +1,20 @@ | |||
| # The fake has no runner to fail an attempt, so this one is stubbed. | |||
| [[Server]] | |||
| Pattern = "GET /api/2.0/git-webhooks/webhook-triggers/{trigger_id}/attempts/11111111-1111-4111-8111-111111111111" | |||
There was a problem hiding this comment.
[nice to have] The stub matches any {trigger_id} and returns trigger_id/name for aaaaaaaa-…, not the trigger this test created ([UUID][1]). The fake would never return that body for this request. testing.md asks to model API behavior in libs/testserver/ instead of [[Server]] stubs, and this route is now modelled there. Could the test seed a failed attempt into the fake (for example a helper that sets an attempt's status), so this case goes through the real handler?
| // attempt stays queued. | ||
| if isNew { | ||
| attemptID := nextUUID() | ||
| s.GitWebhookAttempts[triggerID] = []gitwebhooks.AutoDeployAttempt{{ |
There was a problem hiding this comment.
[nice to have] Each trigger only ever gets the one attempt queued on create, and a re-upsert queues nothing. So ListAutoDeployAttempts never follows a next_page_token, even with page size 1. The "newest first" order in the help is never checked either. Can the fake queue a second attempt (for example on a push), so the golden shows two rows across two pages, in order?
| title "A target without a trigger" | ||
| trace musterr $CLI bundle auto-deploy attempts | ||
|
|
||
| $CLI bundle auto-deploy create >> LOG.setup 2>&1 |
There was a problem hiding this comment.
[nit] testing.md asks for the acceptance/bin/ helpers instead of inline jq, and recommends gron.py | grep field for single values. Can attempt_id be read with gron.py here instead of jq -r '.[0].attempt_id'?
3c86b40 to
4210154
Compare
8008385 to
a056e02
Compare
4210154 to
6cd3842
Compare
a056e02 to
c70586e
Compare
6cd3842 to
ac844d0
Compare
c70586e to
367e7fb
Compare
`attempts` lists the auto-deploy attempts of the bundle target, newest first, or shows one attempt when given its ID. It finds the target's trigger, then calls ListAutoDeployAttempts or GetAutoDeployAttempt. The fake queues an attempt when a trigger is created, as the service deploys the branch's head right away. It has no runner, so the test stubs a failed attempt to cover how one renders. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: atreyadbrx <atreya.misra@databricks.com>
ac844d0 to
c3e275a
Compare
367e7fb to
a3949bf
Compare
Changes
attemptslists the target's auto-deploy attempts, newest first, throughListAutoDeployAttempts. With an attempt ID, it shows that attempt throughGetAutoDeployAttempt. It rejects an ID that is empty or contains/, since the ID becomes a segment of the attempt's name.Why
Users need to see whether their pushes deployed, and why a deploy failed.
Tests
acceptance/bundle/auto-deploy/attemptscovers:Stacked on #7942.
This pull request and its description were written by Isaac.