Skip to content

Commit

Permalink
feat(version): unified version display
Browse files Browse the repository at this point in the history
'version-info' module is used to display version uniformely for all binaries.

Resolves: ER1-239
  • Loading branch information
dsavitskiy authored and tiagolobocastro committed Jun 8, 2022
1 parent b37f898 commit af597b2
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "spdk-rs"]
path = spdk-rs
url = https://github.com/mayadata-io/spdk-rs
[submodule "utils/mayastor-dependencies"]
path = utils/mayastor-dependencies
url = https://github.com/openebs/mayastor-dependencies.git
10 changes: 9 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ members = [
"sysfs",
"composer",
"spdk-rs",
"utils/mayastor-dependencies/version-info",
]
3 changes: 2 additions & 1 deletion mayastor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["Jeffry Molanus <[email protected]>"]
edition = "2018"
name = "mayastor"
description = "Mayastor"
version = "1.0.0"
default-run = "mayastor-client"
build = "build.rs"
Expand Down Expand Up @@ -51,7 +52,6 @@ crossbeam-sync = "0.0.0"
env_logger = "0.9.0"
function_name = "0.2.0"
futures = "0.3.16"
git-version = "0.3.5"
http = "0.2.4"
io-uring = "0.5.1"
ioctl-gen = "0.1.1"
Expand Down Expand Up @@ -88,6 +88,7 @@ dns-lookup = "1.0.8"
mbus_api = { path = "../mbus-api" }
etcd-client = "0.7.1"
parking_lot = "0.11.1"
version-info = { path = "../utils/mayastor-dependencies/version-info" }


[dependencies.rpc]
Expand Down
5 changes: 3 additions & 2 deletions mayastor/src/bin/casperf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use spdk_rs::{
},
DmaBuf,
};
use version_info::version_info_str;

#[derive(Debug)]
enum IoType {
Expand Down Expand Up @@ -330,8 +331,8 @@ fn main() {
cfg
});

