fix(cli): allow running quick maintenance with epoch manager (#4198)

* allow running quick maintenance with epoch manager
* run full maintenance to cleanup logs
* separate logs maintenance set params test
This commit is contained in:
Julio López
2024-10-28 16:04:29 -07:00
committed by GitHub
parent a3c570d264
commit 0e91261c3e
2 changed files with 13 additions and 10 deletions

View File

@@ -90,14 +90,24 @@ func TestLogsMaintenance(t *testing.T) {
e.RunAndExpectSuccess(t, "maintenance", "set", "--max-retained-log-count=2")
e.RunAndVerifyOutputLineCount(t, 5, "logs", "list")
e.RunAndExpectSuccess(t, "maintenance", "run")
e.RunAndExpectSuccess(t, "maintenance", "run", "--full")
e.RunAndVerifyOutputLineCount(t, 3, "logs", "list")
e.RunAndExpectSuccess(t, "maintenance", "set", "--max-retained-log-age=1ms")
e.RunAndVerifyOutputLineCount(t, 4, "logs", "list")
e.RunAndExpectSuccess(t, "maintenance", "run")
e.RunAndExpectSuccess(t, "maintenance", "run", "--full")
e.RunAndVerifyOutputLineCount(t, 1, "logs", "list")
}
func TestLogsMaintenanceSet(t *testing.T) {
t.Parallel()
runner := testenv.NewInProcRunner(t)
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
e.RunAndExpectSuccess(t, "maintenance", "set",
"--max-retained-log-age=22h",

View File

@@ -3,8 +3,6 @@
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/maintenance"
"github.com/kopia/kopia/snapshot/snapshotmaintenance"
@@ -28,12 +26,7 @@ func (c *commandMaintenanceRun) setup(svc appServices, parent commandParent) {
func (c *commandMaintenanceRun) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
mode := maintenance.ModeQuick
_, supportsEpochManager, err := rep.ContentManager().EpochManager(ctx)
if err != nil {
return errors.Wrap(err, "EpochManager")
}
if c.maintenanceRunFull || supportsEpochManager {
if c.maintenanceRunFull {
mode = maintenance.ModeFull
}