Add better logging and update dependencies
This commit is contained in:
parent
c5960a55a9
commit
db18e03513
185
Cargo.lock
generated
185
Cargo.lock
generated
@ -8,36 +8,15 @@ version = "1.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
|
||||
[[package]]
|
||||
name = "async-stream"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e"
|
||||
dependencies = [
|
||||
"async-stream-impl",
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-stream-impl"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.58"
|
||||
version = "0.1.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c"
|
||||
checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -48,9 +27,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.5.17"
|
||||
version = "0.6.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43"
|
||||
checksum = "3b32c5ea3aabaf4deb5f5ced2d688ec0844c881c9e6c696a8b769a05fc691e62"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum-core",
|
||||
@ -66,20 +45,19 @@ dependencies = [
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.2.9"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc"
|
||||
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
@ -87,15 +65,16 @@ dependencies = [
|
||||
"http",
|
||||
"http-body",
|
||||
"mime",
|
||||
"rustversion",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
@ -130,6 +109,15 @@ dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fern"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.2"
|
||||
@ -194,9 +182,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gluster-dir-csi"
|
||||
version = "0.1.0"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"fern",
|
||||
"hostname",
|
||||
"humantime",
|
||||
"log",
|
||||
"prost",
|
||||
"prost-types",
|
||||
"tokio",
|
||||
@ -258,9 +249,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.8"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
|
||||
checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
@ -278,12 +269,6 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-range-header"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.8.0"
|
||||
@ -297,10 +282,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.22"
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
@ -362,9 +353,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.4"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
@ -395,9 +386,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.5.0"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb"
|
||||
checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
@ -478,7 +469,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -506,23 +497,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c142c0e46b57171fe0c528bee8c5b7569e80f0c17e377cd0e30ea57dbc11bb51"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
version = "1.0.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.11.2"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0841812012b2d4a6145fae9a6af1534873c32aa67fff26bd09f8fa42c83f95a"
|
||||
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost-derive",
|
||||
@ -530,9 +521,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "prost-build"
|
||||
version = "0.11.2"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d8b442418ea0822409d9e7d047cbf1e7e9e1760b172bf9982cf29d517c93511"
|
||||
checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"heck",
|
||||
@ -545,39 +536,38 @@ dependencies = [
|
||||
"prost",
|
||||
"prost-types",
|
||||
"regex",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
"tempfile",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.11.2"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "164ae68b6587001ca506d3bf7f1000bfa248d0e1217b618108fba4ec1d0cc306"
|
||||
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.11.2"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "747761bc3dc48f9a34553bf65605cf6cb6288ba219f3450b4275dbd81539551a"
|
||||
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@ -645,6 +635,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.147"
|
||||
@ -681,6 +677,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcf316d5356ed6847742d036f8a39c3b8435cac10bd528a4bd461928a6ab34d5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "0.1.1"
|
||||
@ -737,7 +744,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -767,11 +774,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tonic"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55b9af819e54b8f33d453655bef9b9acc171568fb49523078d0cc4e7484200ec"
|
||||
checksum = "38bd8e87955eb13c1986671838177d6792cdc52af9bffced0d2c8a9a7f741ab3"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"base64",
|
||||
@ -786,28 +792,25 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"prost",
|
||||
"prost-derive",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tonic-build"
|
||||
version = "0.8.2"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c6fd7c2581e36d63388a9e04c350c21beb7a8b059580b2e93993c526899ddc"
|
||||
checksum = "0f60a933bbea70c95d633c04c951197ddf084958abaa2ed502a3743bdd8d8dd7"
|
||||
dependencies = [
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"prost-build",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -830,25 +833,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-http"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-range-header",
|
||||
"pin-project-lite",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-layer"
|
||||
version = "0.3.2"
|
||||
@ -868,7 +852,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
@ -882,7 +865,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -894,16 +877,6 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-futures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.3"
|
||||
|
@ -1,17 +1,20 @@
|
||||
[package]
|
||||
name = "gluster-dir-csi"
|
||||
version = "0.1.0"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tonic = "0.8"
|
||||
tonic = "0.9"
|
||||
prost = "0.11"
|
||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
||||
tokio-stream = { version = "0.1", features = ["net"] }
|
||||
hostname = "0.3.1"
|
||||
prost-types = "0.11.2"
|
||||
log = "0.4.17"
|
||||
fern = "0.6.2"
|
||||
humantime = "2.1.0"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.8"
|
||||
tonic-build = "0.9"
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM docker.io/rust:1.65.0-slim-bullseye as builder
|
||||
FROM docker.io/rust:1.67.0-slim-bullseye as builder
|
||||
|
||||
RUN apt-get update -yq && \
|
||||
apt install -y --no-install-recommends \
|
||||
|
83
src/main.rs
83
src/main.rs
@ -3,6 +3,9 @@ use std::process::Command;
|
||||
|
||||
use tonic::{transport::Server, Request, Response, Status};
|
||||
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use std::time::SystemTime;
|
||||
|
||||
pub mod csi {
|
||||
tonic::include_proto!("csi.v1");
|
||||
}
|
||||
@ -35,7 +38,7 @@ fn mount_volume(volume_id: String, target_path: String) -> Result<(), Status> {
|
||||
// Code 0 means success
|
||||
// Code 32 means already mounted
|
||||
if output.status.code() != Some(0) && output.status.code() != Some(32) {
|
||||
println!(
|
||||
error!(
|
||||
"Mount failed with code: {:?} {}",
|
||||
output.status.code(),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
@ -62,7 +65,7 @@ fn unmount_volume(target_path: String) -> Result<(), Status> {
|
||||
// Code 0 means success
|
||||
// Code 32 means already unmounted
|
||||
if output.status.code() != Some(0) && output.status.code() != Some(32) {
|
||||
println!(
|
||||
error!(
|
||||
"Unmount failed with code: {:?} {}",
|
||||
output.status.code(),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
@ -86,7 +89,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeGetInfoRequest>,
|
||||
) -> Result<Response<csi::NodeGetInfoResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
// Get hostname of system
|
||||
let hostname = hostname::get().unwrap().into_string().unwrap();
|
||||
@ -103,7 +106,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeGetCapabilitiesRequest>,
|
||||
) -> Result<Response<csi::NodeGetCapabilitiesResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let reply = csi::NodeGetCapabilitiesResponse {
|
||||
capabilities: vec![csi::NodeServiceCapability {
|
||||
@ -121,7 +124,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodePublishVolumeRequest>,
|
||||
) -> Result<Response<csi::NodePublishVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let volume_id = request.get_ref().volume_id.clone();
|
||||
let target_path = request.get_ref().target_path.clone();
|
||||
@ -137,7 +140,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeUnpublishVolumeRequest>,
|
||||
) -> Result<Response<csi::NodeUnpublishVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let target_path = request.get_ref().target_path.clone();
|
||||
|
||||
@ -152,7 +155,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeStageVolumeRequest>,
|
||||
) -> Result<Response<csi::NodeStageVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let volume_id = request.get_ref().volume_id.clone();
|
||||
let target_path = request.get_ref().staging_target_path.clone();
|
||||
@ -168,7 +171,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeUnstageVolumeRequest>,
|
||||
) -> Result<Response<csi::NodeUnstageVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let target_path = request.get_ref().staging_target_path.clone();
|
||||
|
||||
@ -183,7 +186,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeExpandVolumeRequest>,
|
||||
) -> Result<Response<csi::NodeExpandVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("Not implemented"))
|
||||
}
|
||||
@ -192,7 +195,7 @@ impl Node for GlusterNode {
|
||||
&self,
|
||||
request: Request<csi::NodeGetVolumeStatsRequest>,
|
||||
) -> Result<Response<csi::NodeGetVolumeStatsResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("Not implemented"))
|
||||
}
|
||||
@ -207,7 +210,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ControllerGetCapabilitiesRequest>,
|
||||
) -> Result<Response<csi::ControllerGetCapabilitiesResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
// Return CREATE_DELETE_VOLUME capability
|
||||
let reply = csi::ControllerGetCapabilitiesResponse {
|
||||
@ -228,7 +231,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::CreateVolumeRequest>,
|
||||
) -> Result<Response<csi::CreateVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let name = request.into_inner().name;
|
||||
|
||||
@ -250,7 +253,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::DeleteVolumeRequest>,
|
||||
) -> Result<Response<csi::DeleteVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
// let name = request.into_inner().volume_id;
|
||||
|
||||
@ -264,7 +267,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ControllerPublishVolumeRequest>,
|
||||
) -> Result<Response<csi::ControllerPublishVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -273,7 +276,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ControllerUnpublishVolumeRequest>,
|
||||
) -> Result<Response<csi::ControllerUnpublishVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -282,7 +285,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ValidateVolumeCapabilitiesRequest>,
|
||||
) -> Result<Response<csi::ValidateVolumeCapabilitiesResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -291,7 +294,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ListVolumesRequest>,
|
||||
) -> Result<Response<csi::ListVolumesResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -300,7 +303,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::GetCapacityRequest>,
|
||||
) -> Result<Response<csi::GetCapacityResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -309,7 +312,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ControllerGetVolumeRequest>,
|
||||
) -> Result<Response<csi::ControllerGetVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -318,7 +321,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::CreateSnapshotRequest>,
|
||||
) -> Result<Response<csi::CreateSnapshotResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -327,7 +330,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::DeleteSnapshotRequest>,
|
||||
) -> Result<Response<csi::DeleteSnapshotResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -336,7 +339,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ListSnapshotsRequest>,
|
||||
) -> Result<Response<csi::ListSnapshotsResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -345,7 +348,7 @@ impl Controller for GlusterController {
|
||||
&self,
|
||||
request: Request<csi::ControllerExpandVolumeRequest>,
|
||||
) -> Result<Response<csi::ControllerExpandVolumeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
@ -360,11 +363,11 @@ impl Identity for GlusterIdentity {
|
||||
&self,
|
||||
request: Request<csi::GetPluginInfoRequest>,
|
||||
) -> Result<Response<csi::GetPluginInfoResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let reply = csi::GetPluginInfoResponse {
|
||||
name: "glusterf-dir-csi".to_string(),
|
||||
vendor_version: "0.1.0".to_string(),
|
||||
vendor_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -375,7 +378,7 @@ impl Identity for GlusterIdentity {
|
||||
&self,
|
||||
request: Request<csi::GetPluginCapabilitiesRequest>,
|
||||
) -> Result<Response<csi::GetPluginCapabilitiesResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let reply = csi::GetPluginCapabilitiesResponse {
|
||||
capabilities: vec![csi::PluginCapability {
|
||||
@ -394,7 +397,7 @@ impl Identity for GlusterIdentity {
|
||||
&self,
|
||||
request: Request<csi::ProbeRequest>,
|
||||
) -> Result<Response<csi::ProbeResponse>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
debug!("Got a request: {:?}", request);
|
||||
|
||||
let reply = csi::ProbeResponse { ready: Some(true) };
|
||||
|
||||
@ -402,8 +405,27 @@ impl Identity for GlusterIdentity {
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_logger() -> Result<(), fern::InitError> {
|
||||
fern::Dispatch::new()
|
||||
.format(|out, message, record| {
|
||||
out.finish(format_args!(
|
||||
"[{} {} {}] {}",
|
||||
humantime::format_rfc3339_seconds(SystemTime::now()),
|
||||
record.level(),
|
||||
record.target(),
|
||||
message
|
||||
))
|
||||
})
|
||||
.level(log::LevelFilter::Debug)
|
||||
.chain(std::io::stdout())
|
||||
.apply()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
setup_logger()?;
|
||||
|
||||
std::fs::create_dir_all("/mnt/main")?;
|
||||
// Mount glusterfs main
|
||||
let res = Command::new("mount")
|
||||
@ -419,9 +441,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.expect("failed to mount glusterfs");
|
||||
|
||||
if res.status.success() {
|
||||
println!("Glusterfs mounted");
|
||||
info!("Glusterfs mounted");
|
||||
} else {
|
||||
println!(
|
||||
error!(
|
||||
"Glusterfs mount failed: {}",
|
||||
String::from_utf8_lossy(&res.stderr)
|
||||
);
|
||||
@ -432,13 +454,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let controller = GlusterController::default();
|
||||
let node = GlusterNode::default();
|
||||
|
||||
println!("Starting server...");
|
||||
info!("Starting server...");
|
||||
let csi_sock_base = std::env::var("CSI_PATH")
|
||||
.or_else(|_| Ok::<String, Error>("/csi/".to_owned()))
|
||||
.unwrap();
|
||||
|
||||
std::fs::create_dir_all(&csi_sock_base)?;
|
||||
let csi_sock: String = csi_sock_base + "csi.sock";
|
||||
info!("Listening on {},", csi_sock);
|
||||
|
||||
let uds = UnixListener::bind(csi_sock)?;
|
||||
let uds_stream = UnixListenerStream::new(uds);
|
||||
|
Loading…
Reference in New Issue
Block a user