feat/ceph-osd-score #116

Merged
wjro merged 4 commits from feat/ceph-osd-score into master 2025-08-20 18:19:48 +00:00
2 changed files with 26 additions and 7 deletions
Showing only changes of commit d1a274b705 - Show all commits

View File

@ -52,6 +52,19 @@ impl K8sClient {
})
}
pub async fn get_deployment(
&self,
name: &str,
namespace: Option<&str>,
) -> Result<Option<Deployment>, Error> {
let deps: Api<Deployment> = if let Some(ns) = namespace {
Api::namespaced(self.client.clone(), ns)
} else {
Api::default_namespaced(self.client.clone())
};
Ok(deps.get_opt(name).await?)
}
pub async fn get_pod(&self, name: &str, namespace: Option<&str>) -> Result<Option<Pod>, Error> {
let pods: Api<Pod> = if let Some(ns) = namespace {
Api::namespaced(self.client.clone(), ns)

View File

@ -50,13 +50,21 @@ impl<T: Topology + K8sclient> Interpret<T> for PrepCephOsdReplacementInterpret {
0,
)
.await?;
Review

Nice, super lisible.

Eventuellement plusieurs de ces helper functions pourront aller dans un module ceph management ou quelque chose comme ca.

Nice, super lisible. Eventuellement plusieurs de ces helper functions pourront aller dans un module ceph management ou quelque chose comme ca.
client
.get_pod(&self.score.osd_name, Some(&self.score.rook_ceph_namespace))
let dep = client
.get_deployment(&self.score.osd_name, Some(&self.score.rook_ceph_namespace))
.await?;
Ok(Outcome::success(
"Successfully prepared rook-ceph-cluster for disk replacement".to_string(),
))
match dep.unwrap().status.and_then(|s| s.ready_replicas) {
Some(0) => Ok(Outcome::success(
"Successfully prepared rook-ceph-cluster for disk replacement".to_string(),
)),
Some(_) => Err(InterpretError::new({
"Deployment still has ready replicas".to_string()
})),
None => Err(InterpretError::new({
"Failed to get rook-ceph-cluster status".to_string()
})),
}
}
fn get_name(&self) -> InterpretName {
@ -75,5 +83,3 @@ impl<T: Topology + K8sclient> Interpret<T> for PrepCephOsdReplacementInterpret {
todo!()
}
}
impl PrepCephOsdReplacementInterpret {}