Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log waiting time in monitor script and useragent #5502

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/OpenQA/CLI/monitor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ has description => 'Monitors a set of jobs';
has usage => sub { shift->extract_usage };

sub _monitor_jobs ($self, $client, $poll_interval, $job_ids, $job_results) {
my $start = time;
while (@$job_results < @$job_ids) {
my $job_id = $job_ids->[@$job_results];
my $tx = $client->build_tx(GET => $self->url_for("experimental/jobs/$job_id/status"));
Expand All @@ -23,7 +24,9 @@ sub _monitor_jobs ($self, $client, $poll_interval, $job_ids, $job_results) {
push @$job_results, $job->{result} // NONE;
next;
}
print encode('UTF-8', "Job state of job ID $job_id: $job_state, waiting …\n");
my $waited = time - $start;
print encode('UTF-8',
"Job state of job ID $job_id: $job_state, waiting … (delay: $poll_interval; waited ${waited}s)\n");
sleep $poll_interval;
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/OpenQA/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ sub retry_tx ($self, $client, $tx, $retries = undef, $delay = undef) {
$client->connect_timeout($ENV{MOJO_CONNECT_TIMEOUT} // 30);
$delay //= $ENV{OPENQA_CLI_RETRY_SLEEP_TIME_S} // 3;
$retries //= $ENV{OPENQA_CLI_RETRIES} // 0;
my $start = time;
for (;; --$retries) {
$tx = $client->start($tx);
my $res_code = $tx->res->code // 0;
return $self->handle_result($tx) unless $res_code =~ /^(50[23]|0)$/ && $retries > 0;
my $waited = time - $start;
print encode('UTF-8',
"Request failed, hit error $res_code, retrying up to $retries more times after waiting …\n");
"Request failed, hit error $res_code, retrying up to $retries more times after waiting … (delay: $delay; waited ${waited}s)\n"
);
sleep $delay;
}
}
Expand Down
Loading