From 95a9d18d1cb4bce4339eb6004ff2e2f75f8df46c Mon Sep 17 00:00:00 2001 From: "Aaron H. Alpar" Date: Mon, 5 Dec 2022 10:59:59 -0800 Subject: [PATCH] fixups and clarity --- cli/command_repository_upgrade.go | 15 ++++++++++----- cli/command_repository_upgrade_test.go | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cli/command_repository_upgrade.go b/cli/command_repository_upgrade.go index 1b13b8f05..7f363a8e9 100644 --- a/cli/command_repository_upgrade.go +++ b/cli/command_repository_upgrade.go @@ -152,19 +152,21 @@ func (c *commandRepositoryUpgrade) validateAction(ctx context.Context, rep repo. return errors.Wrapf(err, "failed to load index entries for new index") } - var msgs []string + var msgs []string // a place to keep messages from the index comparison process + // both indexes will have matching contentiDs with matching indexInfo sructures. for contentID, indexEntryPairs := range indexEntries { - iep0 := indexEntryPairs[0] - iep1 := indexEntryPairs[1] - - // compare two index blobs for the same content ID + iep0 := indexEntryPairs[0] // first entry of index entry pair + iep1 := indexEntryPairs[1] // second entry of index entry pair + // check that both the new and old indexes have entries for the same content if iep0 != nil && iep1 != nil { + // this is the happy-path, check the entries. any problems found will be added to msgs msgs = append(msgs, checkIndexInfo(iep0, iep1)...) continue } + // one of iep0 or iep1 are nil .. find out which one and add an appropriate message. if iep0 != nil { msgs = append(msgs, fmt.Sprintf("lop-sided index entries for contentID %q at blob %q", contentID, iep0.GetPackBlobID())) continue @@ -173,17 +175,20 @@ func (c *commandRepositoryUpgrade) validateAction(ctx context.Context, rep repo. msgs = append(msgs, fmt.Sprintf("lop-sided index entries for contentID %q at blob %q", contentID, iep1.GetPackBlobID())) } + // no msgs means the check passed without finding anything wrong if len(msgs) == 0 { log(ctx).Infof("index validation succeeded") return nil } + // otherwise there's a problem somewhere ... log the problems log(ctx).Error("inconsistencies found in migrated index:") for _, m := range msgs { log(ctx).Error(m) } + // and return an error that states something's wrong. return errors.Wrap(err, "repository will remain locked until index differences are resolved") } diff --git a/cli/command_repository_upgrade_test.go b/cli/command_repository_upgrade_test.go index 643c9af08..7eb5835e7 100644 --- a/cli/command_repository_upgrade_test.go +++ b/cli/command_repository_upgrade_test.go @@ -87,7 +87,6 @@ func (s *formatSpecificTestSuite) TestRepositoryCorruptedUpgrade(t *testing.T) { "--status-poll-interval", "1s", "--max-permitted-clock-drift", "1s") require.Contains(t, stderr, "Repository indices have already been migrated to the epoch format, no need to drain other clients") - require.Contains(t, stderr, "Commit mode is set to 'never'. Skipping commit.") default: require.Contains(t, out, "Format version: 3") env.RunAndExpectFailure(t, "repository", "upgrade",