let matches = App::new("\nMayastor performance tool")
.version("0.1")
let matches = App::new("Mayastor performance tool")
.version(version_info_str!())
.settings(&[AppSettings::ColoredHelp, AppSettings::ColorAlways])
.about("Perform IO to storage URIs")
.arg(
Expand Down
2 changes: 2 additions & 0 deletions mayastor/src/bin/initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use mayastor::{
subsys::Config,
};
use spdk_rs::DmaError;
use version_info::version_info_str;

unsafe extern "C" fn run_static_initializers() {
spdk_rs::libspdk::spdk_add_subsystem(subsys::ConfigSubsystem::new().0)
Expand Down Expand Up @@ -149,6 +150,7 @@ async fn connect(uri: &str) -> Result<()> {

fn main() {
let matches = App::new("Test initiator for nexus replica")
.version(version_info_str!())
.about("Connect, read or write a block to a nexus replica using its URI")
.arg(Arg::with_name("URI")
.help("URI of the replica to connect to")
Expand Down
7 changes: 6 additions & 1 deletion mayastor/src/bin/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ extern crate serde_json;

use jsonrpc::call;
use structopt::StructOpt;
use version_info::{package_description, version_info_str};

/// TODO
#[derive(Debug, StructOpt)]
#[structopt(
name = "jsonrpc",
name = package_description!(),
version = version_info_str!(),
about = "Mayastor json-rpc client",
setting = structopt::clap::AppSettings::ColoredHelp
)]
Expand All @@ -23,6 +26,8 @@ struct Opt {
#[structopt(subcommand)]
cmd: Sub,
}

/// TODO
#[derive(StructOpt, Debug)]
enum Sub {
#[structopt(name = "raw")]
Expand Down
3 changes: 2 additions & 1 deletion mayastor/src/bin/mayastor-client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ::rpc::mayastor::{
json_rpc_client::JsonRpcClient,
mayastor_client::MayastorClient,
};
use version_info::version_info_str;

mod bdev_cli;
mod context;
Expand Down Expand Up @@ -54,7 +55,7 @@ async fn main() -> crate::Result<()> {
env_logger::init();

let matches = App::new("Mayastor CLI")
.version("0.1")
.version(version_info_str!())
.settings(&[
AppSettings::SubcommandRequiredElseHelp,
AppSettings::ColoredHelp,
Expand Down
7 changes: 3 additions & 4 deletions mayastor/src/bin/mayastor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{env, path::Path};
use futures::future::FutureExt;
use structopt::StructOpt;

use git_version::git_version;
use mayastor::{
bdev::util::uring,
core::{
Expand All @@ -23,9 +22,8 @@ use mayastor::{
subsys,
subsys::Registration,
};
use version_info::fmt_package_info;

const GIT_VERSION: &str =
git_version!(args = ["--tags", "--abbrev=12"], fallback = "unknown");
const PAGES_NEEDED: u32 = 1024;

mayastor::CPS_INIT!();
Expand Down Expand Up @@ -109,6 +107,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
logger::init("INFO");
}

info!("{}", fmt_package_info!());

hugepage_check();

let nvme_core_path = Path::new("/sys/module/nvme_core/parameters");
Expand All @@ -132,7 +132,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
};

info!("Starting Mayastor version: {}", GIT_VERSION);
info!(
"kernel io_uring support: {}",
if uring::kernel_support() { "yes" } else { "no" }
Expand Down
3 changes: 2 additions & 1 deletion mayastor/src/bin/nvmet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use mayastor::{
grpc,
logger,
};
use version_info::version_info_str;

mayastor::CPS_INIT!();
extern crate tracing;
Expand Down Expand Up @@ -63,7 +64,7 @@ async fn create_nexus(args: &ArgMatches<'_>) {

fn main() {
let matches = App::new("NVMeT CLI")
.version("0.1")
.version(version_info_str!())
.settings(&[
AppSettings::ColoredHelp,
AppSettings::ColorAlways])
Expand Down
5 changes: 3 additions & 2 deletions mayastor/src/bin/uring-support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ extern crate clap;
use clap::App;

use mayastor::bdev::util::uring;
use version_info::version_info_str;

fn main() {
let _matches = App::new("io_uring support")
.version("0.1.0")
let _matches = App::new("Detect io_uring support")
.version(version_info_str!())
.author("Jonathan Teh <[email protected]>")
.about("Determines io_uring support")
.get_matches();
Expand Down
6 changes: 3 additions & 3 deletions mayastor/src/core/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::{

use byte_unit::{Byte, ByteUnit};
use futures::{channel::oneshot, future};
use git_version::git_version;
use once_cell::sync::{Lazy, OnceCell};
use snafu::Snafu;
use spdk_rs::{
Expand All @@ -35,6 +34,7 @@ use spdk_rs::{
};
use structopt::StructOpt;
use tokio::runtime::Builder;
use version_info::{package_description, version_info_str};

use crate::{
bdev::{bdev_io_ctx_pool_init, nexus, nvme_io_ctx_pool_init},
Expand Down Expand Up @@ -72,9 +72,9 @@ fn parse_mb(src: &str) -> Result<i32, String> {

#[derive(Debug, Clone, StructOpt)]
#[structopt(
name = "Mayastor",
name = package_description!(),
about = "Containerized Attached Storage (CAS) for k8s",
version = git_version!(args = ["--tags", "--abbrev=12"], fallback="unkown"),
version = version_info_str!(),
setting(structopt::clap::AppSettings::ColoredHelp)
)]
pub struct MayastorCliArgs {
Expand Down
8 changes: 2 additions & 6 deletions mayastor/src/grpc/mayastor_grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ use tonic::{Request, Response, Status};
struct UnixStream(tokio::net::UnixStream);

use ::function_name::named;
use git_version::git_version;
use std::{panic::AssertUnwindSafe, pin::Pin};
use version_info::raw_version_string;

impl GrpcClientContext {
#[track_caller]
Expand Down Expand Up @@ -1425,11 +1425,7 @@ impl mayastor_server::Mayastor for MayastorSvc {
let features = MayastorFeatures::get_features().into();

let reply = MayastorInfoRequest {
version: git_version!(
args = ["--tags", "--abbrev=12"],
fallback = "unknown"
)
.to_string(),
version: raw_version_string(),
supported_features: Some(features),
};

Expand Down
8 changes: 2 additions & 6 deletions mayastor/src/grpc/v1/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use crate::{
host::{blk_device, resource},
};
use futures::FutureExt;
use git_version::git_version;
use rpc::mayastor::v1::host as rpc;
use std::panic::AssertUnwindSafe;
use tonic::{Request, Response, Status};
use version_info::raw_version_string;

use ::function_name::named;

Expand Down Expand Up @@ -209,11 +209,7 @@ impl rpc::HostRpc for HostService {
let features = MayastorFeatures::get_features().into();

let response = rpc::MayastorInfoResponse {
version: git_version!(
args = ["--tags", "--abbrev=12"],
fallback = "unknown"
)
.to_string(),
version: raw_version_string(),
supported_features: Some(features),
};

Expand Down
1 change: 1 addition & 0 deletions nix/pkgs/mayastor/cargo-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let
"rpc"
"spdk-rs"
"sysfs"
"utils"
];
buildProps = rec {
name = "mayastor";
Expand Down
1 change: 1 addition & 0 deletions utils/mayastor-dependencies
Submodule mayastor-dependencies added at bced30

0 comments on commit af597b2

Please sign in to comment.