Skip to content

Commit fbaee6a

Browse files
mayastor-borsdsavitskiy
mayastor-bors
andcommitted
Merge #1618
1618: fix(nvmf): fixing duplicate QID error for release/2.6 r=dsavitskiy a=dsavitskiy * Updating to the SPDK with the fix * A test for many parallel rebuilds added Co-authored-by: Dmitry Savitskiy <dmitry.savitskiy@datacore.com>
2 parents a57c48e + 651e86c commit fbaee6a

File tree

2 files changed

+210
-3
lines changed

2 files changed

+210
-3
lines changed
+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
pub mod common;
2+
3+
use std::time::{Duration, Instant};
4+
5+
use common::{
6+
compose::{
7+
rpc::v1::{nexus::ChildState, GrpcConnect, Status},
8+
Binary,
9+
Builder,
10+
},
11+
nexus::NexusBuilder,
12+
pool::PoolBuilder,
13+
replica::ReplicaBuilder,
14+
};
15+
use tonic::Code;
16+
17+
struct Volume {
18+
replicas: Vec<ReplicaBuilder>,
19+
nex: NexusBuilder,
20+
}
21+
22+
/// Runs multiple rebuild jobs parallel.
23+
#[tokio::test]
24+
async fn nexus_rebuild_parallel() {
25+
common::composer_init();
26+
27+
const R: usize = 3; // Number of replicas / nodes.
28+
const N: usize = 20; // Number f volumes
29+
const REPL_SIZE: u64 = 50;
30+
const NEXUS_SIZE: u64 = REPL_SIZE;
31+
const POOL_SIZE: u64 = REPL_SIZE * N as u64 + REPL_SIZE;
32+
const DISK_SIZE: u64 = POOL_SIZE * 1024 * 1024;
33+
const DISK_NAME: &str = "disk";
34+
35+
// Create pool data file.
36+
for r in 0 .. R {
37+
let name = format!("/tmp/{DISK_NAME}_{r}");
38+
common::delete_file(&[name.clone()]);
39+
common::truncate_file_bytes(&name, DISK_SIZE);
40+
}
41+
42+
let test = Builder::new()
43+
.name("cargo-test")
44+
.network("10.1.0.0/16")
45+
.unwrap()
46+
.add_container_bin(
47+
"ms_0",
48+
Binary::from_dbg("io-engine")
49+
.with_args(vec!["-l", "1,2", "-Fcolor,compact,nodate,host"])
50+
.with_bind("/tmp", "/host/tmp"),
51+
)
52+
.add_container_bin(
53+
"ms_1",
54+
Binary::from_dbg("io-engine")
55+
.with_args(vec!["-l", "3,4", "-Fcolor,compact,nodate,host"])
56+
.with_bind("/tmp", "/host/tmp"),
57+
)
58+
.add_container_bin(
59+
"ms_2",
60+
Binary::from_dbg("io-engine")
61+
.with_args(vec!["-l", "5,6", "-Fcolor,compact,nodate,host"])
62+
.with_bind("/tmp", "/host/tmp"),
63+
)
64+
.with_clean(true)
65+
.build()
66+
.await
67+
.unwrap();
68+
69+
let conn = GrpcConnect::new(&test);
70+
71+
let ms_nex = conn.grpc_handle_shared("ms_2").await.unwrap();
72+
73+
let ms = [
74+
conn.grpc_handle_shared("ms_0").await.unwrap(),
75+
conn.grpc_handle_shared("ms_1").await.unwrap(),
76+
conn.grpc_handle_shared("ms_2").await.unwrap(),
77+
];
78+
79+
let mut pools = Vec::new();
80+
81+
// Create pools.
82+
for (r, ms) in ms.iter().enumerate() {
83+
let bdev = format!("aio:///host/tmp/{DISK_NAME}_{r}?blk_size=512");
84+
let mut pool = PoolBuilder::new(ms.clone())
85+
.with_name(&format!("p{r}"))
86+
.with_new_uuid()
87+
.with_bdev(&bdev);
88+
pool.create().await.unwrap();
89+
pools.push(pool);
90+
}
91+
92+
let mut vols = Vec::new();
93+
94+
for i in 0 .. N {
95+
// Create R replicas on the pools.
96+
let mut replicas = Vec::new();
97+
for r in 0 .. R {
98+
let mut repl = ReplicaBuilder::new(ms[r].clone())
99+
.with_pool(&pools[r])
100+
.with_name(&format!("v{i}r{r}"))
101+
.with_new_uuid()
102+
.with_size_mb(REPL_SIZE)
103+
.with_thin(false);
104+
repl.create().await.unwrap();
105+
repl.share().await.unwrap();
106+
replicas.push(repl);
107+
}
108+
109+
// Create the nexus with 2 replicas @ 1,2.
110+
let mut nex = NexusBuilder::new(ms_nex.clone())
111+
.with_name(&format!("v{i}"))
112+
.with_new_uuid()
113+
.with_size_mb(NEXUS_SIZE)
114+
.with_replica(&replicas[1])
115+
.with_replica(&replicas[2]);
116+
117+
nex.create().await.unwrap();
118+
119+
vols.push(Volume {
120+
replicas,
121+
nex,
122+
});
123+
}
124+
125+
// Adding replicas / starting rebuilds.
126+
for vol in &vols {
127+
vol.nex.add_replica(&vol.replicas[0], false).await.unwrap();
128+
}
129+
130+
monitor_volumes(&vols, Duration::from_secs(30))
131+
.await
132+
.expect("All volumes must go online");
133+
134+
// Delete test files.
135+
for r in 0 .. R {
136+
let name = format!("/tmp/{DISK_NAME}_{r}");
137+
common::delete_file(&[name.clone()]);
138+
}
139+
}
140+
141+
/// Monitors and prints volume states.
142+
async fn monitor_volumes(
143+
vols: &Vec<Volume>,
144+
timeout: Duration,
145+
) -> Result<(), Status> {
146+
println!("\nMonitoring {n} volumes", n = vols.len());
147+
148+
let start = Instant::now();
149+
150+
loop {
151+
let mut vols_degraded = false;
152+
let mut vols_failed = false;
153+
154+
for vol in vols {
155+
let mut s = String::new();
156+
157+
let n = vol.nex.get_nexus().await.unwrap();
158+
for c in n.children.iter() {
159+
match c.state() {
160+
ChildState::Faulted => {
161+
s = format!("{s} FAILED | ");
162+
vols_failed = true;
163+
}
164+
ChildState::Online => {
165+
s = format!("{s} ONLINE | ");
166+
}
167+
ChildState::Unknown => {
168+
s = format!("{s} UNKNOWN | ");
169+
vols_degraded = true;
170+
}
171+
ChildState::Degraded => {
172+
s = format!(
173+
"{s} REBUILD {p:02} | ",
174+
p = c.rebuild_progress
175+
);
176+
vols_degraded = true;
177+
}
178+
}
179+
}
180+
181+
println!(" {n}: {s}", n = n.name)
182+
}
183+
println!("-");
184+
185+
if vols_failed {
186+
println!("One or more volumes failed");
187+
return Err(Status::new(
188+
Code::Internal,
189+
"One or more volumes failed".to_string(),
190+
));
191+
}
192+
193+
if !vols_degraded {
194+
println!("All volumes are online");
195+
return Ok(());
196+
}
197+
198+
if start.elapsed() > timeout {
199+
return Err(Status::new(
200+
Code::Cancelled,
201+
"Waiting for volumes to go Online state timed out".to_string(),
202+
));
203+
}
204+
205+
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
206+
}
207+
}

nix/pkgs/libspdk/default.nix

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ let
5656
# 7. Copy SHA256 from 'got' of the error message to 'sha256' field.
5757
# 8. 'nix-shell' build must now succeed.
5858
drvAttrs = rec {
59-
version = "23.05-c210d86";
59+
version = "23.05-e051030";
6060

6161
src = fetchFromGitHub {
6262
owner = "openebs";
6363
repo = "spdk";
64-
rev = "c210d8650a2fcb44d3a83bb4df2b9bebbb20f833";
65-
sha256 = "sha256-6LJquwT6WOPv/GK9IFkCjOdx17488vTK0Fy1f+rSOJU=";
64+
rev = "e0510300f2c5b005a9ab32f0ab42740ac65b23ca";
65+
sha256 = "sha256-pGeIiCjndKf82BVHIYhn6lXL2fNmKhjX11W7K9GqFvs=";
6666
fetchSubmodules = true;
6767
};
6868

0 commit comments

Comments
 (0)