fix: checks deployment status ready replicas rather than pod name since the pod name is not necessarily matching the deployment name and often has a random generated number in it

This commit is contained in:
Willem 2025-08-15 15:44:06 -04:00
parent b43ca7c740
commit d1a274b705
2 changed files with 26 additions and 7 deletions

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> { pub async fn get_pod(&self, name: &str, namespace: Option<&str>) -> Result<Option<Pod>, Error> {
let pods: Api<Pod> = if let Some(ns) = namespace { let pods: Api<Pod> = if let Some(ns) = namespace {
Api::namespaced(self.client.clone(), ns) Api::namespaced(self.client.clone(), ns)

View File

@ -50,13 +50,21 @@ impl<T: Topology + K8sclient> Interpret<T> for PrepCephOsdReplacementInterpret {
0, 0,
) )
.await?; .await?;
client let dep = client
.get_pod(&self.score.osd_name, Some(&self.score.rook_ceph_namespace)) .get_deployment(&self.score.osd_name, Some(&self.score.rook_ceph_namespace))
.await?; .await?;
Ok(Outcome::success( match dep.unwrap().status.and_then(|s| s.ready_replicas) {
"Successfully prepared rook-ceph-cluster for disk replacement".to_string(), 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 { fn get_name(&self) -> InterpretName {
@ -75,5 +83,3 @@ impl<T: Topology + K8sclient> Interpret<T> for PrepCephOsdReplacementInterpret {
todo!() todo!()
} }
} }
impl PrepCephOsdReplacementInterpret {}