Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Don't assume ldiskfs
Browse files Browse the repository at this point in the history
Signed-off-by: johnsonw <[email protected]>
  • Loading branch information
johnsonw committed Oct 27, 2020
1 parent 37cdf34 commit 724e50e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 109 deletions.
50 changes: 25 additions & 25 deletions iml-agent/src/action_plugins/ldev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,161 +70,161 @@ mod tests {
failover: Some("mds2".into()),
label: "MGS".into(),
device: "zfs:mdt0/mdt0".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "mds1".into(),
failover: Some("mds2".into()),
label: "zfsmo-MDT0000".into(),
device: "zfs:mdt0/mdt0".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "mds2".into(),
failover: Some("mds1".into()),
label: "zfsmo-MDT0001".into(),
device: "zfs:mdt1/mdt1".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0000".into(),
device: "zfs:ost0/ost0".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0001".into(),
device: "zfs:ost1/ost1".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0002".into(),
device: "zfs:ost2/ost2".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0003".into(),
device: "zfs:ost3/ost3".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0004".into(),
device: "zfs:ost4/ost4".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0005".into(),
device: "zfs:ost5/ost5".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0006".into(),
device: "zfs:ost6/ost6".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0007".into(),
device: "zfs:ost7/ost7".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0008".into(),
device: "zfs:ost8/ost8".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss1".into(),
failover: Some("oss2".into()),
label: "zfsmo-OST0009".into(),
device: "zfs:ost9/ost9".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000a".into(),
device: "zfs:ost10/ost10".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000b".into(),
device: "zfs:ost11/ost11".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000c".into(),
device: "zfs:ost12/ost12".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000d".into(),
device: "zfs:ost13/ost13".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000e".into(),
device: "zfs:ost14/ost14".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST000f".into(),
device: "zfs:ost15/ost15".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST0010".into(),
device: "zfs:ost16/ost16".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST00011".into(),
device: "zfs:ost17/ost17".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST00012".into(),
device: "zfs:ost18/ost18".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "oss2".into(),
failover: Some("oss1".into()),
label: "zfsmo-OST00013".into(),
device: "zfs:ost19/ost19".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
]
.into_iter()
Expand All @@ -244,14 +244,14 @@ mod tests {
failover: None,
label: "MGS".into(),
device: "zfs:mdt0/mdt0".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
LdevEntry {
primary: "mds1".into(),
failover: Some("mds2".into()),
label: "zfsmo-MDT0000".into(),
device: "zfs:mdt0/mdt0".into(),
fs_type: FsType::Zfs,
fs_type: Some(FsType::Zfs),
},
]
.into_iter()
Expand Down
10 changes: 6 additions & 4 deletions iml-services/iml-device/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use iml_tracing::tracing;
use iml_wire_types::{Fqdn, FsType};
use std::{
collections::{BTreeMap, BTreeSet, HashMap},
convert::TryFrom,
sync::Arc,
};

Expand Down Expand Up @@ -75,7 +76,7 @@ pub async fn create_target_cache(pool: &PgPool) -> Result<Vec<Target>, ImlDevice
uuid: x.uuid,
mount_path: x.mount_path,
dev_path: x.dev_path,
fs_type: x.fs_type.map(|x| x.into()),
fs_type: x.fs_type.map(|x| FsType::try_from(x).ok()).flatten(),
}
})
.try_collect()
Expand Down Expand Up @@ -464,9 +465,10 @@ pub fn find_targets<'a>(
name: target.into(),
uuid: fs_uuid.into(),
mount_path: Some(mntpnt.0.to_string_lossy().to_string()),
fs_type: match osd.contains("zfs") {
true => Some("zfs".into()),
false => Some("ldiskfs".into()),
fs_type: match osd {
osd if osd.contains("zfs") => Some(FsType::Zfs),
osd if osd.contains("ldiskfs") => Some(FsType::Ldiskfs),
_ => None,
},
},
)
Expand Down
40 changes: 24 additions & 16 deletions iml-wire-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,19 +2020,23 @@ pub enum FsType {
Ldiskfs,
}

