feat: add global omit_snapshot_on_delete setting, fixes #8263#8264
feat: add global omit_snapshot_on_delete setting, fixes #8263#8264marklabrecque-ab wants to merge 3 commits intoddev:mainfrom
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
rfay
left a comment
There was a problem hiding this comment.
This probably needs a little test of the functionality, right, or an extra stanza in an existing test?
I always use ddev delete -Oy which doesn't hurt my fingers too much.
|
I've expanded the tests now and hopefully they cover all of the normal testing surfaces for this stuff. I tried to follow the patterns that I could find for tests like these. They all passed locally on my arm64 machine. I also noticed that there was a package that was sharing a variable scope with another package, which probably is not a great practice, so I've isolated them as well. That should prevent tests from breaking if the tests are re-ordered or run in parallel. In response to your suggestion, I actually missed that -O was possible in the documentation. Now that you mention it, I vaguely remember you suggesting this to me before and I completely forgot this option existed. I need to read --help closer next time. Happy to hear any additional feedback on my tests or approaches here, too. All this to say that if you favor the existing -O approach over my solution, I completely understand. I learned alot in producing this PR, so even if it doesn't get merged, I call it a win. Thanks! |
|
I took at look at the failing tests, but they didn't look related to what I was doing in this changeset. That being said, tests appear to be passing on stable. Perhaps I targetted the wrong branch with my PR? If you have any advice for how I would debug these tests on my end, much appreciated! |
|
You have privileges to restart buildkite tests (from sometime in the past) and it's OK to do so, but the panic isn't something I remember seeing, https://buildkite.com/ddev/ddev-macos-arm64-mutagen/builds/13094#019d3ac5-c52b-48d9-80ed-fcc9e60853d4/L19457 And since it also happens in https://buildkite.com/ddev/macos-lima/builds/5985#019d3ac5-c650-45a4-807e-ccd9e374f3da/L19249 and https://buildkite.com/ddev/macos-orbstack/builds/6811#019d3af6-d943-4144-923a-9c9eacfe34d8/L19488 Oh, and linux too, https://github.com/ddev/ddev/actions/runs/23715551972/job/69081941787?pr=8264#step:13:20205 it's a result of this PR |
|
Claude's suggestion: TestGetActiveAppRoot panic - root causeThe panic in What happens:
Fix run |
|
ah okay, I think I understand. Looks like my tests were creating stray DDEV config files because it found itself in a package directory of DDEV instead of the test site directory, so I guess I made some bad assumptions here. It looks like if I explicitly reset the directory at the beginning of each test, it might work better? Let's see how it goes |
|
Tricky and weird stuff sometimes. Since we do so many end-to-end tests they can affect each other. It's not pretty sometimes. |
|
This fail might be a bit more incidental. Looks like it ran for 25 minutes, then stopped after the TestDdevExec setup finished, and idled for about 3h40m until the 4 hour timeout killed it entirely. Maybe you have run into this before? |
|
From Claude:
Nothing in the log suggests your PR's code changes caused this. Editorial note: All this with a grain of salt, because Claude was just going off of failed build's logfile. It does not have access to the build process itself. |
|
The timeout/hang problem in https://buildkite.com/ddev/macos-colima-vz/builds/6156#019d3bd9-d3dd-4f2d-917a-0f21d254e742 is what Stas is working on in #8265 I'll restart this now, you have privs to restart buildkite stuff any time. (You have to be logged into buildkite) |
3ff181b to
1a4dab6
Compare
|
I rebased my branch onto main to bring it up to date. It looks like the last tests had passed, so I expect we are in the clear on this one. Appreciate the guidance on this one, @rfay - Thanks! |
|
Please always use rebase, not merge of upstream, to update a PR. Merge makes it really hard to maintain. |
|
ok, that's good advice, thanks. I had performed a rebase of my branch, but it still said the branch needed updating, so I tried using the button in the Github UI to facilitate - turns out that was not a good idea. I will back out of that change and try rebasing again. It's possible there were some changes I didn't have in my original rebase attempt. |
|
I'm sure you know the github web UI also has a "rebase" option, it's just hidden. Stas did an attempt to make rebase the default today but couldn't get it working. |
182463d to
00d8bc3
Compare
|
oh, thanks I didn't actually know that. For most of my work, I have always used Gitlab and am still not used to the Github UI. Good tip. I've rebased again to see if that fixes it. Hard to keep up with HEAD with such an active project! :) |
|
It's not actually necessary to worry about the update all the time. Unfortunately, when we enable want the update/rebase option, it's done by enabling "always suggest update" and then it feels like it's putting pressure on you :) In a PR like this one, nothing is likely to conflict before it gets in, so there's no essential need to update it all the time. What happens with doing a merge commit instead of a rebase: When some actual nontrivial divergence does happen, it's then no longer possible to fix with a rebase, because the merge commit was introduced. |
|
Yeah, understood. I'm pretty picky about history on my projects for this very reason. I've been burned by it more than once. |
…pshot vars - Add TestOmitSnapshotOnDeleteGlobal with table-driven tests covering all four combinations of global config and --omit-snapshot flag - Scope package-level omitSnapshot var into deleteOmitSnapshot (delete.go) and stopOmitSnapshot (stop.go) to prevent shared mutable state between commands
…Global cleanup The cleanup function was running `ddev config --auto` from the package directory (origDir), creating a stray .ddev/config.yaml that caused TestGetActiveAppRoot to panic with a nil error dereference. Run from site.Dir instead and use defer for os.Chdir(origDir) to ensure CWD restoration even if require.NoError triggers runtime.Goexit().
00d8bc3 to
5c5f76c
Compare
stasadev
left a comment
There was a problem hiding this comment.
Please update the docs https://docs.ddev.com/en/stable/users/configuration/config/ in
https://github.com/ddev/ddev/blob/main/docs/content/users/configuration/config.md?plain=1
Everything else looks good.
The Issue
Users who frequently delete projects without needing a snapshot must pass
--omit-snapshotevery time. There is no way to set this as a default.How This PR Solves The Issue
Adds a new global configuration option
omit_snapshot_on_delete(defaultfalse) that, when enabled, makesddev deleteskip the database snapshot by default. The explicit--omit-snapshot/--omit-snapshot=falseflag on the command still takes precedence, so per-command overrides work in both directions.Changes across five files:
pkg/globalconfig/global_config.go— newOmitSnapshotOnDeletebool field and documentation comment in WriteGlobalConfigcmd/ddev/cmd/config-global.go— flag handler and registration for--omit-snapshot-on-deletecmd/ddev/cmd/delete.go— applies global default when--omit-snapshotis not explicitly passedpkg/globalconfig/schema.json— schema entry for the new optioncmd/ddev/cmd/config-global_test.go— test coverageManual Testing Instructions
ddev config global --omit-snapshot-on-delete=trueddev delete <project>— should skip the snapshot without needing-Oddev delete --omit-snapshot=false <project>— should still create a snapshotddev config global --omit-snapshot-on-delete=falseto restore defaultAutomated Testing Overview
Extended
TestCmdGlobalConfigto verify the new flag appears in output with its default value, can be set totrue, and persists in the global config struct afterEnsureGlobalConfig().Release/Deployment Notes
Opt-in only. Existing behavior is unchanged unless a user explicitly enables the new setting. No migration or deployment steps required.