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

properly exit when scheduler misbehaves #329

Merged
merged 1 commit into from
Apr 9, 2015
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
9 changes: 7 additions & 2 deletions lib/OpenQA/Worker/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ sub api_call {
my ($method, $path, $params, $json_data, $ignore_errors) = @_;
state $call_running;

return undef unless verify_workerid();
return unless verify_workerid();

if ($call_running) {
# quit immediately
Expand Down Expand Up @@ -293,6 +293,9 @@ sub _get_capabilities {
}

sub setup_websocket {
# no point in trying if we are not registered
return unless verify_workerid();

# if there is an existing web socket connection wait until it finishes.
if ($ws) {
add_timer('setup_websocket', 2, \&setup_websocket, 1);
Expand Down Expand Up @@ -367,7 +370,9 @@ sub register_worker {
my $tx = $ua->post($ua_url => json => $worker_caps);
unless ($tx->success && $tx->success->json) {
if ($tx->error && $tx->error->{code} && $tx->error->{code} =~ /^4\d\d$/) {
die sprintf "server refused with code %s: %s\n", $tx->error->{code}, $tx->res->body;
# don't retry when 4xx codes are returned. There is problem with scheduler
printf "server refused with code %s: %s\n", $tx->error->{code}, $tx->res->body;
Mojo::IOLoop->stop;
}
print "failed to register worker, retry ...\n" if $verbose;
add_timer('register_worker', 10, \&register_worker, 1);
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/Worker/Jobs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ sub _stop_job($;$) {
$job_done = 1;
}
}
unless ($job_done) {
unless ($job_done || $aborted eq 'api-failure') {
# set job to done. if priority is less than threshold duplicate it
# with worse priority so it can be picked up again.
my %args;
Expand All @@ -208,7 +208,7 @@ sub _stop_job($;$) {
return;
}
# immediatelly check for already scheduled job
add_timer('check_job', 0, \&check_job, 1) unless ($job);
add_timer('check_job', 0, \&check_job, 1);
}

sub start_job {
Expand Down