k8s-cleaner should display the volume iqn for context alongside the id

The volume id listed in the output for k8s-csi-cleaner is opaque, so when it's prompting for delete it's not clear what the volume is.

We can also display the iqn alongside, which should give some indication of what the volume label is, which will be useful context.
This commit is contained in:
Andrew Rowson 2024-01-03 17:28:56 +00:00 committed by GitHub
parent 79f16a0cf6
commit 1e2ca16632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -127,6 +127,7 @@ async function main() {
for (let csiVolume of csiVolumes) { for (let csiVolume of csiVolumes) {
let volume_id = csiVolume.volume.volume_id; let volume_id = csiVolume.volume.volume_id;
let volume_iqn = csiVolume.volume.volume_context.iqn || "Unknown";
//console.log(`processing csi volume ${volume_id}`); //console.log(`processing csi volume ${volume_id}`);
let k8sVolume = k8sVolumes.find((i_k8sVolume) => { let k8sVolume = k8sVolumes.find((i_k8sVolume) => {
let volume_handle = _.get(i_k8sVolume, "spec.csi.volumeHandle", null); let volume_handle = _.get(i_k8sVolume, "spec.csi.volumeHandle", null);
@ -134,7 +135,7 @@ async function main() {
}); });
if (!k8sVolume) { if (!k8sVolume) {
console.log(`volume ${volume_id} is NOT in k8s`); console.log(`volume ${volume_id} (${volume_iqn}) is NOT in k8s`);
if (process.env.DRY_RUN == "1") { if (process.env.DRY_RUN == "1") {
continue; continue;
} }
@ -159,7 +160,7 @@ async function main() {
console.log(`skipping delete of csi volume ${volume_id}`); console.log(`skipping delete of csi volume ${volume_id}`);
} }
} else { } else {
console.log(`volume ${volume_id} is in k8s`); console.log(`volume ${volume_id} (${volume_iqn}) is in k8s`);
} }
} }