Skip to content

Commit bae48d8

Browse files
committed
fix(sdk): Log full resource on cleanup failure
Log the discovered resource body when a cleanup delete fails and dump failed resources in the functional test assertion. Resources are gone by the time CI output is read, so device_owner and similar details were not recoverable when e.g. a port delete was denied by policy. Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
1 parent bdcaca2 commit bae48d8

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎openstack_sdk/src/cleanup/engine.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ impl<'a> ProjectCleanup<'a> {
307307
result.deleted_ids.push(resource.id.clone());
308308
}
309309
Err(e) => {
310+
// Log the full resource body: the failure message
311+
// alone rarely says why (e.g. which `device_owner`
312+
// a policy-denied port had), and the resource is
313+
// usually gone by the time anyone investigates.
314+
tracing::warn!(
315+
kind = ?resource.kind,
316+
id = %resource.id,
317+
reason = ?resource.reason,
318+
raw = %resource.raw,
319+
error = %e,
320+
"cleanup delete failed"
321+
);
310322
result.errors.push((resource.id.clone(), e.to_string()));
311323
for &parent_idx in &blocks_parents_of[idx] {
312324
blocked[parent_idx] = true;

‎openstack_sdk/tests/cleanup/full_scenario.rs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,20 @@ async fn cleanup_engine_removes_related_resources_across_all_services()
193193
.discover(std::collections::HashMap::new(), Some(eval))
194194
.await
195195
.expect("discover failed");
196+
let planned_nodes = plan.nodes.clone();
196197
let result = cleanup.apply(plan).await.expect("apply failed");
197198

199+
// Resources are gone by the time CI output is read, so dump the full
200+
// body of every resource that failed to delete.
201+
let failed_resources: Vec<_> = planned_nodes
202+
.iter()
203+
.filter(|n| result.errors.iter().any(|(id, _)| id == &n.id))
204+
.collect();
198205
assert!(
199206
result.errors.is_empty(),
200-
"unexpected cleanup errors: {:?}",
201-
result.errors
207+
"unexpected cleanup errors: {:?}\nfailed resources: {:#?}",
208+
result.errors,
209+
failed_resources
202210
);
203211

204212
for id in [

0 commit comments

Comments
 (0)