From 7b1968236d36cc47ae65523ec3b0b693abac0fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Thu, 31 Jul 2025 16:26:06 +0200 Subject: [PATCH 1/3] machine-status: Render new queue runner details --- src/lib/Hydra/Helper/Nix.pm | 8 ++++++ src/root/common.tt | 8 ++++++ src/root/machine-status.tt | 47 +++++++++++++++++++++++++++++++++-- src/root/static/css/hydra.css | 8 ++++++ 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 5150ec47..8d640f93 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -363,6 +363,14 @@ sub getMachines { , speedFactor => $machine->{speedFactor} , supportedFeatures => [ @{$machine->{supportedFeatures}}, @{$machine->{mandatoryFeatures}} ] , mandatoryFeatures => [ @{$machine->{mandatoryFeatures}} ] + # New fields for the machine status + , primarySystemType => $machine->{systems}[0] + , hasCapacity => $machine->{hasCapacity} + , hasDynamicCapacity => $machine->{hasDynamicCapacity} + , hasStaticCapacity => $machine->{hasStaticCapacity} + , score => $machine->{score} + , stats => $machine->{stats} + , memTotal => $machine->{totalMem} }; } } else { diff --git a/src/root/common.tt b/src/root/common.tt index 86335a74..7a93cc95 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -685,6 +685,14 @@ BLOCK includeFlot %] [% END; +BLOCK renderYesNo %] +[% IF value %] +Yes +[% ELSE %] +No +[% END %] +[% END; + BLOCK createChart %]
diff --git a/src/root/machine-status.tt b/src/root/machine-status.tt index 725598eb..924bdb52 100644 --- a/src/root/machine-status.tt +++ b/src/root/machine-status.tt @@ -19,10 +19,53 @@ [% INCLUDE renderMachineName machine=m.key %] - [% IF m.value.systemTypes %] + [% IF m.value.primarySystemType %] - ([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %][% system %][% END %]) + ([% m.value.primarySystemType %]) +   + [% WRAPPER makePopover title="Details" classes="btn-secondary btn-sm" %] + + [% END %] + [% ELSE %] + [% IF m.value.systemTypes %] + + ([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %][% system %][% END %]) + + [% END %] [% END %] [% IF m.value.nrStepsDone %] diff --git a/src/root/static/css/hydra.css b/src/root/static/css/hydra.css index b55f557a..3899e766 100644 --- a/src/root/static/css/hydra.css +++ b/src/root/static/css/hydra.css @@ -181,6 +181,14 @@ a.squiggle:hover { padding-bottom: 1px; } +table.pressureTable { + margin-left: 2em; +} + +table.pressureTable td { + padding: 0 .4em; +} + @media (prefers-color-scheme: dark) { /* Prevent some flickering */ html { From 632a59172a3c5111aac3810d54b71e0a4bd08bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Fri, 1 Aug 2025 11:25:14 +0200 Subject: [PATCH 2/3] machine-status: Make new runner status prettier - Remove bottom margin - Properly format memory in human format - Calculate free memory - Format the load with 2 digits after comma - Lpad pressure percentages - Use a macro to render pressure - Score -> Scheduling Score - More spacing in the load - Add IRQ pressure --- package.nix | 1 + src/lib/Hydra/Controller/Root.pm | 14 ++++++++++++ src/root/machine-status.tt | 37 +++++++++++++------------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/package.nix b/package.nix index 5c1a7860..22caf1da 100644 --- a/package.nix +++ b/package.nix @@ -110,6 +110,7 @@ let NetAmazonS3 NetPrometheus NetStatsd + NumberBytesHuman PadWalker ParallelForkManager PerlCriticCommunity diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index d78e1b6d..c4000d1c 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -9,6 +9,7 @@ use Hydra::Helper::CatalystUtils; use Hydra::View::TT; use Nix::Store; use Nix::Config; +use Number::Bytes::Human qw(format_bytes); use Encode; use File::Basename; use JSON::MaybeXS; @@ -215,6 +216,19 @@ sub machines :Local Args(0) { "where busy != 0 order by machine, stepnr", { Slice => {} }); $c->stash->{template} = 'machine-status.tt'; + $c->stash->{human_bytes} = sub { + my ($bytes) = @_; + return format_bytes($bytes, si => 1); + }; + $c->stash->{pretty_load} = sub { + my ($load) = @_; + return sprintf('%.2f', $load); + }; + $c->stash->{pretty_percent} = sub { + my ($percent) = @_; + my $ret = sprintf('%.2f', $percent); + return (' ' x (6 - length($ret))) . $ret; + }; $self->status_ok($c, entity => $c->stash->{machines}); } diff --git a/src/root/machine-status.tt b/src/root/machine-status.tt index 924bdb52..cf8f960c 100644 --- a/src/root/machine-status.tt +++ b/src/root/machine-status.tt @@ -25,36 +25,29 @@   [% WRAPPER makePopover title="Details" classes="btn-secondary btn-sm" %] -