Show queue runner v2 status
This is guarded behind a setting and will overwrite everything that was learned from the machines file. Also drops `sshKeys` since that wasn't used anyway.
This commit is contained in:
@@ -189,8 +189,10 @@ sub machines :Local Args(0) {
|
|||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
my $machines = getMachines;
|
my $machines = getMachines;
|
||||||
|
|
||||||
# Add entry for localhost.
|
# Add entry for localhost. The implicit addition is not needed with queue runner v2
|
||||||
$machines->{''} //= {};
|
if (not $c->config->{'queue_runner_endpoint'}) {
|
||||||
|
$machines->{''} //= {};
|
||||||
|
}
|
||||||
delete $machines->{'localhost'};
|
delete $machines->{'localhost'};
|
||||||
|
|
||||||
my $status = $c->model('DB::SystemStatus')->find("queue-runner");
|
my $status = $c->model('DB::SystemStatus')->find("queue-runner");
|
||||||
|
@@ -12,6 +12,8 @@ use Nix::Store;
|
|||||||
use Encode;
|
use Encode;
|
||||||
use Sys::Hostname::Long;
|
use Sys::Hostname::Long;
|
||||||
use IPC::Run;
|
use IPC::Run;
|
||||||
|
use LWP::UserAgent;
|
||||||
|
use JSON::MaybeXS;
|
||||||
use UUID4::Tiny qw(is_uuid4_string);
|
use UUID4::Tiny qw(is_uuid4_string);
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
@@ -340,37 +342,60 @@ sub getEvals {
|
|||||||
|
|
||||||
sub getMachines {
|
sub getMachines {
|
||||||
my %machines = ();
|
my %machines = ();
|
||||||
|
my $config = getHydraConfig();
|
||||||
|
|
||||||
my @machinesFiles = split /:/, ($ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines");
|
if ($config->{'queue_runner_endpoint'}) {
|
||||||
|
my $ua = LWP::UserAgent->new();
|
||||||
|
my $resp = $ua->get($config->{'queue_runner_endpoint'} . "/status/machines");
|
||||||
|
if (not $resp->is_success) {
|
||||||
|
print STDERR "Unable to ask queue runner for machines\n";
|
||||||
|
return \%machines;
|
||||||
|
}
|
||||||
|
|
||||||
for my $machinesFile (@machinesFiles) {
|
my $data = decode_json($resp->decoded_content) or return \%machines;
|
||||||
next unless -e $machinesFile;
|
my $machinesData = $data->{machines};
|
||||||
open(my $conf, "<", $machinesFile) or die;
|
|
||||||
while (my $line = <$conf>) {
|
|
||||||
chomp($line);
|
|
||||||
$line =~ s/\#.*$//g;
|
|
||||||
next if $line =~ /^\s*$/;
|
|
||||||
my @tokens = split /\s+/, $line;
|
|
||||||
|
|
||||||
if (!defined($tokens[5]) || $tokens[5] eq "-") {
|
foreach my $machineName (keys %$machinesData) {
|
||||||
$tokens[5] = "";
|
my $machine = %$machinesData{$machineName};
|
||||||
}
|
$machines{$machineName} =
|
||||||
my @supportedFeatures = split(/,/, $tokens[5] || "");
|
{ systemTypes => $machine->{systems}
|
||||||
|
, maxJobs => $machine->{maxJobs}
|
||||||
if (!defined($tokens[6]) || $tokens[6] eq "-") {
|
, speedFactor => $machine->{speedFactor}
|
||||||
$tokens[6] = "";
|
, supportedFeatures => [ @{$machine->{supportedFeatures}}, @{$machine->{mandatoryFeatures}} ]
|
||||||
}
|
, mandatoryFeatures => [ @{$machine->{mandatoryFeatures}} ]
|
||||||
my @mandatoryFeatures = split(/,/, $tokens[6] || "");
|
|
||||||
$machines{$tokens[0]} =
|
|
||||||
{ systemTypes => [ split(/,/, $tokens[1]) ]
|
|
||||||
, sshKeys => $tokens[2]
|
|
||||||
, maxJobs => int($tokens[3])
|
|
||||||
, speedFactor => 1.0 * (defined $tokens[4] ? int($tokens[4]) : 1)
|
|
||||||
, supportedFeatures => [ @supportedFeatures, @mandatoryFeatures ]
|
|
||||||
, mandatoryFeatures => [ @mandatoryFeatures ]
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
close $conf;
|
} else {
|
||||||
|
my @machinesFiles = split /:/, ($ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines");
|
||||||
|
|
||||||
|
for my $machinesFile (@machinesFiles) {
|
||||||
|
next unless -e $machinesFile;
|
||||||
|
open(my $conf, "<", $machinesFile) or die;
|
||||||
|
while (my $line = <$conf>) {
|
||||||
|
chomp($line);
|
||||||
|
$line =~ s/\#.*$//g;
|
||||||
|
next if $line =~ /^\s*$/;
|
||||||
|
my @tokens = split /\s+/, $line;
|
||||||
|
|
||||||
|
if (!defined($tokens[5]) || $tokens[5] eq "-") {
|
||||||
|
$tokens[5] = "";
|
||||||
|
}
|
||||||
|
my @supportedFeatures = split(/,/, $tokens[5] || "");
|
||||||
|
|
||||||
|
if (!defined($tokens[6]) || $tokens[6] eq "-") {
|
||||||
|
$tokens[6] = "";
|
||||||
|
}
|
||||||
|
my @mandatoryFeatures = split(/,/, $tokens[6] || "");
|
||||||
|
$machines{$tokens[0]} =
|
||||||
|
{ systemTypes => [ split(/,/, $tokens[1]) ]
|
||||||
|
, maxJobs => int($tokens[3])
|
||||||
|
, speedFactor => 1.0 * (defined $tokens[4] ? int($tokens[4]) : 1)
|
||||||
|
, supportedFeatures => [ @supportedFeatures, @mandatoryFeatures ]
|
||||||
|
, mandatoryFeatures => [ @mandatoryFeatures ]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
close $conf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return \%machines;
|
return \%machines;
|
||||||
|
@@ -33,7 +33,6 @@ close $fh;
|
|||||||
is(Hydra::Helper::Nix::getMachines(), {
|
is(Hydra::Helper::Nix::getMachines(), {
|
||||||
'root@ip' => {
|
'root@ip' => {
|
||||||
'systemTypes' => ["x86_64-darwin"],
|
'systemTypes' => ["x86_64-darwin"],
|
||||||
'sshKeys' => '/sshkey',
|
|
||||||
'maxJobs' => 15,
|
'maxJobs' => 15,
|
||||||
'speedFactor' => 15,
|
'speedFactor' => 15,
|
||||||
'supportedFeatures' => ["big-parallel", "kvm", "nixos-test" ],
|
'supportedFeatures' => ["big-parallel", "kvm", "nixos-test" ],
|
||||||
@@ -41,7 +40,6 @@ is(Hydra::Helper::Nix::getMachines(), {
|
|||||||
},
|
},
|
||||||
'root@baz' => {
|
'root@baz' => {
|
||||||
'systemTypes' => [ "aarch64-darwin" ],
|
'systemTypes' => [ "aarch64-darwin" ],
|
||||||
'sshKeys' => '/sshkey',
|
|
||||||
'maxJobs' => 4,
|
'maxJobs' => 4,
|
||||||
'speedFactor' => 1,
|
'speedFactor' => 1,
|
||||||
'supportedFeatures' => ["big-parallel"],
|
'supportedFeatures' => ["big-parallel"],
|
||||||
@@ -49,7 +47,6 @@ is(Hydra::Helper::Nix::getMachines(), {
|
|||||||
},
|
},
|
||||||
'root@bux' => {
|
'root@bux' => {
|
||||||
'systemTypes' => [ "i686-linux", "x86_64-linux" ],
|
'systemTypes' => [ "i686-linux", "x86_64-linux" ],
|
||||||
'sshKeys' => '/var/sshkey',
|
|
||||||
'maxJobs' => 1,
|
'maxJobs' => 1,
|
||||||
'speedFactor' => 1,
|
'speedFactor' => 1,
|
||||||
'supportedFeatures' => [ "kvm", "nixos-test", "benchmark" ],
|
'supportedFeatures' => [ "kvm", "nixos-test", "benchmark" ],
|
||||||
@@ -57,7 +54,6 @@ is(Hydra::Helper::Nix::getMachines(), {
|
|||||||
},
|
},
|
||||||
'root@lotsofspace' => {
|
'root@lotsofspace' => {
|
||||||
'systemTypes' => [ "i686-linux", "x86_64-linux" ],
|
'systemTypes' => [ "i686-linux", "x86_64-linux" ],
|
||||||
'sshKeys' => '/var/sshkey',
|
|
||||||
'maxJobs' => 1,
|
'maxJobs' => 1,
|
||||||
'speedFactor' => 1,
|
'speedFactor' => 1,
|
||||||
'supportedFeatures' => [ "kvm", "nixos-test", "benchmark" ],
|
'supportedFeatures' => [ "kvm", "nixos-test", "benchmark" ],
|
||||||
|
Reference in New Issue
Block a user