(ctx context.Context, rep repo.DirectRepositoryWriter)
| 406 | } |
| 407 | |
| 408 | func (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 |
no test coverage detected