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

Sync needles when caching is enabled #1381

Merged
merged 2 commits into from Sep 20, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/OpenQA/Worker.pm
Expand Up @@ -58,14 +58,15 @@ sub main {
my ($host_settings) = @_;
my $lockfd = lockit();
my $dir;
my $shared_cache;
clean_pool();
## register worker at startup to all webuis
for my $h (@{$host_settings->{HOSTS}}) {
# check if host`s working directory exists
# if caching is not enabled

if ($worker_settings->{CACHEDIRECTORY}) {
prepare_cache_directory($h, $worker_settings->{CACHEDIRECTORY});
$shared_cache = prepare_cache_directory($h, $worker_settings->{CACHEDIRECTORY});
}

my @dirs = ($host_settings->{$h}{SHARE_DIRECTORY}, catdir($OpenQA::Utils::prjdir, 'share'));
Expand All @@ -77,7 +78,9 @@ sub main {

log_debug("Using dir $dir for host $h") if $verbose;
Mojo::IOLoop->next_tick(
sub { OpenQA::Worker::Common::register_worker($h, $dir, $host_settings->{$h}{TESTPOOLSERVER}) });
sub {
OpenQA::Worker::Common::register_worker($h, $dir, $host_settings->{$h}{TESTPOOLSERVER}, $shared_cache);
});
}

# start event loop - this will block until stop is called
Expand Down
9 changes: 9 additions & 0 deletions lib/OpenQA/Worker/Commands.pm
Expand Up @@ -20,6 +20,8 @@ use warnings;
use OpenQA::Utils qw(log_error log_warning log_debug);
use OpenQA::Worker::Common;
use OpenQA::Worker::Jobs;
use POSIX qw(:sys_wait_h);
use OpenQA::Worker::Engines::isotovideo;

## WEBSOCKET commands
sub websocket_commands {
Expand Down Expand Up @@ -77,6 +79,13 @@ sub websocket_commands {
}
elsif ($type eq 'reload_needles_and_retry') {
if (backend_running) {
if ($hosts->{$current_host}{testpoolserver} && $hosts->{$host}{shared_cache}) {
my $sync_child = fork();
if (!$sync_child) {
OpenQA::Worker::Engines::isotovideo::cache_tests($hosts->{$host}{shared_cache},
$hosts->{$current_host}{testpoolserver});
}
}
$ua->post("$joburl/isotovideo/reload_needles");
log_debug('needles will be reloaded') if $verbose;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/OpenQA/Worker/Common.pm
Expand Up @@ -417,7 +417,7 @@ sub call_websocket {
}

sub register_worker {
my ($host, $dir, $testpoolserver) = @_;
my ($host, $dir, $testpoolserver, $shared_cache) = @_;
die unless $host;
$hosts->{$host}{accepting_jobs} = 0;

Expand Down Expand Up @@ -447,6 +447,7 @@ sub register_worker {

# test pool is from config, so it doesn't change
$hosts->{$host}{testpoolserver} = $testpoolserver if $testpoolserver;
$hosts->{$host}{shared_cache} = $shared_cache if $shared_cache;

# reset workerid
$hosts->{$host}{workerid} = undef;
Expand Down