Skip to content

Commit 753de5f

Browse files
chore: allow passing flag to disable check
Signed-off-by: Abhinandan Purkait <[email protected]>
1 parent cf01401 commit 753de5f

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

control-plane/agents/src/bin/core/tests/pool/mod.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ async fn slow_create() {
10591059
{
10601060
let cluster = ClusterBuilder::builder()
10611061
.with_io_engines(1)
1062+
.with_allow_non_persistent_devlink(true)
10621063
.with_reconcile_period(Duration::from_millis(250), Duration::from_millis(250))
10631064
.with_cache_period("200ms")
10641065
.with_options(|o| o.with_io_engine_devices(vec![lvol.path()]))
@@ -1176,6 +1177,7 @@ async fn reject_devlink_reuse() {
11761177
.await
11771178
.expect("Failed to build cluster");
11781179

1180+
let dev_path = lvol.path();
11791181
let client = cluster.grpc_client();
11801182

11811183
let bds = client
@@ -1191,17 +1193,29 @@ async fn reject_devlink_reuse() {
11911193
.expect("Failed to get block devices")
11921194
.into_inner();
11931195

1194-
let dev_path = lvol.path();
11951196
let matched_device = bds
11961197
.iter()
11971198
.find(|bd| {
1198-
bd.devlinks.iter().any(|link| link == &dev_path.to_string())
1199-
|| bd.devname == dev_path
1200-
|| bd.devpath == dev_path
1199+
let dev_path_str = dev_path.to_string();
1200+
bd.devname == dev_path_str
1201+
|| bd.devpath == dev_path_str
1202+
|| bd.devlinks.iter().any(|link| link == &dev_path_str)
12011203
})
12021204
.expect("Block device should exist");
12031205

1204-
let device_devlinks = &matched_device.devlinks;
1206+
let device_devlinks: Vec<&str> = matched_device
1207+
.devlinks
1208+
.iter()
1209+
.filter_map(|link| link.strip_prefix("/dev/disk/by-"))
1210+
.map(|s| {
1211+
&matched_device
1212+
.devlinks
1213+
.iter()
1214+
.find(|l| l.ends_with(s))
1215+
.unwrap()[..]
1216+
})
1217+
.collect();
1218+
12051219
assert!(
12061220
device_devlinks.len() >= 2,
12071221
"Expected at least 2 devlinks, found {}",
@@ -1214,6 +1228,7 @@ async fn reject_devlink_reuse() {
12141228
disks: vec![device_devlinks
12151229
.first()
12161230
.expect("At least one devlink should be present")
1231+
.to_string()
12171232
.into()],
12181233
labels: None,
12191234
encryption: Some(Encryption::Secret(EncryptionSecret {
@@ -1233,6 +1248,7 @@ async fn reject_devlink_reuse() {
12331248
disks: vec![device_devlinks
12341249
.get(1)
12351250
.expect("Another devlink should be present")
1251+
.to_string()
12361252
.into()],
12371253
labels: None,
12381254
encryption: Some(Encryption::Secret(EncryptionSecret {

deployer/src/infra/agents/core.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ impl ComponentAction for CoreAgent {
7171
if let Some(max_rebuilds) = &options.max_rebuilds {
7272
binary = binary.with_args(vec!["--max-rebuilds", &max_rebuilds.to_string()]);
7373
}
74+
if options.allow_non_persistent_devlink {
75+
binary = binary.with_args(vec!["--allow-non-persistent-devlink"]);
76+
}
7477
Ok(cfg.add_container_spec(
7578
ContainerSpec::from_binary(name, binary).with_portmap("50051", "50051"),
7679
))

deployer/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ pub struct StartOptions {
354354
/// Mount host dev and udev.
355355
#[clap(long)]
356356
mount_host_dev_udev: bool,
357+
/// Allow non persistent devlink for pool creation.
358+
#[clap(long)]
359+
allow_non_persistent_devlink: bool,
357360
}
358361

359362
/// List of KeyValues
@@ -607,6 +610,12 @@ impl StartOptions {
607610
self
608611
}
609612

613+
/// Specify whether allow non peristent devlink is needed or not.
614+
pub fn with_allow_non_persistent_devlink(mut self, enabled: bool) -> Self {
615+
self.allow_non_persistent_devlink = enabled;
616+
self
617+
}
618+
610619
pub(crate) fn app_nodes(&self) -> u32 {
611620
if self.csi_node {
612621
self.app_nodes.unwrap_or(1)

utils/deployer-cluster/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,11 @@ impl ClusterBuilder {
993993
self.opts = self.opts.with_mount_host_dev_udev(enabled);
994994
self
995995
}
996+
/// Specify whether allow non peristent devlink is needed or not.
997+
pub fn with_allow_non_persistent_devlink(mut self, enabled: bool) -> Self {
998+
self.opts = self.opts.with_allow_non_persistent_devlink(enabled);
999+
self
1000+
}
9961001
/// Build into the resulting Cluster using a composer closure, eg:
9971002
/// .compose_build(|c| c.with_logs(false)).
9981003
pub async fn compose_build<F>(mut self, set: F) -> Result<Cluster, Error>

0 commit comments

Comments
 (0)