MCPcopy
hub / github.com/kopia/kopia / drainAllClients

Method drainAllClients

cli/command_repository_upgrade.go:408–434  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepositoryWriter)

Source from the content-addressed store, hash-verified

406}
407
408func (c *commandRepositoryUpgrade) drainAllClients(ctx context.Context, rep repo.DirectRepositoryWriter) error {
409 for {
410 l, err := rep.FormatManager().GetUpgradeLockIntent(ctx)
411
412 upgradeTime := l.UpgradeTime()
413 now := rep.Time()
414
415 log(ctx).Infof("Waiting for %s to allow all other kopia clients to drain ...", upgradeTime.Sub(rep.Time()).Round(time.Second))
416
417 locked, writersDrained := l.IsLocked(now)
418 if locked {
419 if writersDrained {
420 // we have the lock now
421 break
422 }
423 } else {
424 return errors.Wrap(err, "upgrade lock got revoked after the intent was placed, giving up")
425 }
426
427 // TODO: this can get stuck
428 if !c.sleepWithContext(ctx, l.StatusPollInterval) {
429 return errors.New("upgrade drain interrupted")
430 }
431 }
432
433 return nil
434}
435
436// upgrade phase performs the actual upgrade action that upgrades the target
437// repository. This phase runs after the lock has been acquired in one of the

Callers 1

drainOrCommitMethod · 0.95

Calls 7

sleepWithContextMethod · 0.95
GetUpgradeLockIntentMethod · 0.80
UpgradeTimeMethod · 0.80
SubMethod · 0.80
IsLockedMethod · 0.80
FormatManagerMethod · 0.65
TimeMethod · 0.65

Tested by

no test coverage detected