From ab04ef5dbde2cac7b71868ac1ccdd1504ba7d365 Mon Sep 17 00:00:00 2001 From: ybonatakis Date: Thu, 13 Jun 2024 13:13:14 +0200 Subject: [PATCH] Provide parallel_one_host_only via workers config file --- docs/WritingTests.asciidoc | 4 ++-- etc/openqa/workers.ini | 12 ++++++++++++ lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm | 6 +++--- lib/OpenQA/Worker.pm | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/WritingTests.asciidoc b/docs/WritingTests.asciidoc index 158f5c049f86..910982b1f3c8 100644 --- a/docs/WritingTests.asciidoc +++ b/docs/WritingTests.asciidoc @@ -672,8 +672,8 @@ eventually workers can be held back for the cluster. It is possible to ensure that all jobs within the same _parallel_ cluster are executed on the same worker host. This is useful for connecting the SUTs without having to connect the physical worker hosts. Use `PARALLEL_ONE_HOST_ONLY=1` to -enable this. Note that adding this setting in `workers.ini` has currently *no* -effect. +enable this. It is also possible to enable this setting as a global in +`workers.ini`. WARNING: You need to provide enough worker slots on single worker hosts to fit an entire cluster. So this feature is mainly intended to workaround situations diff --git a/etc/openqa/workers.ini b/etc/openqa/workers.ini index 28685760ecce..f925552039a0 100644 --- a/etc/openqa/workers.ini +++ b/etc/openqa/workers.ini @@ -5,7 +5,10 @@ [global] # space separated list of webuis to connect to (empty defaults to localhost) #HOST = http://openqa.example.host +HOST = http://localhost:9526 +# Ensure that Multimachine jobs are scheduled on the same worker host. +#PARALLEL_ONE_HOST_ONLY = 1 # Specify a cache directory for assets and tests to sync them automatically via # http/rsync; the specified path is just an example but what you would usually # use on a normal setup @@ -83,6 +86,15 @@ # The section ids are the instance of the workers. # The key/value pairs will appear in vars.json +[1] +WORKER_CLASS = qemu_x86_64_staging,qemu_x86_64,tap + +[2] +WORKER_CLASS = qemu_x86_64_staging,qemu_x86_64,tap +#PARALLEL_ONE_HOST_ONLY = 1 +[3] +WORKER_CLASS = qemu_x86_64_staging,qemu_x86_64,tap + #[1] #WORKER_CLASS = 64bit-ipmi diff --git a/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm b/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm index 172b5bc9ba76..aca104433aa8 100644 --- a/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm +++ b/lib/OpenQA/WebAPI/Controller/API/V1/Worker.pm @@ -173,10 +173,10 @@ sub create { my ($self) = @_; my $validation = $self->validation; my @validation_params - = qw(cpu_arch cpu_modelname cpu_opmode cpu_flags mem_max isotovideo_interface_version websocket_api_version worker_class); + = qw(cpu_arch cpu_modelname cpu_opmode cpu_flags mem_max isotovideo_interface_version websocket_api_version worker_class parallel_one_host_only); $validation->required($_) for qw(host instance cpu_arch mem_max worker_class); $validation->optional($_) - for qw(cpu_modelname cpu_opmode cpu_flags isotovideo_interface_version job_id websocket_api_version); + for qw(cpu_modelname cpu_opmode cpu_flags isotovideo_interface_version job_id websocket_api_version parallel_one_host_only); return $self->reply->validation_error({format => 'json'}) if $validation->has_error; my $host = $validation->param('host'); @@ -184,7 +184,7 @@ sub create { my $job_ids = $validation->every_param('job_id'); my $caps = {}; $caps->{$_} = $validation->param($_) for @validation_params; - + #print "CAPS == $caps"; my $id; try { $id = $self->_register($self->schema, $host, $instance, $caps, $job_ids); diff --git a/lib/OpenQA/Worker.pm b/lib/OpenQA/Worker.pm index 0bd2fa6c3243..5d981f2ae590 100644 --- a/lib/OpenQA/Worker.pm +++ b/lib/OpenQA/Worker.pm @@ -211,6 +211,7 @@ sub capabilities ($self) { $caps->{worker_class} = join(',', map { 'qemu_' . $_ } @{$supported_archs_by_cpu_archs{$caps->{cpu_arch}} // [$caps->{cpu_arch}]}); # TODO: check installed qemu and kvm? + $caps->{parallel_one_host_only} = $global_settings->{PARALLEL_ONE_HOST_ONLY} if exists $global_settings->{PARALLEL_ONE_HOST_ONLY}; } return $self->{_caps} = $caps;