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 2013/09/06 16:36:49 UTC
svn commit: r1520583 - in /vcl/trunk/managementnode/lib/VCL: Module/State.pm
utils.pm
Author: arkurth
Date: Fri Sep 6 14:36:49 2013
New Revision: 1520583
URL: http://svn.apache.org/r1520583
Log:
VCL-16
Added code to State.pm::reservation_failed to check if the state is inuse. State is set back to inuse rather than failed.
Extended update_request_state to check the result of database_execute which returns the number of rows updated. If 0, the current request state is retrieved from the database. If it matches the arguments passed to update_request_state then no warning is displayed.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/State.pm
vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=1520583&r1=1520582&r2=1520583&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/State.pm Fri Sep 6 14:36:49 2013
@@ -236,7 +236,7 @@ sub reservation_failed {
# Check if the request has been deleted
if (is_request_deleted($request_id)) {
notify($ERRORS{'OK'}, 0, "request has been deleted, setting computer state to available and exiting");
-
+
# Update the computer state to available
if ($computer_state_name !~ /^(maintenance)/){
if (update_computer_state($computer_id, "available")) {
@@ -253,7 +253,12 @@ sub reservation_failed {
notify($ERRORS{'OK'}, 0, "exiting 0");
exit 0;
} ## end if (is_request_deleted($request_id))
-
+
+ # Never set inuse requests to failed, set the state back to inuse
+ if ($request_state_name eq 'inuse') {
+ $self->state_exit('inuse', 'inuse');
+ }
+
# Display the message
notify($ERRORS{'CRITICAL'}, 0, "reservation failed on $computer_short_name: $message");
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1520583&r1=1520582&r2=1520583&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Fri Sep 6 14:36:49 2013
@@ -1564,13 +1564,22 @@ EOF
# Call the database execute subroutine
my $result = database_execute($update_statement);
- if ($result) {
+ if (defined($result)) {
my $rows_updated = (sprintf '%d', $result);
if ($rows_updated) {
- #notify($ERRORS{'OK'}, $LOGFILE, "request $request_id state updated to: $state_name, laststate to: $laststate_name, rows updated: $rows_updated");
+ notify($ERRORS{'OK'}, $LOGFILE, "request $request_id state updated to: $state_name, laststate to: $laststate_name");
+ return 1;
}
else {
- notify($ERRORS{'OK'}, $LOGFILE, "request $request_id state updated to: $state_name, laststate to: $laststate_name, rows updated: $rows_updated");
+ my ($current_state_name, $current_laststate_name) = get_request_current_state_name($request_id);
+ if ($state_name eq $current_state_name && $laststate_name eq $current_laststate_name) {
+ notify($ERRORS{'OK'}, $LOGFILE, "request $request_id state already set to: $current_state_name/$current_laststate_name");
+ return 1;
+ }
+ else {
+ notify($ERRORS{'WARNING'}, $LOGFILE, "failed to update request $request_id state to: $state_name/$laststate_name, current state: $current_state_name/$current_laststate_name");
+ return;
+ }
}
return $rows_updated;
}