upgrade phase performs the actual upgrade action that upgrades the target repository. This phase runs after the lock has been acquired in one of the prior phases.
(ctx context.Context, rep repo.DirectRepositoryWriter)
| 437 | // repository. This phase runs after the lock has been acquired in one of the |
| 438 | // prior phases. |
| 439 | func (c *commandRepositoryUpgrade) upgrade(ctx context.Context, rep repo.DirectRepositoryWriter) error { |
| 440 | mp, mperr := rep.ContentReader().ContentFormat().GetMutableParameters(ctx) |
| 441 | if mperr != nil { |
| 442 | return errors.Wrap(mperr, "mutable parameters") |
| 443 | } |
| 444 | |
| 445 | rf, err := rep.FormatManager().RequiredFeatures(ctx) |
| 446 | if err != nil { |
| 447 | return errors.Wrap(err, "error getting repository features") |
| 448 | } |
| 449 | |
| 450 | if mp.EpochParameters.Enabled { |
| 451 | // nothing to upgrade on format, so let the next action commit the upgraded format blob |
| 452 | return nil |
| 453 | } |
| 454 | |
| 455 | mp.EpochParameters = epoch.DefaultParameters() |
| 456 | mp.IndexVersion = 2 |
| 457 | |
| 458 | log(ctx).Info("migrating current indices to epoch format") |
| 459 | |
| 460 | if uerr := rep.ContentManager().PrepareUpgradeToIndexBlobManagerV1(ctx); uerr != nil { |
| 461 | return errors.Wrap(uerr, "error upgrading indices") |
| 462 | } |
| 463 | |
| 464 | blobCfg, err := rep.FormatManager().BlobCfgBlob(ctx) |
| 465 | if err != nil { |
| 466 | return errors.Wrap(err, "error getting blob configuration") |
| 467 | } |
| 468 | |
| 469 | // update format-blob and clear the cache |
| 470 | if err := rep.FormatManager().SetParameters(ctx, mp, blobCfg, rf); err != nil { |
| 471 | return errors.Wrap(err, "error setting parameters") |
| 472 | } |
| 473 | |
| 474 | // we need to reopen the repository after this point |
| 475 | |
| 476 | log(ctx).Info("Repository indices have been upgraded.") |
| 477 | |
| 478 | return nil |
| 479 | } |
| 480 | |
| 481 | // commitUpgrade is the upgrade CLI phase that commits the upgrade and removes |
| 482 | // the lock after the actual upgrade phase has been run successfully. We will |
nothing calls this directly
no test coverage detected