Improve Cluster Dashboard Timeline #1
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
define('APP_NAME', 'hyprcrd');
|
||||
define('APP_VERSION', '2.0.14');
|
||||
define('APP_VERSION', '2.0.15');
|
||||
|
||||
// APP_DEBUG: gates verbose error responses (curl traces, upstream bodies).
|
||||
// Off by default; enable via env for local troubleshooting only.
|
||||
|
||||
@@ -290,6 +290,26 @@ function dominantSev(events) {
|
||||
return best || 'info';
|
||||
}
|
||||
|
||||
/** Scan the cluster (events are newest-first) for the most recent state
|
||||
* transition and map it to a dot severity. This reflects how the
|
||||
* workload ended up after the cluster, not the worst thing that
|
||||
* happened inside it — so a cluster that ends in "-> healthy" shows a
|
||||
* green dot even if it contains degraded/warning events along the way.
|
||||
* Returns null when no state-change event is present; callers fall
|
||||
* back to dominantSev in that case (e.g. rollout-only clusters). */
|
||||
function clusterOutcomeSev(events) {
|
||||
for (const e of events) {
|
||||
const m = /->\s*(\w+)\s*$/.exec(e.message || '');
|
||||
if (!m) continue;
|
||||
switch (m[1]) {
|
||||
case 'healthy': return 'recovered';
|
||||
case 'degraded': return 'warning';
|
||||
case 'unavailable': return 'error';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function sameDay(a, b) {
|
||||
const da = new Date(a), db = new Date(b);
|
||||
return da.getFullYear() === db.getFullYear()
|
||||
@@ -336,7 +356,7 @@ function renderTimeline() {
|
||||
|
||||
let lastDate = null;
|
||||
body.innerHTML = clusters.map(cluster => {
|
||||
const sev = dominantSev(cluster.events);
|
||||
const sev = clusterOutcomeSev(cluster.events) || dominantSev(cluster.events);
|
||||
const showDate = !lastDate || !sameDay(lastDate, cluster.ts);
|
||||
lastDate = cluster.ts;
|
||||
const d = new Date(cluster.ts);
|
||||
|
||||
Reference in new issue
Block a user