From f50a95ff38d7f95f6329baee09ae19e9912d212e Mon Sep 17 00:00:00 2001 From: Venryx Date: Sun, 7 Jul 2024 14:41:41 -0700 Subject: [PATCH] * Changed display layer for new "pvc storage-space-free checker" feature to match based on the filesystem's "mounted on" path of "/pgdata", rather than the name of the filesystem. (the filesystem name apparently differs based on the k8s environment; in rancher-desktop no "/pgdata" entry exists however, so we now fallback to showing whichever filesystem has the higher usage-percent) --- Packages/monitor-backend/src/gql/_general.rs | 4 ++-- Packages/monitor-client/Source/UI/Home.tsx | 24 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Packages/monitor-backend/src/gql/_general.rs b/Packages/monitor-backend/src/gql/_general.rs index 64f3a545..9d61676b 100644 --- a/Packages/monitor-backend/src/gql/_general.rs +++ b/Packages/monitor-backend/src/gql/_general.rs @@ -49,7 +49,7 @@ pub fn ensure_admin_key_is_correct(admin_key: String, log_message_if_wrong: bool Ok(()) } -// wrap_slow_macros! { +wrap_slow_macros! { // queries // ========== @@ -498,4 +498,4 @@ impl SubscriptionShard_General { } } -// } +} diff --git a/Packages/monitor-client/Source/UI/Home.tsx b/Packages/monitor-client/Source/UI/Home.tsx index 42966bde..b77d8ad8 100644 --- a/Packages/monitor-client/Source/UI/Home.tsx +++ b/Packages/monitor-client/Source/UI/Home.tsx @@ -104,15 +104,19 @@ const SettingsUI = observer(()=>{ // todo: replace with "observer_mgl", if it wo }); const healthData: HealthStats[] = dataHealth?.healthStats ?? []; - const sddHealth = healthData.find(a=>a.filesystem == "/dev/sdd") ?? HealthStats.empty(); - - let sddHealthColor = ""; - if (sddHealth.usePercent >= 90) { - sddHealthColor = "#dc3545"; - } else if (sddHealth.usePercent >= 70) { - sddHealthColor = "#ffc107"; + const storageHealth = healthData.find(a=>a.mountedOn == "/pgdata") + // if no "/pgdata" filesystem was found, fallback to finding the stats for whichever filesystem has the most usage + // (for some reason, rancher desktop doesn't seem to mount a separate filesystem for the "/pgdata" directory; it must have some other "fake" filesystem implementation for K8s PVCs) + ?? healthData.OrderByDescending(a=>a.usePercent).FirstOrX() + ?? HealthStats.empty(); + + let storageHealthColor = ""; + if (storageHealth.usePercent >= 90) { + storageHealthColor = "#dc3545"; + } else if (storageHealth.usePercent >= 70) { + storageHealthColor = "#ffc107"; } else { - sddHealthColor = "#28a745"; + storageHealthColor = "#28a745"; } const [showKey, setShowKey] = useState(false); @@ -175,8 +179,8 @@ const SettingsUI = observer(()=>{ // todo: replace with "observer_mgl", if it wo Persistent Volume Claim: {formatBytes(sddHealth.used)} / {formatBytes(sddHealth.available)} ({sddHealth.usePercent}%) + color: storageHealthColor, + }}>{formatBytes(storageHealth.used)} / {formatBytes(storageHealth.available)} ({storageHealth.usePercent}%)