Skip to content

Commit c0a7fd7

Browse files
authored
Merge pull request #18749 from mlschroe/master
[backend] BSRepServer::Checker: also support appimage, livebuild, sim…
2 parents ce5a5bc + f83b6ab commit c0a7fd7

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/backend/BSRepServer/Checker.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ my %handlers = (
4343
'docker' => BSSched::BuildJob::Docker->new(),
4444
'fissile' => BSSched::BuildJob::Docker->new(),
4545
'mkosi' => BSSched::BuildJob::Image->new(),
46+
'appimage' => BSSched::BuildJob::Image->new(),
47+
'livebuild' => BSSched::BuildJob::Image->new(),
48+
'simpleimage' => BSSched::BuildJob::Image->new(),
4649
'buildenv' => BSSched::BuildJob::BuildEnv->new(),
4750
'unknown' => BSSched::BuildJob::Unknown->new(),
4851
'default' => BSSched::BuildJob::Package->new(),

src/backend/BSServer.pm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,25 @@ sub request_infostr {
673673
my ($req) = @_;
674674
my $id = $req->{'reqid'} || $req->{'keepalive_count'};
675675
$id = $id ? "$$.$id" : $$;
676-
return sprintf("%s: %3ds %-7s %-22s %s%s\n", BSUtil::isotime($req->{'starttime'}), time() - $req->{'starttime'}, "[$id]",
676+
my $extrastr = '';
677+
if ($req->{'starttime'} && $req->{'client_time'}) {
678+
my $client_wait_time = $req->{'starttime'} - $req->{'client_time'};
679+
$extrastr = sprintf("+%d", $client_wait_time) if $client_wait_time > 0 && $client_wait_time < 3600 * 24;
680+
}
681+
return sprintf("%s: %3ds$extrastr %-7s %-22s %s%s\n", BSUtil::isotime($req->{'starttime'}), time() - $req->{'starttime'}, "[$id]",
677682
"$req->{'action'} ($req->{'peer'})", $req->{'path'}, ($req->{'query'}) ? "?$req->{'query'}" : '');
678683
}
679684

680685
sub log_slow_requests {
681686
my ($conf, $req) = @_;
682-
return unless $req && $conf->{'slowrequestthr'} && $req->{'starttime'} && time() - $req->{'starttime'} >= $conf->{'slowrequestthr'};
687+
return unless $req && $conf->{'slowrequestthr'} && $req->{'starttime'};
688+
my $now = time();
689+
my $extratime = 0;
690+
if ($req->{'client_time'}) {
691+
my $client_wait_time = $req->{'starttime'} - $req->{'client_time'};
692+
$extratime = $client_wait_time if $client_wait_time > 0 && $client_wait_time < 3600 * 24;
693+
}
694+
return unless $req && $conf->{'slowrequestthr'} && $req->{'starttime'} && $now - $req->{'starttime'} + $extratime >= $conf->{'slowrequestthr'};
683695
my $log = $req->{'slowrequestlog'} || $conf->{'slowrequestlog'};
684696
return unless $log;
685697
my $msg = request_infostr($req);

src/backend/BSStdServer.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ sub dispatch {
114114
my $peerip = ($req->{'headers'} || {})->{lc($conf->{'trusted_peerip_header'})};
115115
$req->{'peerip'} = $req->{'peer'} = $peer = $peerip if $peerip && $peerip =~ /^[0-9a-fA-F\.\:]+$/s;
116116
}
117+
if (!$isajax && $conf->{'client_time_header'}) {
118+
my $client_time = ($req->{'headers'} || {})->{lc($conf->{'client_time_header'})};
119+
$req->{'client_time'} = 0 + $client_time if $client_time && $client_time =~ /^\d+$/;
120+
}
117121
my $msg = sprintf("%-22s %s%s",
118122
"$req->{'action'} ($peer)", $req->{'path'},
119123
defined($req->{'query'}) ? "?$req->{'query'}" : '',

src/backend/bs_srcserver

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8153,6 +8153,7 @@ my $conf = {
81538153
'errorreply' => \&BSRegistryServer::errreply,
81548154
'run' => \&run,
81558155
'periodic' => \&periodic,
8156+
'client_time_header' => 'X-Frontend-Start',
81568157
};
81578158

81588159
my $aconf = {

0 commit comments

Comments
 (0)