MCPcopy Index your code
hub / github.com/kopia/kopia / drainOrCommit

Method drainOrCommit

cli/command_repository_upgrade.go:356–388  ·  view source on GitHub ↗

drainOrCommit is the upgrade CLI phase that will actually wait for all the clients to be drained out of the upgrade quorum. This phase will cause all other phases to be skipped until the lock is fully established.

(ctx context.Context, rep repo.DirectRepositoryWriter)

Source from the content-addressed store, hash-verified

354// clients to be drained out of the upgrade quorum. This phase will cause all other phases to be
355// skipped until the lock is fully established.
356func (c *commandRepositoryUpgrade) drainOrCommit(ctx context.Context, rep repo.DirectRepositoryWriter) error {
357 cf := rep.ContentReader().ContentFormat()
358
359 mp, mperr := cf.GetMutableParameters(ctx)
360 if mperr != nil {
361 return errors.Wrap(mperr, "mutable parameters")
362 }
363
364 if mp.EpochParameters.Enabled {
365 log(ctx).Info("Repository indices have already been migrated to the epoch format, no need to drain other clients")
366
367 l, err := rep.FormatManager().GetUpgradeLockIntent(ctx)
368 if err != nil {
369 return errors.Wrap(err, "failed to get upgrade lock intent")
370 }
371
372 if l.AdvanceNoticeDuration == 0 {
373 // let the upgrade continue to commit the new format blob
374 return nil
375 }
376
377 log(ctx).Info("Continuing to drain since advance notice has been set")
378 }
379
380 if err := c.drainAllClients(ctx, rep); err != nil {
381 return errors.Wrap(err, "failed to upgrade the repository, lock is not released")
382 }
383 // we need to reopen the repository after this point
384
385 log(ctx).Info("Successfully drained all repository clients, the lock has been fully-established now.")
386
387 return nil
388}
389
390func (c *commandRepositoryUpgrade) sleepWithContext(ctx context.Context, dur time.Duration) bool {
391 t := time.NewTimer(dur)

Callers

nothing calls this directly

Calls 7

drainAllClientsMethod · 0.95
InfoMethod · 0.80
GetUpgradeLockIntentMethod · 0.80
ContentFormatMethod · 0.65
ContentReaderMethod · 0.65
GetMutableParametersMethod · 0.65
FormatManagerMethod · 0.65

Tested by

no test coverage detected