Skip to content

Commit a9d64b7

Browse files
authored
Merge pull request #6568 from Wabri/feat/181409-settings
Prevent error when workers config not found, throw warning instead
2 parents 235a203 + 7391c52 commit a9d64b7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/OpenQA/Worker/Settings.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Mojo::Util 'trim';
1010
use Config::IniFiles;
1111
use Time::Seconds;
1212
use OpenQA::Config;
13-
use OpenQA::Log 'setup_log';
13+
use OpenQA::Log qw(setup_log log_info);
1414
use OpenQA::Utils 'is_host_local';
1515
use Net::Domain 'hostfqdn';
1616

@@ -23,7 +23,8 @@ use constant VNCPORT_OFFSET => $ENV{VNCPORT_OFFSET} // 90;
2323
sub new ($class, $instance_number = undef, $cli_options = {}) {
2424
my $config_paths = lookup_config_files(undef, 'workers.ini', 1);
2525
my $cfg = parse_config_files($config_paths);
26-
my @parse_errors = @$config_paths ? (@Config::IniFiles::errors) : ('No config file found.');
26+
my @parse_errors = @$config_paths ? (@Config::IniFiles::errors) : ();
27+
log_info 'workers.ini not found, using default settings' unless @$config_paths;
2728

2829
# read settings from config
2930
my %global_settings;

t/24-worker-settings.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ subtest 'settings file not found' => sub {
127127
$config_mock->redefine(_config_dirs => [['does not exist']]);
128128
my $settings = OpenQA::Worker::Settings->new(1);
129129
ok !$settings->file_path, 'no file path present';
130-
is_deeply $settings->parse_errors, ['No config file found.'], 'error logged'
130+
is_deeply $settings->parse_errors, [], 'no parse errors if file is missing'
131131
or always_explain $settings->parse_errors;
132132
};
133133

0 commit comments

Comments
 (0)