Author: arkurth
Date: Tue Feb 3 18:40:04 2015
New Revision: 1656882
URL: http://svn.apache.org/r1656882
Log:
VCL-16
Added code to State.pm::state_exit to check the state of computers when the
parent of a cluster request exits. If the request failed, the state of
computers assigned to child reservations which did not fail could be left in
'reloading'. If this is the case, the parent changes the state to available.
Cleaned up utils.pm::get_computer_current_state_name.
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=1656882&r1=1656881&r2=1656882&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/State.pm Tue Feb 3 18:40:04 2015
@@ -114,12 +114,12 @@ sub initialize {
$self->data->set_reservation_lastcheck_time($reservation_lastcheck);
}
- # If this is a cluster request, wait for all reservations to begin
before proceeding
- if ($reservation_count > 1) {
- if (!$self->wait_for_all_reservations_to_begin('begin', 90, 5))
{
- $self->reservation_failed("failed to detect start of
processing for all reservation processes", 'available');
- }
- }
+ #### If this is a cluster request, wait for all reservations to begin
before proceeding
+ ###if ($reservation_count > 1) {
+ ### if (!$self->wait_for_all_reservations_to_begin('begin', 90, 5))
{
+ ### $self->reservation_failed("failed to detect start of
processing for all reservation processes", 'available');
+ ### }
+ ###}
# Parent reservation needs to update the request state to pending
if ($is_parent_reservation) {
@@ -815,10 +815,33 @@ sub state_exit {
$self->wait_for_child_reservations_to_exit();
# Check if any reservations failed
- if (!$request_state_name_new || $request_state_name_new
ne 'failed') {
- if
($self->does_loadstate_exist_any_reservation('failed')) {
- notify($ERRORS{'OK'}, 0, "another
reservation failed, request state will be updated to 'failed'");
- $request_state_name_new = 'failed';
+ my @failed_reservation_ids =
$self->does_loadstate_exist_any_reservation('failed');
+ if (@failed_reservation_ids &&
(!$request_state_name_new || $request_state_name_new ne 'failed')) {
+ notify($ERRORS{'OK'}, 0, "another reservation
failed, request state will be updated to 'failed'");
+ $request_state_name_new = 'failed';
+ }
+
+ if ($request_state_name_new eq 'failed') {
+ # Child reservations will leave the state of
the computer to 'reloading' if they didn't fail
+ # Need to change state back to available for
child reservations which didn't fail
+ for my $cluster_reservation_id
(@reservation_ids) {
+ next if $cluster_reservation_id eq
$reservation_id;
+
+ my $reservation_data =
$self->data->get_reservation_data($cluster_reservation_id) || next;
+ my $reservation_computer_id =
$reservation_data->get_computer_id() || next;
+ my $reservation_computer_hostname =
$reservation_data->get_computer_hostname() || next;
+ if (!(grep { $_ eq
$cluster_reservation_id } @failed_reservation_ids)) {
+ notify($ERRORS{'DEBUG'}, 0,
"child reservation $cluster_reservation_id did not fail, checking state of
computer assigned to reservation: $reservation_computer_id");
+
+ my $computer_current_state_name
= get_computer_current_state_name($reservation_computer_id) || next;
+ if
($computer_current_state_name =~ /(reloading)/) {
+
notify($ERRORS{'DEBUG'}, 0, "state of computer $reservation_computer_id
assigned to child reservation $cluster_reservation_id is
$computer_current_state_name, reservation did not fail, changing state to
available");
+
update_computer_state($reservation_computer_id, 'available');
+ }
+ else {
+
notify($ERRORS{'DEBUG'}, 0, "state of computer $reservation_computer_id
assigned to child reservation $cluster_reservation_id is
$computer_current_state_name, reservation did not fail, state of computer will
not be changed");
+ }
+ }
}
}
}
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1656882&r1=1656881&r2=1656882&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Tue Feb 3 18:40:04 2015
@@ -5144,7 +5144,7 @@ EOF
=head2 get_computer_current_state_name
Parameters : $computer_id
- Returns : String containing state name for a particular computer
+ Returns : string
Description :
=cut
@@ -5152,48 +5152,37 @@ EOF
sub get_computer_current_state_name {
my ($computer_id) = @_;
-
- my ($package, $filename, $line, $sub) = caller(0);
-
- # Check the passed parameter
if (!(defined($computer_id))) {
- notify($ERRORS{'WARNING'}, 0, "computer ID was not specified");
- return ();
+ notify($ERRORS{'WARNING'}, 0, "computer ID argument was not
specified");
+ return;
}
# Create the select statement
- my $select_statement = "
- SELECT DISTINCT
- state.name AS name
- FROM
- state,
- computer
- WHERE
- computer.stateid = state.id
- AND computer.id = $computer_id
- ";
+ my $select_statement = <<EOF;
+SELECT
+state.name
+FROM
+state,
+computer
+WHERE
+computer.stateid = state.id
+AND computer.id = $computer_id
+EOF
# Call the database select subroutine
# This will return an array of one or more rows based on the select
statement
- my @selected_rows = database_select($select_statement);
+ my @rows = database_select($select_statement);
# Check to make sure 1 row was returned
- if (scalar @selected_rows == 0) {
- notify($ERRORS{'WARNING'}, 0, "zero rows were returned from
database select");
- return ();
- }
- elsif (scalar @selected_rows > 1) {
- notify($ERRORS{'WARNING'}, 0, "" . scalar @selected_rows . "
rows were returned from database select");
- return ();
- }
-
- # Make sure we return undef if the column wasn't found
- if (defined $selected_rows[0]{name}) {
- return $selected_rows[0]{name};
- }
- else {
- return undef;
+ if (!@rows) {
+ notify($ERRORS{'WARNING'}, 0, "failed to retrieve current
computer state, no rows were returned from database select
statement:\n$select_statement");
+ return;
}
+
+ my $row = $rows[0];
+ my $state_name = $row->{name};
+ notify($ERRORS{'DEBUG'}, 0, "retrieved current state of computer
$computer_id: $state_name");
+ return $state_name;
} ## end sub get_computer_current_state_name
#/////////////////////////////////////////////////////////////////////////////