You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2017/06/23 20:46:29 UTC
svn commit: r1799700 - in /vcl/trunk/managementnode/lib/VCL: new.pm utils.pm
Author: arkurth
Date: Fri Jun 23 20:46:29 2017
New Revision: 1799700
URL: http://svn.apache.org/viewvc?rev=1799700&view=rev
Log:
Reduced unnecessary warnings when checking for competing reservations. Added $suppress_warnings argument to utils.pm::get_request_current_state_name, used by utils.pm::is_request_deleted. Added additional calls to is_request_deleted in new.pm::computer_not_being_used.
Modified:
vcl/trunk/managementnode/lib/VCL/new.pm
vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1799700&r1=1799699&r2=1799700&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Fri Jun 23 20:46:29 2017
@@ -669,9 +669,7 @@ sub computer_not_being_used {
}
# Warn if computer state isn't available or reload - except for reinstall requests
- if ($request_state_name !~ /^(reinstall)$/ && $computer_state_name !~ /^(available|reload)$/) {
- notify($ERRORS{'WARNING'}, 0, "$computer_short_name state is $computer_state_name, checking if any competing reservations are active");
- }
+ notify($ERRORS{'WARNING'}, 0, "$computer_short_name state is $computer_state_name, checking if any competing reservations are active");
# Check if there is another request using this machine
# Get a hash containing all of the reservations for the computer
@@ -734,7 +732,9 @@ sub computer_not_being_used {
}
# Check if the other reservation is a 'reload' reservation for the same image revision
- if ($competing_imagerevision_id eq $imagerevision_id && $competing_request_state =~ /^(pending|reload)$/ && $competing_request_laststate =~ /(reload)/) {
+ if ($competing_imagerevision_id eq $imagerevision_id &&
+ $competing_request_state =~ /^(pending|reload)$/ &&
+ $competing_request_laststate =~ /(reload)/) {
notify($ERRORS{'OK'}, 0, "reservation $competing_reservation_id is assigned to $computer_short_name with the same image revision: $image_name, waiting for the other reload process to complete");
my $message = "waiting for reload reservation $competing_request_id:$competing_reservation_id to finish loading $computer_short_name with $image_name";
@@ -746,12 +746,23 @@ sub computer_not_being_used {
# Loop until other process is done
if ($self->code_loop_timeout(sub{return !reservation_being_processed(@_)}, [$competing_reservation_id], $message, $total_wait_seconds, $attempt_delay_seconds)) {
- notify($ERRORS{'DEBUG'}, 0, "reload reservation $competing_reservation_id is not loading $computer_short_name with $image_name");
- # Verified competing 'reload' is not being processed verify it is not stuck in pending/reload
- my ($current_competing_request_state, $current_competing_request_laststate) = get_request_current_state_name($competing_request_id);
- if ($current_competing_request_state eq 'pending' && $current_competing_request_laststate eq 'reload') {
- notify($ERRORS{'OK'}, 0, "state of competing reload request $competing_request_id:$competing_reservation_id is $current_competing_request_state/$current_competing_request_laststate, verified it is not being processed, changing state of competing request $competing_request_id to 'complete'");
- update_request_state($competing_request_id, 'complete', 'reload');
+ # Check if reload request finished and was already deleted
+ if (is_request_deleted($competing_request_id)) {
+ notify($ERRORS{'OK'}, 0, "reload reservation $competing_request_id:$competing_reservation_id is no longer loading $computer_short_name with $image_name, request $competing_request_id has been deleted");
+ }
+ else {
+ # Verified competing 'reload' is not being processed verify it is not stuck in pending/reload
+ notify($ERRORS{'DEBUG'}, 0, "reload reservation $competing_request_id:$competing_reservation_id is not loading $computer_short_name with $image_name, checking current state of request $competing_request_id");
+ my ($current_competing_request_state, $current_competing_request_laststate) = get_request_current_state_name($competing_request_id);
+ if (!defined($current_competing_request_state)) {
+ if (is_request_deleted($competing_request_id)) {
+ notify($ERRORS{'OK'}, 0, "reload request $competing_request_id:$competing_reservation_id which was loading $computer_short_name with $image_name was just deleted");
+ }
+ }
+ elsif ($current_competing_request_state eq 'pending' && $current_competing_request_laststate eq 'reload') {
+ notify($ERRORS{'OK'}, 0, "state of competing reload request $competing_request_id:$competing_reservation_id is $current_competing_request_state/$current_competing_request_laststate, verified it is not being processed, changing state of competing request $competing_request_id to 'complete'");
+ update_request_state($competing_request_id, 'complete', 'reload');
+ }
}
# Try again in order to retrieve a current list of competing reservations
@@ -807,7 +818,7 @@ sub computer_not_being_used {
}
}
- # Kill competing process and update request state to complete
+ # Kill competing process
notify($ERRORS{'OK'}, 0, "attempting to kill process of competing reservation $competing_reservation_id assigned to $computer_short_name");
for my $competing_reservation_pid (@competing_reservation_pids) {
$self->mn_os->kill_process($competing_reservation_pid);
@@ -823,6 +834,8 @@ sub computer_not_being_used {
}
}
+ sleep_uninterrupted(5);
+
# Try again in order to retrieve a current list of competing reservations
# The list of competing reservations may have changed
# A new reload reservation may have been added by timeout/deleted processes
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1799700&r1=1799699&r2=1799700&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Fri Jun 23 20:46:29 2017
@@ -818,6 +818,21 @@ END
}
else {
open(STDOUT, ">>$log");
+
+ # ARK - for testing competing reservations
+ if ($ENV{reservation_id}) {
+ if ($ENV{reservation_id} == 3115) {
+ print colored($log_message, "YELLOW");
+ }
+ elsif ($ENV{reservation_id} == 3116) {
+ print colored($log_message, "CYAN");
+ }
+ else {
+ print colored($log_message, "MAGENTA");
+ }
+ print "\n";
+ return 1;
+ }
print STDOUT "$log_message\n";
}
} ## end sub notify
@@ -1710,9 +1725,9 @@ sub is_request_deleted {
return;
}
- my ($state_name, $laststate_name) = get_request_current_state_name($request_id);
+ my ($state_name, $laststate_name) = get_request_current_state_name($request_id, 1);
if (!$state_name || !$laststate_name) {
- notify($ERRORS{'WARNING'}, 0, "request $request_id state data could not be retrieved, assuming request is deleted and was removed from the database, returning true");
+ notify($ERRORS{'OK'}, 0, "request $request_id state data could not be retrieved, assuming request is deleted and was removed from the database, returning true");
return 1;
}
@@ -5282,7 +5297,7 @@ EOF
=head2 get_request_current_state_name
- Parameters : $request_id
+ Parameters : $request_id, $suppress_warnings (optional)
Returns : String containing state name for a request
Description :
@@ -5290,7 +5305,7 @@ EOF
sub get_request_current_state_name {
- my ($request_id) = @_;
+ my ($request_id, $suppress_warnings) = @_;
# Check the passed parameter
if (!(defined($request_id))) {
@@ -5315,10 +5330,11 @@ EOF
# Call the database select subroutine
my @selected_rows = database_select($select_statement);
-
+
+ my $notify_type = ($suppress_warnings ? $ERRORS{'OK'} : $ERRORS{'WARNING'});
# Check to make sure 1 row was returned
if (!@selected_rows) {
- notify($ERRORS{'WARNING'}, 0, "unable to determine current state of request $request_id, zero rows were returned from database select");
+ notify($notify_type, 0, "unable to determine current state of request $request_id, zero rows were returned from database select");
return;
}