Skip to content

Commit 94fbb17

Browse files
upd logging
1 parent b1e11d7 commit 94fbb17

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ async fn reconcile_recovery(
242242
.unwrap();
243243

244244
let bundle = storage::deserialize_storage_bundle(file.clone())?;
245+
storage::print_bundle_names(&bundle);
245246

246247
// Generate the OwnerReference once outside the loops
247248
let owner_ref = cr.controller_owner_ref(&()).expect("CR must have metadata");
@@ -256,6 +257,7 @@ async fn reconcile_recovery(
256257

257258
// Patch Owner Reference (for automatic cleanup)
258259
sanitized.metadata.owner_references = Some(vec![owner_ref.clone()]);
260+
259261
// Ensure the data is never deleted from the physical share
260262
if let Some(spec) = sanitized.spec.as_mut() {
261263
// Force the policy to Retain to prevent accidental deletion of share data

src/storage.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,35 @@ pub async fn cleanup_old_objects(cr: &PersistentVolumeSync) -> anyhow::Result<()
229229
Ok(())
230230
}
231231

232+
pub fn print_bundle_names(bundle: &StorageObjectBundle) {
233+
// 1. Collect and log PV names on one line
234+
let pv_names: Vec<String> = bundle.persistent_volumes
235+
.iter()
236+
.map(|pv| pv.metadata.name.as_deref().unwrap_or("unknown").to_string())
237+
.collect();
238+
239+
info!(
240+
"Total PVs ({}): [{}]",
241+
pv_names.len(),
242+
pv_names.join(", ")
243+
);
244+
245+
// 2. Collect and log PVC names on one line
246+
let pvc_names: Vec<String> = bundle.persistent_volume_claims
247+
.iter()
248+
.map(|pvc| {
249+
let ns = pvc.metadata.namespace.as_deref().unwrap_or("unknown");
250+
format!("{}/{}", ns, pvc.metadata.name.as_deref().unwrap_or("unknown").to_string()) // Format as namespace/name
251+
})
252+
.collect();
253+
254+
info!(
255+
"Total PVCs ({}): [{}]",
256+
pvc_names.len(),
257+
pvc_names.join(", ")
258+
);
259+
}
260+
232261
// --- Dummy Data for Testing ---
233262
pub fn dummy_storage_bundle() -> StorageObjectBundle {
234263
let mut bundle = StorageObjectBundle::new();

0 commit comments

Comments
 (0)