Skip to content

Commit

Permalink
Printing a note if the voyager version does not match with the export…
Browse files Browse the repository at this point in the history
… dir version
  • Loading branch information
ShivanshGahlot committed Dec 12, 2024
1 parent e5e8f9c commit fc2a4ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
29 changes: 21 additions & 8 deletions yb-voyager/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,6 @@ func initMetaDB(migrationExportDir string) *metadb.MetaDB {
utils.ErrExit("could not init migration status record: %w", err)
}

msr, err := metaDBInstance.GetMigrationStatusRecord()
if err != nil {
utils.ErrExit("get migration status record: %v", err)
}

msrVoyagerVersionString := msr.VoyagerVersion

detectVersionCompatibility(msrVoyagerVersionString, migrationExportDir)
return metaDBInstance
}

Expand Down Expand Up @@ -522,6 +514,27 @@ func detectVersionCompatibility(msrVoyagerVersionString string, migrationExportD

if msrVoyagerVersion.LessThan(previousBreakingChangeVersion) {
versionCheckFailed = true
} else {
// If the export-dir was created using a version greater than or equal to the PREVIOUS_BREAKING_CHANGE_VERSION,
// then if the current voyager version does not match the export-dir version, then just print a note warning the user.
noteString := fmt.Sprintf(color.YellowString("Note: The export-dir %q was created using voyager version %q. "+
"The current version is %q."),
migrationExportDir, msrVoyagerVersionString, utils.YB_VOYAGER_VERSION)

if utils.YB_VOYAGER_VERSION == "main" {
// In this case we won't be able to convert the version using version.NewVersion() as "main" is not a valid version.
// Moreover, we know here that the msrVoyagerVersion is not "main" as we have already handled that case above.
// Therefore, the current version and the msrVoyagerVersion will not be equal.
utils.PrintAndLog("%s", noteString)
} else {
currentVersion, err := version.NewVersion(utils.YB_VOYAGER_VERSION)
if err != nil {
utils.ErrExit("could not create version from %q: %v", utils.YB_VOYAGER_VERSION, err)
}
if !currentVersion.Equal(msrVoyagerVersion) {
utils.PrintAndLog("%s", noteString)
}
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions yb-voyager/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ Refer to docs (https://docs.yugabyte.com/preview/migrate/) for more details like
// Initialize the metaDB variable only if the metaDB is already created. For example, resumption of a command.
if metaDBIsCreated(exportDir) {
metaDB = initMetaDB(exportDir)
msr, err := metaDB.GetMigrationStatusRecord()
if err != nil {
utils.ErrExit("get migration status record: %v", err)
}

msrVoyagerVersionString := msr.VoyagerVersion

detectVersionCompatibility(msrVoyagerVersionString, exportDir)
}

if perfProfile {
Expand Down

0 comments on commit fc2a4ab

Please sign in to comment.