machine-status: Read /etc/nix.machines instead of using the BuildMachines table

[?]
Mar 4, 2013, 8:37 PM
HTL6HIBMRGSX2H2H7KB4MC3H6UQ5C752VC3UHC43SRA7V66PQCRQC

Dependencies

  • [2] R2PON6R7 Allow non-admin users to see the machine status page
  • [3] V6S6OYIA Formatting tweaks
  • [4] U5ZWDBW3 Ensure that each eval is compared to the previous one from the same jobset
  • [5] BDSD2JLV * Speed up manifest generation.
  • [6] PMNWRTGJ Add multiple output support
  • [7] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [8] SMCOU72F hydra: add some admin for adding/enabling/etc build machines
  • [9] VH5ZABDR Add a page to show the latest evaluations for the entire server
  • [10] EFWN7JBV * Added a status page that shows all the currently executing build steps.
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] 2GK5DOU7 * Downloading closures.
  • [*] ZWCTAZGL added newsitems, added some admin options to clear various caches.

Change contents

  • replacement in src/lib/Hydra/Controller/Root.pm at line 77
    [2.55][2.55:416]()
    $c->stash->{machines} = [$c->model('DB::BuildMachines')->search(
    {},
    { order_by => ["enabled DESC", "hostname"]
    , '+select' => ["(select bs.stoptime from buildsteps as bs where bs.machine = (me.username || '\@' || me.hostname) and not bs.stoptime is null order by bs.stoptime desc limit 1)"]
    , '+as' => ['idle']
    })];
    [2.55]
    [2.416]
    my $machines = getMachines;
    my $idles = $c->model('DB::BuildSteps')->search(
    { stoptime => { '!=', undef } },
    { select => [ 'machine', { max => 'stoptime', -as => 'max_stoptime' }], group_by => "machine" });
    while (my $idle = $idles->next) {
    ${$machines}{$idle->machine}{'idle'} = $idle->max_stoptime;
    }
    $c->stash->{machines} = $machines;
  • replacement in src/lib/Hydra/Helper/Nix.pm at line 19
    [5.862][5.862:877]()
    getEvals);
    [5.862]
    [5.77]
    getEvals getMachines);
  • edit in src/lib/Hydra/Helper/Nix.pm at line 374
    [4.2639]
    [5.9702]
    }
    sub getMachines {
    my $machinesConf = $ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix.machines";
    # Read the list of machines.
    my %machines = ();
    if (-e $machinesConf) {
    open CONF, "<$machinesConf" or die;
    while (<CONF>) {
    chomp;
    s/\#.*$//g;
    next if /^\s*$/;
    my @tokens = split /\s/, $_;
    my @supportedFeatures = split(/,/, $tokens[5] || "");
    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;
    }
    return \%machines;
  • replacement in src/root/machine-status.tt at line 9
    [3.259][3.259:416]()
    [% IF m.enabled == 1 %]
    <a class="btn btn-success btn-mini" href="[% c.uri_for('/admin/machine' m.hostname 'disable' ) %]">Running</a>
    [3.259]
    [3.416]
    [% IF m.value.maxJobs > 0 %]
    Running
  • replacement in src/root/machine-status.tt at line 12
    [3.437][3.437:729]()
    <a class="btn btn-danger btn-mini" href="[% c.uri_for('/admin/machine' m.hostname 'enable' ) %]">Stopped</a>
    [% END %] <tt>[% m.hostname %]</tt> (<tt>[% comma=0; FOREACH ms IN m.buildmachinesystemtypes %][% IF comma; %], [% ELSE; comma = 1; END; ms.system; END %])</tt>
    [3.437]
    [3.729]
    Stopped
    [% END %] <tt>[% m.key %]</tt> (<tt>[% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END; system; END %])</tt>
  • replacement in src/root/machine-status.tt at line 20
    [3.811][5.10117:10178](),[5.10117][5.10117:10178]()
    [% IF step.machine.match('@(.*)').0 == m.hostname %]
    [3.811]
    [3.812]
    [% IF step.machine.match('@(.*)').0 == m.key %]
  • replacement in src/root/machine-status.tt at line 32
    [3.1374][3.1374:1496]()
    <tr><td colspan="5">Idle since [% INCLUDE renderDuration duration = curTime - m.get_column('idle') %]</td></tr>
    [3.1374]
    [3.1496]
    [% IF m.value.idle %]
    <tr><td colspan="5">Idle since [% INCLUDE renderDuration duration = curTime - m.value.idle %]</td></tr>
    [% ELSE %]
    <tr><td colspan="5">Never built</td></tr>
    [% END %]