Compare commits

...

1 Commits

Author SHA1 Message Date
82d1f87ff8 fix: stop swallowing non-404 errors in ResourceBundle::delete
Previously all errors were silently discarded when deleting bundle
resources. Now only 404 (Not Found) is ignored; other errors propagate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 00:09:28 -04:00

View File

@@ -52,7 +52,7 @@
//! }
//! ```
use kube::{Error, Resource, ResourceExt, api::DynamicObject};
use kube::{Error, Resource, ResourceExt, api::DynamicObject, core::ErrorResponse};
use serde::Serialize;
use serde_json;
@@ -117,16 +117,13 @@ impl ResourceBundle {
/// Delete all resources in this bundle from the cluster.
/// Resources are deleted in reverse order to respect dependencies.
pub async fn delete(&self, client: &K8sClient) -> Result<(), Error> {
// FIXME delete all in parallel and retry using kube::client::retry::RetryPolicy
for res in self.resources.iter().rev() {
let api = client.get_api_for_dynamic_object(res, res.namespace().as_deref())?;
let name = res.name_any();
// FIXME this swallows all errors. Swallowing a 404 is ok but other errors must be
// handled properly (such as retrying). A normal error case is when we delete a
// resource bundle with dependencies between various resources. Such as a pod with a
// dependency on a ClusterRoleBinding. Trying to delete the ClusterRoleBinding first
// is expected to fail
let _ = api.delete(&name, &kube::api::DeleteParams::default()).await;
match api.delete(&name, &kube::api::DeleteParams::default()).await {
Ok(_) | Err(Error::Api(ErrorResponse { code: 404, .. })) => {}
Err(e) => return Err(e),
}
}
Ok(())
}