diff --git a/Anvil/Tools/DRBD.pm b/Anvil/Tools/DRBD.pm index fc4aa327..858e0c19 100644 --- a/Anvil/Tools/DRBD.pm +++ b/Anvil/Tools/DRBD.pm @@ -2251,6 +2251,8 @@ sub get_status if ($is_local) { # Try rebuilding the module. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0328"}); + my $problem = $anvil->DRBD->_initialize_kmod({debug => 2}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { problem => $problem }}); @@ -2264,7 +2266,7 @@ sub get_status }}); if ($output =~ /modprobe: FATAL: Module drbd not found/i) { - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "error_0415", variables => { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "error_0415", variables => { output => $output, return_code => $anvil->data->{drbd}{status}{$host}{return_code}, }}); diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index a0732d20..469599ec 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -46,6 +46,7 @@ my $THIS_FILE = "System.pm"; # stop_daemon # stty_echo # update_hosts +# wait_on_dnf # _check_anvil_conf # _load_firewalld_zones # _load_specific_firewalld_zone @@ -5389,6 +5390,60 @@ sub update_hosts return(0); } +=head2 wait_on_dnf + +This method checks to see if 'dnf' is running and, if so, won't return until it finishes. This is useful when holding off doing certain tasks, like building kernel modules, while an OS update is under way. + +This method takes no parameters. + +=cut +sub wait_on_dnf +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->wait_on_dnf()" }}); + + my $next_log = time - 1; + my $waiting = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + next_log => $next_log, + waiting => $waiting, + }}); + while ($waiting) + { + my $pids = $anvil->System->pids({program_name => $anvil->data->{path}{exe}{dnf}, debug => $debug}); + my $dnf_instances = @{$pids}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { dnf_instances => $dnf_instances }}); + + if ($dnf_instances) + { + if (time > $next_log) + { + my $say_pids = ""; + foreach my $pid (@{$pids}) + { + $say_pids .= $pid.", "; + } + $say_pids =~ s/, $//; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0325", variables => { pids => $say_pids }}); + + $next_log = time + 60; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { next_log => $next_log }}); + } + sleep 10; + } + else + { + $waiting = 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { waiting => $waiting }}); + } + } + + return(0); +} + # =head3 # # Private Functions; diff --git a/share/words.xml b/share/words.xml index c8b6ec65..dcb2cab7 100644 --- a/share/words.xml +++ b/share/words.xml @@ -2926,6 +2926,7 @@ Proceed? [y/N] [ Note ] - It looks like 'dnf' (pid(s): [#!variable!pids!#]) is running, holding our start up until it's done (in case the system is being updated now). This daemon just started. Holding off starting jobs for another: [#!variable!will_start_in!#] second(s). [ Note ] - It looks like 'anvil-version-changes' (pid(s): [#!variable!pids!#]) is running, holding off on power action until it's done (in case the system is being updated now or kernel modules are being built). + [ Note ] - The DRBD (replicated storage) kernel module appears to not exist. This is normal after an OS update, will try building the kernel module now. Please be patient. Normal Password diff --git a/tools/anvil-daemon b/tools/anvil-daemon index 009a3232..4ea2df9c 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -68,7 +68,7 @@ if (($< != 0) && ($> != 0)) $anvil->System->_check_anvil_conf(); # If dnf is running, hold. -wait_on_dnf($anvil); +$anvil->System->wait_on_dnf(); # Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks # is to setup the database server. @@ -252,49 +252,6 @@ $anvil->nice_exit({exit_code => 0}); # Functions # ############################################################################################################# -# This checks to see if dnf is running when this daemon starts (as happens during an OS update) and hold -# until the dnf update is complete. -sub wait_on_dnf -{ - my ($anvil) = @_; - - my $next_log = time - 1; - my $waiting = 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - next_log => $next_log, - waiting => $waiting, - }}); - while ($waiting) - { - my $pids = $anvil->System->pids({program_name => $anvil->data->{path}{exe}{dnf}}); - my $dnf_instances = @{$pids}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dnf_instances => $dnf_instances }}); - - if ($dnf_instances) - { - if (time > $next_log) - { - my $say_pids = ""; - foreach my $pid (@{$pids}) - { - $say_pids .= $pid.", "; - } - $say_pids =~ s/, $//; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0325", variables => { pids => $say_pids }}); - - $next_log = time + 60; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }}); - } - sleep 10; - } - else - { - $waiting = 0; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }}); - } - } -} - # If we're using too much ram, send an alert and exit. sub check_ram { diff --git a/tools/anvil-safe-start b/tools/anvil-safe-start index d974aab9..0e6496c3 100755 --- a/tools/anvil-safe-start +++ b/tools/anvil-safe-start @@ -53,6 +53,9 @@ if (($< != 0) && ($> != 0)) $anvil->nice_exit({exit_code => 1}); } +# If dnf is running, hold. +$anvil->System->wait_on_dnf(); + # Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks # is to setup the database server. $anvil->Database->connect(); @@ -585,6 +588,13 @@ sub prerun_checks host_type => $host_type, }}); + if (($host_type eq "node") or ($host_type eq "dr")) + { + # Call DRBD->get_status because, if we're just starting up and the kernel module needs to be + # built, do it before we start calling scan agents. + $anvil->DRBD->get_status({debug => 2}); + } + if ($host_type ne "node") { # We're done. diff --git a/tools/scancore b/tools/scancore index 82ed293b..18b6bfca 100755 --- a/tools/scancore +++ b/tools/scancore @@ -67,6 +67,9 @@ $anvil->data->{scancore} = { $anvil->Storage->read_config(); +# If dnf is running, hold. +$anvil->System->wait_on_dnf(); + # Read switches $anvil->Get->switches({list => ["purge", "run-once"], man => $THIS_FILE}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); @@ -431,10 +434,12 @@ sub startup_tasks # This used to call anvil-safe-start, which isn't done here anymore. my $host_type = $anvil->Get->host_type(); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { host_type => $host_type }}); - if ($host_type eq "node") + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }}); + if (($host_type eq "node") or ($host_type eq "dr")) { - # For future use. + # Call DRBD->get_status because, if we're just starting up and the kernel module needs to be + # built, do it before we start calling scan agents. + $anvil->DRBD->get_status({debug => 2}); } elsif ($host_type eq "striker") {