Repository navigation
Add bundle auto-deploy delete - #7942
atreyadbrx wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Automated review at 3c86b40. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) below.
This PR adds bundle auto-deploy delete. The command looks up the target's trigger, asks for confirmation unless --auto-approve is passed, and sends the DELETE with a JSON body through a request visitor so the body survives retries. The fake server and the acceptance test are extended to match. The command and the body-on-DELETE handling look correct. What's left is a gap in the retry test and two wording fixes.
Comments outside the changed lines
- [nit]
cmd/bundle/autodeploy/autodeploy.go: Theauto-deploycommand'sLongtext still starts with "Set up and inspect auto-deploy for a bundle target." Now thatdeleteis registered, could it read "Set up, inspect and stop auto-deploy for a bundle target."?
| title "A retried delete sends its body again" | ||
| fault.py --body-contains deployment_mode "DELETE /api/2.0/git-webhooks/trigger" 503 0 1 TEMPORARILY_UNAVAILABLE | ||
| trace $CLI bundle auto-deploy delete -t prod --auto-approve | ||
| print_requests.py //git-webhooks |
There was a problem hiding this comment.
[nice to have] After the retried delete -t prod, the test only prints the requests. It never shows that prod's trigger is gone. If the retry returned a 2xx without the fake deleting anything, this golden would still be produced. The last section runs against dev, which an earlier section already deleted. Can we add trace $CLI bundle auto-deploy list here, or point the "target without a trigger" section at -t prod, so the output shows the state after the retry?
| NextPageToken string `json:"next_page_token,omitempty"` | ||
| } | ||
|
|
||
| // DeleteWebhookTrigger matches the trigger to delete on its target. The service also requires |
There was a problem hiding this comment.
[nit] "Matches the trigger to delete on its target" doesn't say that the match also uses repo_url and bundle_yml_repo_path, which GitWebhooksDelete in the fake checks too. "The trigger config's repo event" is vague: the required field is push_event. How about: "The service deletes the trigger with the same repo_url, bundle_yml_repo_path and deployment_mode. It ignores push_event but rejects a request without it."
Regression test report ✅Commit: Selected 4 changed tests (limit=20, 0 not selected) 4 tests: regression=4 unreleased=0 coverage=0 failing=0
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): 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): |
✅ Integration test reportCommit: c3e275a
Top 5 slowest tests (at least 2 minutes):
|
bbaf04d to
eb8b631
Compare
3c86b40 to
4210154
Compare
eb8b631 to
852eda8
Compare
4210154 to
6cd3842
Compare
denik
left a comment
There was a problem hiding this comment.
🤖 Automated review of 6cd384264 by Opus, Fable and Astra; each finding verified against the code.
No blocking issues. One should-fix inline: the --auto-approve check and its agent notice. The DELETE-with-body visitor is correct for SDK v0.204.0: the SDK reruns visitors on each retry, and the head merged into current main builds and passes TestAccept/bundle/auto-deploy/*.
Review points
- The fake server is the only thing that asserts three service behaviors this command depends on: the service reads a DELETE's JSON body, requires
push_eventbut ignores it, and returns 200 when nothing matches. Because a no-match counts as success, a service that keys the delete differently (for example ongit_provideror a normalizedrepo_url) would print "Deleted the auto-deploy trigger" while pushes keep deploying. With no test workspace for this API yet, could the description say what was checked by hand on a real workspace: delete then list, deleting a missing trigger, a request withoutpush_event? - Remaining risk worth a line in the description: the delete is keyed by repo, bundle path and target, not by trigger ID, because the API has no delete by ID. An SDK retry of a delete that was applied but whose response was lost, or a first attempt that lands late, also deletes a trigger that another checkout re-created for the same target in that window. A one-attempt client wouldn't close this, so it looks acceptable, but it should be written down.
Not posted inline
- Nit
cmd/bundle/autodeploy/delete.go:44: answering "n" exits 0 with no output;bundle destroyandbundle deployprint "Destroy cancelled!" / "Deployment cancelled!" (bundle/phases/destroy.go:377,bundle/phases/deploy.go:266). - Nit
cmd/bundle/autodeploy/trigger.go:97(reached fromdelete.go:33): a seconddeleteends with "To create one, run: databricks bundle auto-deploy create", which is an odd thing to suggest after a delete (last case of the golden).deletecould say there is nothing to delete. - For the PR that turns
Cloudon:libs/testproxyforwards a DELETE's data only as query parameters (libs/testproxy/server.go:65-74), so with request recording this body won't reach the workspace. Nothing hits it while the tests areCloud = false.
| } | ||
|
|
||
| if !autoApprove { | ||
| if !cmdio.IsPromptSupported(ctx) { |
There was a problem hiding this comment.
🤖 Should fix: this check runs only after loadTrigger has processed the bundle and findTrigger has sent GET /git-webhooks/webhook-triggers, and neither result changes the outcome. A CI job that forgot --auto-approve initializes the bundle and makes the list call, retried by the SDK on 429/503, before it fails on something that depends only on the flag and the terminal. bundle destroy checks first (cmd/bundle/utils/destroy.go:20). Moving the check to the top of RunE, or at least above findTrigger, avoids the extra work.
The message also needs agent.AgentNotice(). Every other bundle error that suggests --auto-approve appends it (cmd/bundle/utils/destroy.go:24, bundle/phases/deploy.go:55, bundle/phases/bind.go:93). Without it, an AI agent that reads "To proceed, use --auto-approve" may retry with the flag and delete the trigger and its runner job without the user's approval.
There was a problem hiding this comment.
Fixed in ac844d0. The check runs first in RunE, before the bundle loads or any request is sent, and the message ends with agent.AgentNotice(). The delete test asserts that no request was recorded. The message no longer names the target, since the bundle isn't loaded at that point.
852eda8 to
ee80a9e
Compare
6cd3842 to
ac844d0
Compare
|
Thanks @denik. I pushed ac844d0 with your points addressed.
|
`delete` deletes the trigger of the bundle target and its runner job, after a confirmation prompt or with --auto-approve. The target's attempts stay. DeleteWebhookTrigger takes its fields in the body of a DELETE, but the SDK sends a DELETE's fields in the query string. The client sets the body with a request visitor, which the SDK runs on every attempt, so a retry sends the body again. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: atreyadbrx <atreya.misra@databricks.com>
ac844d0 to
c3e275a
Compare
ee80a9e to
b78dec4
Compare
Changes
deletedeletes the target's trigger and its runner job, after a prompt or with--auto-approve. Without a terminal it fails on a missing--auto-approvebefore it loads the bundle or calls the API, asbundle destroydoes. The service keeps the trigger's attempts but shows them only to workspace admins, so the help saysattemptscan no longer show them.DeleteWebhookTriggeris aDELETEwith a JSON body, but the SDK always sends aDELETE's fields as query parameters. The client sends the body with a request visitor, which the SDK runs on every attempt.Why
Users need a way to stop auto-deploying a target. The service matches the trigger to delete by its target, and it also requires the trigger's
push_event, so the CLI sends both from the trigger it looked up. The visitor also setsGetBody, so the transport can replay the request the way it does for SDK-built bodies.Tests
acceptance/bundle/auto-deploy/deletecovers:--auto-approve(error)--auto-approve, with the recorded request showing the bodylistno longer shows the triggerpush_event, and a 200 when nothing matches. The fake follows the service's implemented behavior. One known risk: the API deletes by target, not by trigger ID. So if a delete is retried after its response was lost, it can also delete a trigger that someone re-created for the same target in that window.Stacked on #7941.
This pull request and its description were written by Isaac.