breaking(cli): remove deprecated 'snapshot gc' command (#2862)

* remove deprecated `snapshot gc` command
* run `maintenance` instead of `snapshot gc` in robustness
* use `maintenance` command instead of `gc` alias for clarity
* use `maintenance run` in `TestSnapshotDeleteRestore`
This commit is contained in:
Julio Lopez
2023-04-10 23:17:32 -04:00
committed by GitHub
parent cfe352f9d5
commit 8f2499b94b
5 changed files with 3 additions and 21 deletions

View File

@@ -8,7 +8,6 @@ type commandSnapshot struct {
estimate commandSnapshotEstimate
expire commandSnapshotExpire
fix commandSnapshotFix
gc commandSnapshotGC
list commandSnapshotList
migrate commandSnapshotMigrate
pin commandSnapshotPin
@@ -25,7 +24,6 @@ func (c *commandSnapshot) setup(svc advancedAppServices, parent commandParent) {
c.estimate.setup(svc, cmd)
c.expire.setup(svc, cmd)
c.fix.setup(svc, cmd)
c.gc.setup(svc, cmd)
c.list.setup(svc, cmd)
c.migrate.setup(svc, cmd)
c.pin.setup(svc, cmd)

View File

@@ -1,16 +0,0 @@
package cli
import (
"github.com/kopia/kopia/repo/maintenance"
)
type commandSnapshotGC struct {
snapshotGCDelete bool
snapshotGCSafety maintenance.SafetyParameters
}
func (c *commandSnapshotGC) setup(_ appServices, parent commandParent) {
cmd := parent.Command("gc", "DEPRECATED: This command does not do anything and will be removed. Snapshot GC is now automatically done as part of repository maintenance.").Hidden()
cmd.Flag("delete", "Delete unreferenced contents").BoolVar(&c.snapshotGCDelete)
safetyFlagVar(cmd, &c.snapshotGCSafety)
}

View File

@@ -230,7 +230,7 @@ func TestSnapshotDeleteRestore(t *testing.T) {
e.RunAndExpectFailure(t, "snapshot", "delete", snapID, "--delete")
// garbage-collect to clean up the root object.
e.RunAndExpectSuccess(t, "snapshot", "gc", "--delete", "--safety=none")
e.RunAndExpectSuccess(t, "maintenance", "run", "--full")
// Run a restore on the deleted snapshot's root ID. The root should be
// marked as deleted but still recoverable

View File

@@ -274,7 +274,7 @@ func enduranceRunner(t *testing.T, runnerID int, fakeTimeServer, webdavServer st
e.RunAndExpectSuccess(t, "repo", "connect", "webdav", "--url", webdavServer, "--override-username="+fmt.Sprintf("runner-%v", runnerID))
if runnerID == 0 {
e.RunAndExpectSuccess(t, "gc", "set", "--enable-full=true", "--full-interval=4h", "--owner=me")
e.RunAndExpectSuccess(t, "maintenance", "set", "--enable-full=true", "--full-interval=4h", "--owner=me")
}
var s runnerState

View File

@@ -160,7 +160,7 @@ func (ks *KopiaSnapshotter) DeleteSnapshot(snapID string) (err error) {
// RunGC implements the Snapshotter interface, issues a gc command to the kopia repo.
func (ks *KopiaSnapshotter) RunGC() (err error) {
_, _, err = ks.Runner.Run("snapshot", "gc")
_, _, err = ks.Runner.Run("maintenance", "run", "--full")
return err
}