Skip to content

Commit

Permalink
fix(kubectl-plugin): non-zero exit code on error
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Varakantham <vandana.varakantham@datacore.com>
  • Loading branch information
datacore-vvarakantham committed Dec 4, 2023
1 parent be91751 commit 69447b3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
5 changes: 3 additions & 2 deletions control-plane/plugin/src/resources/blockdevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl GetBlockDevices for BlockDevice {
}
Err(e) => {
println!("Failed to list blockdevices for node {id} . Error {e}");
return;
std::process::exit(1);
}
}

Expand Down Expand Up @@ -169,7 +169,8 @@ impl GetBlockDevices for BlockDevice {
};
}
Err(e) => {
println!("Failed to list blockdevices for node {id} . Error {e}")
println!("Failed to list blockdevices for node {id} . Error {e}");
std::process::exit(1);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions control-plane/plugin/src/resources/cordon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl Get for NodeCordon {
node_display_print_one(node.into_body(), output, NodeDisplayFormat::CordonLabels)
}
Err(e) => {
println!("Failed to get node {id}. Error {e}")
println!("Failed to get node {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down Expand Up @@ -53,7 +54,8 @@ impl List for NodeCordons {
node_display_print(filteredlist, output, NodeDisplayFormat::CordonLabels)
}
Err(e) => {
println!("Failed to list nodes. Error {e}")
println!("Failed to list nodes. Error {e}");
std::process::exit(1);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions control-plane/plugin/src/resources/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ impl Get for NodeDrain {
match RestClient::client().nodes_api().get_node(id).await {
Ok(node) => node_display_print_one(node.into_body(), output, NodeDisplayFormat::Drain),
Err(e) => {
println!("Failed to get node {id}. Error {e}")
println!("Failed to get node {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down Expand Up @@ -51,7 +52,8 @@ impl List for NodeDrains {
node_display_print(filteredlist, output, NodeDisplayFormat::Drain);
}
Err(e) => {
println!("Failed to list nodes. Error {e}")
println!("Failed to list nodes. Error {e}");
std::process::exit(1);
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions control-plane/plugin/src/resources/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl List for Nodes {
utils::print_table(output, nodes.into_body());
}
Err(e) => {
println!("Failed to list nodes. Error {e}")
println!("Failed to list nodes. Error {e}");
std::process::exit(1);
}
}
}
Expand All @@ -116,7 +117,8 @@ impl Get for Node {
utils::print_table(output, node.into_body());
}
Err(e) => {
println!("Failed to get node {id}. Error {e}")
println!("Failed to get node {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down Expand Up @@ -161,7 +163,7 @@ impl Cordoning for Node {
}
Err(e) => {
println!("Failed to get node {id}. Error {e}");
return;
std::process::exit(1);
}
};
let result = match already_has_cordon_label {
Expand All @@ -185,7 +187,8 @@ impl Cordoning for Node {
}
},
Err(e) => {
println!("Failed to cordon node {id}. Error {e}")
println!("Failed to cordon node {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down Expand Up @@ -228,7 +231,8 @@ impl Cordoning for Node {
}
},
Err(e) => {
println!("Failed to uncordon node {id}. Error {e}")
println!("Failed to uncordon node {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down Expand Up @@ -449,7 +453,7 @@ impl Drain for Node {
}
Err(e) => {
println!("Failed to get node {id}. Error {e}");
return;
std::process::exit(1);
}
};
if !already_has_drain_label {
Expand All @@ -459,7 +463,7 @@ impl Drain for Node {
.await
{
println!("Failed to put node drain {id}. Error {error}");
return;
std::process::exit(1);
}
}
// loop this call until no longer draining
Expand Down Expand Up @@ -519,7 +523,7 @@ impl Drain for Node {
}
Err(e) => {
println!("Failed to get node {id}. Error {e}");
break;
std::process::exit(1);
}
}
if timeout_instant.is_some() && time::Instant::now() > timeout_instant.unwrap() {
Expand Down
6 changes: 4 additions & 2 deletions control-plane/plugin/src/resources/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ impl List for Pools {
utils::print_table(output, pools.into_body());
}
Err(e) => {
println!("Failed to list pools. Error {e}")
println!("Failed to list pools. Error {e}");
std::process::exit(1);
}
}
}
Expand All @@ -88,7 +89,8 @@ impl Get for Pool {
utils::print_table(output, pool.into_body());
}
Err(e) => {
println!("Failed to get pool {id}. Error {e}")
println!("Failed to get pool {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions control-plane/plugin/src/resources/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ impl Get for Volume {
utils::print_table(output, volume.into_body());
}
Err(e) => {
println!("Failed to get volume {id}. Error {e}")
println!("Failed to get volume {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand All @@ -176,7 +177,8 @@ impl Scale for Volume {
}
},
Err(e) => {
println!("Failed to scale volume {id}. Error {e}")
println!("Failed to scale volume {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand All @@ -197,7 +199,8 @@ impl ReplicaTopology for Volume {
utils::print_table(output, volume.into_body().state.replica_topology);
}
Err(e) => {
println!("Failed to get volume {id}. Error {e}")
println!("Failed to get volume {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand All @@ -216,7 +219,8 @@ impl RebuildHistory for Volume {
utils::print_table(output, history.into_body());
}
Err(e) => {
println!("Failed to get rebuild history for volume {id}. Error {e}")
println!("Failed to get rebuild history for volume {id}. Error {e}");
std::process::exit(1);
}
}
}
Expand Down

0 comments on commit 69447b3

Please sign in to comment.