From 0e91261c3e230f7265b56d612bc035a3d2fc646b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20L=C3=B3pez?= <1953782+julio-lopez@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:04:29 -0700 Subject: [PATCH] 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 --- cli/command_logs_test.go | 14 ++++++++++++-- cli/command_maintenance_run.go | 9 +-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cli/command_logs_test.go b/cli/command_logs_test.go index 090f25ec3..28b45d2fc 100644 --- a/cli/command_logs_test.go +++ b/cli/command_logs_test.go @@ -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", diff --git a/cli/command_maintenance_run.go b/cli/command_maintenance_run.go index d2e42c612..b18c880ac 100644 --- a/cli/command_maintenance_run.go +++ b/cli/command_maintenance_run.go @@ -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 }