Stream logs if possible and remove size limit

[?]
Jul 8, 2015, 5:04 PM
KI423DCQYAHL7IRSLKYU6BR5VMEGETWSKUANU4EKZEDWC2S2XSHAC

Dependencies

  • [2] KLSDJV75 Serve raw uncompressed logs directly
  • [3] CNEQ7L4G Don't show logs bigger than 64 MB
  • [4] WXV6M6XN Add a convenient way to get logs of a path/drv. Requested by phreedom.
  • [5] MMDLWWZ2 automatic reload of tail log when build is running
  • [6] J5UVLXOK * Start of a basic Catalyst web interface.
  • [7] SAIUFDP3 hydra: make sure viewing logs works when logs are bz2'd
  • [8] 6F4UNDTC * Provide access to the raw, non-pretty-printed logfiles.
  • [9] Q24QXGSM * Don't do pretty printing for large logs, because the XSLT processing
  • [10] X6RB5HQ6 Put a 5-second CPU time limit on the log processing pipeline.
  • [11] ZH6B56XR Try harder to find build logs
  • [12] RBHHV7P7 * Read logs using logContents function in stead of handling it everywhere separately.
  • [13] HRAFVVOE make logo configurable via HYDRA_LOGO env var
  • [14] Y6AHH4TH Remove the logfile and logSize columns from the database
  • [15] KZ55DLPH Fix UTF-8 handling of log files
  • [*] LBNVQXUB * Build the /build stuff in a separate controller.
  • [*] D5QIOJGP * Move everything up one directory.

Change contents

  • replacement in src/lib/Hydra/Controller/Build.pm at line 139
    [3.1][3.1:145]()
    my $size = stat($logPath)->size;
    error($c, "This build log is too big to display ($size bytes).")
    if $size >= 64 * 1024 * 1024;
    [3.1]
    [5.198]
    # Don't send logs that we can't stream.
    my $size = stat($logPath)->size; # FIXME: not so meaningful for compressed logs
    error($c, "This build log is too big to display ($size bytes).") unless
    $mode eq "raw"
    || (($mode eq "tail" || $mode eq "tail-reload") && $logPath !~ /\.bz2$/)
    || $size < 64 * 1024 * 1024;
  • replacement in src/lib/Hydra/Controller/Build.pm at line 156
    [5.759][2.0:240]()
    if ($logPath !~ /.bz2$/) {
    $c->serve_static_file($logPath);
    } else {
    $c->stash->{'plain'} = { data => (scalar logContents($logPath)) || " " };
    $c->forward('Hydra::View::Plain');
    }
    [5.759]
    [5.0]
    $c->stash->{logPath} = $logPath;
    $c->forward('Hydra::View::NixLog');
    return;
  • replacement in src/lib/Hydra/Controller/Root.pm at line 355
    [4.285][4.285:402]()
    $c->stash->{'plain'} = { data => (scalar logContents($logPath)) || " " };
    $c->forward('Hydra::View::Plain');
    [4.285]
    [4.402]
    $c->stash->{logPath} = $logPath;
    $c->forward('Hydra::View::NixLog');
  • file addition: NixLog.pm (----------)
    [18.1193]
    package Hydra::View::NixLog;
    use strict;
    use base qw/Catalyst::View/;
    use Hydra::Helper::CatalystUtils;
    sub process {
    my ($self, $c) = @_;
    my $logPath = $c->stash->{logPath};
    $c->response->content_type('text/plain');
    my $fh = new IO::Handle;
    if ($logPath =~ /\.bz2$/) {
    open $fh, "bzip2 -dc < '$logPath' |" or die;
    } else {
    open $fh, "<$logPath" or die;
    }
    binmode($fh);
    setCacheHeaders($c, 365 * 24 * 60 * 60);
    $c->response->body($fh);
    return 1;
    }
    1;