Skip to content

Commit

Permalink
track phantom disk undelete errors too
Browse files Browse the repository at this point in the history
add more logging to phantom disk background task
  • Loading branch information
jmpesp committed Dec 1, 2023
1 parent 6e0827c commit 1c4b61e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
15 changes: 11 additions & 4 deletions dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,11 @@ fn print_task_details(bgtask: &BackgroundTask, details: &serde_json::Value) {
} else if name == "phantom_disks" {
#[derive(Deserialize)]
struct TaskSuccess {
/// how many phantom disks were found
disk_count: usize,
/// how many phantom disks were deleted ok
phantom_disk_deleted_ok: usize,

/// how many phantom disks could not be deleted
phantom_disk_deleted_err: usize,
}

match serde_json::from_value::<TaskSuccess>(details.clone()) {
Expand All @@ -529,8 +532,12 @@ fn print_task_details(bgtask: &BackgroundTask, details: &serde_json::Value) {
),
Ok(success) => {
println!(
" number of phantom disks found: {}",
success.disk_count
" number of phantom disks deleted: {}",
success.phantom_disk_deleted_ok
);
println!(
" number of phantom disk delete errors: {}",
success.phantom_disk_deleted_err
);
}
};
Expand Down
25 changes: 21 additions & 4 deletions nexus/src/app/background/phantom_disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,25 @@ impl BackgroundTask for PhantomDiskDetector {
{
async {
let log = &opctx.log;
warn!(&log, "phantom disk task started");

let phantom_disks = match self.datastore.find_phantom_disks().await
{
Ok(phantom_disks) => phantom_disks,
Err(e) => {
warn!(&log, "error from find_phantom_disks: {:?}", e);
return json!({
"error":
format!("failed find_phantom_disks: {:#}", e)
});
}
};

let rv = phantom_disks.len();
let mut phantom_disk_deleted_ok = 0;
let mut phantom_disk_deleted_err = 0;

for disk in phantom_disks {
warn!(&log, "phantom disk {} found!", disk.id(),);
warn!(&log, "phantom disk {} found!", disk.id());

// If a phantom disk is found, then un-delete it and set it to
// faulted: this will allow a user to request deleting it again.
Expand All @@ -75,12 +78,26 @@ impl BackgroundTask for PhantomDiskDetector {
if let Err(e) = result {
error!(
&log,
"error undeleting disk and setting to faulted: {:#}", e
"error un-deleting disk {} and setting to faulted: {:#}",
disk.id(),
e,
);
phantom_disk_deleted_err += 1;
} else {
info!(
&log,
"phandom disk {} un-deleted andset to faulted ok",
disk.id(),
);
phantom_disk_deleted_ok += 1;
}
}

json!({ "ok": rv })
warn!(&log, "phantom disk task done");
json!({
"phantom_disk_deleted_ok": phantom_disk_deleted_ok,
"phantom_disk_deleted_err": phantom_disk_deleted_err,
})
}
.boxed()
}
Expand Down

0 comments on commit 1c4b61e

Please sign in to comment.