Skip to content

Commit

Permalink
migrate: informative msg on re-attempted migration
Browse files Browse the repository at this point in the history
If an operator runs `pd migrate` and then runs it again, the error
message should accurately describe the situation that the local state is
already migrated, and state that pd is refusing to proceed as
instructed.

Notably this failure occurs even if the `--force` flag is provided to
`pd migrate`, so I've updated the docstring on that flag accordingly.
  • Loading branch information
conorsch committed Nov 15, 2024
1 parent 10e3564 commit 47230fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub enum RootCommand {
#[clap(long, display_order = 200)]
comet_home: Option<PathBuf>,
/// If set, force a migration to occur even if the chain is not halted.
/// Will not override a detected mismatch in state versions.
#[clap(long, display_order = 1000)]
force: bool,
/// If set, edit local state to permit the node to start, despite
Expand Down
8 changes: 8 additions & 0 deletions crates/core/app/src/app_version/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ fn check_version(ctx: CheckContext, expected: u64, found: Option<u64>) -> anyhow
let expected_name = version_to_software_version(expected);
let found_name = version_to_software_version(found);
let mut error = String::new();
if found == APP_VERSION {
write!(
&mut error,
"state already migrated to version {}",
APP_VERSION
)?;
anyhow::bail!(error);
}
error.push_str("app version mismatch:\n");
write!(
&mut error,
Expand Down

0 comments on commit 47230fd

Please sign in to comment.