Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashmate): invalid platform version in the status command #2249

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/group/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class GroupStatusCommand extends GroupBaseCommand {
plain['Platform Status'] = colors.status(scope.platform.tenderdash.serviceStatus)(scope.platform.tenderdash.serviceStatus) || 'n/a';
} else {
plain['Platform Status'] = colors.status(scope.platform.tenderdash.serviceStatus)(scope.platform.tenderdash.serviceStatus) || 'n/a';
plain['Platform Version'] = scope.platform.tenderdash.version || 'n/a';
plain['Platform Version'] = scope.platform.drive.version || 'n/a';
plain['Platform Block Height'] = scope.platform.tenderdash.latestBlockHeight || 'n/a';
plain['Platform Peers'] = scope.platform.tenderdash.peers || 'n/a';
plain['Platform Network'] = scope.platform.tenderdash.network || 'n/a';
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class StatusCommand extends ConfigBaseCommand {
plain['Platform Status'] = colors.status(platformStatus)(platformStatus) || 'n/a';

if (platform.tenderdash.serviceStatus === ServiceStatusEnum.up) {
plain['Platform Version'] = platform.tenderdash.version || 'n/a';
plain['Platform Version'] = platform.drive.version || 'n/a';
plain['Platform Block Height'] = platform.tenderdash.latestBlockHeight || 'n/a';
plain['Platform Peers'] = platform.tenderdash.peers || 'n/a';
plain['Platform Network'] = platform.tenderdash.network || 'n/a';
Expand Down
1 change: 0 additions & 1 deletion packages/dashmate/src/commands/status/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class PlatformStatusCommand extends ConfigBaseCommand {
flags,
dockerCompose,
createRpcClient,
getConnectionHost,
config,
getPlatformScope,
) {
Expand Down
18 changes: 18 additions & 0 deletions packages/dashmate/src/status/scopes/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default function getPlatformScopeFactory(
const info = {
dockerStatus: null,
serviceStatus: null,
version: null,
};

try {
Expand Down Expand Up @@ -190,6 +191,23 @@ export default function getPlatformScopeFactory(
throw e;
}
}

try {
const driveVersionResult = await dockerCompose.execCommand(
config,
'drive_abci',
'drive-abci version',
);

info.version = driveVersionResult.out.trim();
} catch (e) {
// Throw an error if it's not a Drive issue
if (!(e instanceof DockerComposeError
&& e.dockerComposeExecutionResult
&& e.dockerComposeExecutionResult.exitCode !== 0)) {
throw e;
}
}
}

return info;
Expand Down
25 changes: 15 additions & 10 deletions packages/rs-drive-abci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ enum Commands {
/// by creating `.fsck` file in database directory (`DB_PATH`).
#[command()]
Verify,

/// Print current software version
#[command()]
Version,
}

/// Server that accepts connections from Tenderdash, and
Expand Down Expand Up @@ -148,6 +152,7 @@ impl Cli {
Commands::Config => dump_config(&config)?,
Commands::Status => runtime.block_on(check_status(&config))?,
Commands::Verify => verify_grovedb(&config.db_path, true)?,
Commands::Version => print_version(),
};

Ok(())
Expand Down Expand Up @@ -220,16 +225,11 @@ fn main() -> Result<(), ExitCode> {

runtime.spawn(handle_signals(cancel.clone(), loggers));

let result = match cli.run(&runtime, config, cancel) {
Ok(()) => {
tracing::debug!("shutdown complete");
Ok(())
}
Err(e) => {
tracing::error!(error = e, "drive-abci failed: {e}");
Err(ExitCode::FAILURE)
}
};
let result = cli.run(&runtime, config, cancel).map_err(|e| {
tracing::error!(error = e, "drive-abci failed: {e}");

ExitCode::FAILURE
});

drop(runtime_guard);
runtime.shutdown_timeout(Duration::from_millis(SHUTDOWN_TIMEOUT_MILIS));
Expand Down Expand Up @@ -387,6 +387,11 @@ fn verify_grovedb(db_path: &PathBuf, force: bool) -> Result<(), String> {
}
}

/// Print current software version.
fn print_version() {
println!("{}", env!("CARGO_PKG_VERSION"));
}

fn load_config(path: &Option<PathBuf>) -> PlatformConfig {
if let Some(path) = path {
if let Err(e) = dotenvy::from_path(path) {
Expand Down
Loading