Skip to content

Commit

Permalink
fix: volume creation failed in eks cluster due to different hostname …
Browse files Browse the repository at this point in the history
…and nodename

Signed-off-by: Abhinandan Purkait <[email protected]>
  • Loading branch information
Abhinandan-Purkait authored and Paul Yoong committed May 27, 2022
1 parent 32c4dc5 commit 53fe82e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 9 additions & 5 deletions mayastor/src/bin/mayastor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[macro_use]
extern crate tracing;

use std::path::Path;
use std::{env, path::Path};

use futures::future::FutureExt;
use structopt::StructOpt;
Expand Down Expand Up @@ -32,10 +32,14 @@ fn start_tokio_runtime(args: &MayastorCliArgs) {
let grpc_address = grpc::endpoint(args.grpc_endpoint.clone());
let registration_addr = args.registration_endpoint.clone();
let rpc_address = args.rpc_address.clone();
let node_name = args
.node_name
.clone()
.unwrap_or_else(|| "mayastor-node".into());
// In case we do not have the node-name provided we would set the node name
// as the hostname(env always present), because the csi-controller adds
// the hostname in allowed nodes in the topology and in case there is
// mismatch, for ex, in case of EKS clusters where hostname and
// node name differ volume wont be created, so we set it to hostname.
let node_name = args.node_name.clone().unwrap_or_else(|| {
env::var("HOSTNAME").unwrap_or_else(|_| "mayastor-node".into())
});

let persistent_store_endpoint = args.persistent_store_endpoint.clone();

Expand Down
5 changes: 4 additions & 1 deletion mayastor/src/core/env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
env,
ffi::CString,
os::raw::{c_char, c_void},
pin::Pin,
Expand Down Expand Up @@ -373,7 +374,9 @@ impl MayastorEnvironment {
grpc_endpoint: Some(grpc::endpoint(args.grpc_endpoint)),
registration_endpoint: args.registration_endpoint,
persistent_store_endpoint: args.persistent_store_endpoint,
node_name: args.node_name.unwrap_or_else(|| "mayastor-node".into()),
node_name: args.node_name.unwrap_or_else(|| {
env::var("HOSTNAME").unwrap_or_else(|_| "mayastor-node".into())
}),
mayastor_config: args.mayastor_config,
pool_config: args.pool_config,
log_component: args.log_components,
Expand Down

0 comments on commit 53fe82e

Please sign in to comment.