Skip to content

Commit

Permalink
* Changed display layer for new "pvc storage-space-free checker" feat…
Browse files Browse the repository at this point in the history
…ure 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)
  • Loading branch information
Venryx committed Jul 7, 2024
1 parent 8907051 commit f50a95f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Packages/monitor-backend/src/gql/_general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ==========
Expand Down Expand Up @@ -498,4 +498,4 @@ impl SubscriptionShard_General {
}
}

// }
}
24 changes: 14 additions & 10 deletions Packages/monitor-client/Source/UI/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -175,8 +179,8 @@ const SettingsUI = observer(()=>{ // todo: replace with "observer_mgl", if it wo
<Row>
<Text>Persistent Volume Claim: <span style={{
marginLeft: 5,
color: sddHealthColor,
}}>{formatBytes(sddHealth.used)} / {formatBytes(sddHealth.available)} ({sddHealth.usePercent}%)</span></Text>
color: storageHealthColor,
}}>{formatBytes(storageHealth.used)} / {formatBytes(storageHealth.available)} ({storageHealth.usePercent}%)</span></Text>
</Row>
</Column>
</Column>
Expand Down

0 comments on commit f50a95f

Please sign in to comment.