Call config verify command during maintenance (#5123)
Add the wiring to actually call the new config verify command during maintenance --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) merge after: * #5117 * #5118 * #5122 #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
8437724254
commit
85aaa448c5
@ -847,6 +847,8 @@ func (w *conn) verifyDefaultConfigOptions(
|
||||
ctx context.Context,
|
||||
errs *fault.Bus,
|
||||
) {
|
||||
logger.Ctx(ctx).Info("verifying config parameters")
|
||||
|
||||
w.verifyDefaultPolicyConfigOptions(ctx, errs)
|
||||
w.verifyRetentionConfig(ctx, errs)
|
||||
}
|
||||
|
||||
@ -665,7 +665,12 @@ func (w Wrapper) RepoMaintenance(
|
||||
ctx context.Context,
|
||||
storer store.Storer,
|
||||
opts repository.Maintenance,
|
||||
errs *fault.Bus,
|
||||
) error {
|
||||
// Check the existing config parameters first so that even if we fail for some
|
||||
// reason below we know we checked the config.
|
||||
w.c.verifyDefaultConfigOptions(ctx, errs)
|
||||
|
||||
kopiaSafety, err := translateSafety(opts.Safety)
|
||||
if err != nil {
|
||||
return clues.WrapWC(ctx, err, "identifying safety level")
|
||||
@ -696,8 +701,9 @@ func (w Wrapper) RepoMaintenance(
|
||||
// Even if we fail this we don't want to fail the overall maintenance
|
||||
// operation since there's other useful work we can still do.
|
||||
if err := cleanupOrphanedData(ctx, storer, w.c, buffer, time.Now); err != nil {
|
||||
logger.CtxErr(ctx, err).Info(
|
||||
"cleaning up failed backups, some space may not be freed")
|
||||
errs.AddRecoverable(ctx, clues.Wrap(
|
||||
err,
|
||||
"cleaning up failed backups, some space may not be freed"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ func (suite *BasicKopiaIntegrationSuite) TestMaintenance_FirstRun_NoChanges() {
|
||||
Type: repository.MetadataMaintenance,
|
||||
}
|
||||
|
||||
err = w.RepoMaintenance(ctx, nil, opts)
|
||||
err = w.RepoMaintenance(ctx, nil, opts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ func (suite *BasicKopiaIntegrationSuite) TestMaintenance_WrongUser_NoForce_Fails
|
||||
}
|
||||
|
||||
// This will set the user.
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
err = k.Close(ctx)
|
||||
@ -236,7 +236,7 @@ func (suite *BasicKopiaIntegrationSuite) TestMaintenance_WrongUser_NoForce_Fails
|
||||
|
||||
var notOwnedErr maintenance.NotOwnedError
|
||||
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
assert.ErrorAs(t, err, ¬OwnedErr, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ func (suite *BasicKopiaIntegrationSuite) TestMaintenance_WrongUser_Force_Succeed
|
||||
}
|
||||
|
||||
// This will set the user.
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
err = k.Close(ctx)
|
||||
@ -275,13 +275,13 @@ func (suite *BasicKopiaIntegrationSuite) TestMaintenance_WrongUser_Force_Succeed
|
||||
mOpts.Force = true
|
||||
|
||||
// This will set the user.
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
mOpts.Force = false
|
||||
|
||||
// Running without force should succeed now.
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
}
|
||||
|
||||
@ -733,7 +733,7 @@ func (suite *RetentionIntegrationSuite) TestSetRetentionParameters_And_Maintenan
|
||||
// This will set common maintenance config parameters. There's some interplay
|
||||
// between the maintenance schedule and retention period that we want to check
|
||||
// below.
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts)
|
||||
err = w.RepoMaintenance(ctx, nil, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// Enable retention.
|
||||
@ -838,7 +838,7 @@ func (suite *RetentionIntegrationSuite) TestSetAndUpdateRetentionParameters_RunM
|
||||
// This will set common maintenance config parameters. There's some interplay
|
||||
// between the maintenance schedule and retention period that we want to check
|
||||
// below.
|
||||
err = w.RepoMaintenance(ctx, ms, mOpts)
|
||||
err = w.RepoMaintenance(ctx, ms, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
// Enable retention.
|
||||
@ -882,7 +882,7 @@ func (suite *RetentionIntegrationSuite) TestSetAndUpdateRetentionParameters_RunM
|
||||
|
||||
// Run full maintenance again. This should extend object locks for things if
|
||||
// they exist.
|
||||
err = w.RepoMaintenance(ctx, ms, mOpts)
|
||||
err = w.RepoMaintenance(ctx, ms, mOpts, fault.New(true))
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
})
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ func (op *MaintenanceOperation) do(ctx context.Context) error {
|
||||
op.Results.CompletedAt = time.Now()
|
||||
}()
|
||||
|
||||
err := op.operation.kopia.RepoMaintenance(ctx, op.store, op.mOpts)
|
||||
err := op.operation.kopia.RepoMaintenance(ctx, op.store, op.mOpts, op.Errors)
|
||||
if err != nil {
|
||||
op.Status = Failed
|
||||
return clues.Wrap(err, "running maintenance operation")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user