impl From<&str> for FsType {
fn from(x: &str) -> Self {
impl TryFrom<&str> for FsType {
type Error = &'static str;

fn try_from(x: &str) -> Result<Self, Self::Error> {
match x {
"ldiskfs" => Self::Ldiskfs,
"zfs" => Self::Zfs,
_ => Self::Ldiskfs,
"ldiskfs" => Ok(Self::Ldiskfs),
"zfs" => Ok(Self::Zfs),
_ => Err("Invalid fs type."),
}
}
}

impl From<String> for FsType {
fn from(x: String) -> Self {
Self::from(x.as_str())
impl TryFrom<String> for FsType {
type Error = &'static str;

fn try_from(x: String) -> Result<Self, Self::Error> {
Self::try_from(x.as_str())
}
}

Expand All @@ -2053,7 +2057,7 @@ pub struct LdevEntry {
pub failover: Option<String>,
pub label: String,
pub device: String,
pub fs_type: FsType,
pub fs_type: Option<FsType>,
}

impl From<&str> for LdevEntry {
Expand All @@ -2077,11 +2081,13 @@ impl From<&str> for LdevEntry {
),
label: (*parts.get(2).expect("LdevEntry must specify a label.")).to_string(),
device: (*parts.get(3).expect("LdevEntry must specify a device.")).to_string(),
fs_type: (*parts.get(3).expect("LdevEntry must specify a device."))
.split(':')
.next()
.unwrap_or_else(|| "ldiskfs")
.into(),
fs_type: FsType::try_from(
(*parts.get(3).expect("LdevEntry must specify a device."))
.split(':')
.next()
.expect("get fs_type"),
)
.ok(),
}
}
}
Expand All @@ -2090,10 +2096,12 @@ impl fmt::Display for LdevEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let device = if self.device.starts_with("zfs:") || self.device.starts_with("ldiskfs:") {
self.device.to_string()
} else if self.fs_type == FsType::Zfs {
} else if self.fs_type == Some(FsType::Zfs) {
format!("zfs:{}", self.device)
} else {
} else if self.fs_type == Some(FsType::Ldiskfs) {
format!("ldiskfs:{}", self.device)
} else {
self.device.to_string()
};

write!(
Expand Down
64 changes: 0 additions & 64 deletions sqlx-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3060,70 +3060,6 @@
]
}
},
"a36f75c883918331f080025b809fb0d2ebf00ef9a4c40d5cdb5e6e960c3f7c58": {
"query": "\n SELECT * from target t\n ORDER BY\n CASE WHEN $3 = 'ASC' THEN t.name END ASC,\n CASE WHEN $3 = 'DESC' THEN t.name END DESC\n OFFSET $1 LIMIT $2",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "state",
"type_info": "Text"
},
{
"ordinal": 1,
"name": "name",
"type_info": "Text"
},
{
"ordinal": 2,
"name": "active_host_id",
"type_info": "Int4"
},
{
"ordinal": 3,
"name": "host_ids",
"type_info": "Int4Array"
},
{
"ordinal": 4,
"name": "filesystems",
"type_info": "TextArray"
},
{
"ordinal": 5,
"name": "uuid",
"type_info": "Text"
},
{
"ordinal": 6,
"name": "mount_path",
"type_info": "Text"
},
{
"ordinal": 7,
"name": "dev_path",
"type_info": "Text"
}
],
"parameters": {
"Left": [
"Int8",
"Int8",
"Text"
]
},
"nullable": [
false,
false,
true,
false,
false,
false,
true,
true
]
}
},
"a8110847776ee7220577529cf0e395fe9ef3d72fa113924a08ef4a1c44664f82": {
"query": "\n SELECT\n c.id AS id,\n cancelled,\n complete,\n errored,\n created_at,\n array_agg(cj.job_id)::INT[] AS job_ids,\n message\n FROM chroma_core_command c\n JOIN chroma_core_command_jobs cj ON c.id = cj.command_id\n WHERE ($4::BOOL IS NULL OR complete = $4)\n AND ($5::TEXT IS NULL OR c.message ILIKE '%' || $5 || '%')\n GROUP BY c.id\n ORDER BY\n CASE WHEN $3 = 'ASC' THEN c.id END ASC,\n CASE WHEN $3 = 'DESC' THEN c.id END DESC\n OFFSET $1 LIMIT $2\n ",
"describe": {
Expand Down

0 comments on commit 724e50e

Please sign in to comment.