Author: arkurth
Date: Fri Oct 17 19:16:09 2014
New Revision: 1632652

URL: http://svn.apache.org/r1632652
Log:
VCL-793
Updated State.pm::reservation_failed to catch a case where a 'deleted' process 
failed. The code was just checking for is_request_deleted, then setting the 
computer to available and leaving the request state intact. This caused vcld to 
attempt to spawn deleted processes indefinitely if there was a problem with the 
host.

VCL-685
Added DESTROY subroutine to vSphere_SDK.pm with an explicit call to 
Util::disconnect. The call is wrapped in an eval block and the die handler is 
overridden. Hoping to fix intermittent condition where die is called 
automatically when a process exits.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
    vcl/trunk/managementnode/lib/VCL/Module/State.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm?rev=1632652&r1=1632651&r2=1632652&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm 
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VIM_SSH.pm Fri 
Oct 17 19:16:09 2014
@@ -168,6 +168,7 @@ sub _run_vim_cmd {
        
        my $timeout_seconds = shift || 60;
        
+       my $request_state_name = $self->data->get_request_state_name();
        my $vmhost_computer_name = 
$self->vmhost_os->data->get_computer_short_name();
        
        my $command = "$self->{vim_cmd} $vim_arguments";
@@ -242,14 +243,13 @@ sub _run_vim_cmd {
                        # Problem probably won't correct itself
                        # If request state is 'inuse', set the 
reservation.lastcheck value to 20 minutes before request.end
                        # This avoids 'inuse' processes from being created over 
and over again which will fail
-                       my $request_state_name = 
$self->data->get_request_state_name();
-                       #if ($request_state_name eq 'inuse') {
+                       if ($request_state_name eq 'inuse') {
                                my $reservation_id = 
$self->data->get_reservation_id();
                                my $request_end_time_epoch = 
convert_to_epoch_seconds($self->data->get_request_end_time());
                                my $current_time_epoch = time;
                                my $reservation_lastcheck_epoch = 
($request_end_time_epoch-(20*60));
                                set_reservation_lastcheck($reservation_id, 
$reservation_lastcheck_epoch);
-                       #}
+                       }
                        return;
                }
                else {

Modified: 
vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm?rev=1632652&r1=1632651&r2=1632652&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm 
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm 
Fri Oct 17 19:16:09 2014
@@ -4203,6 +4203,29 @@ sub is_multiextent_disabled {
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 DESTROY
+
+ Parameters  : none
+ Returns     : nothing
+ Description : Calls Util::disconnect to attempt to exit gracefully.
+
+=cut
+
+sub DESTROY {
+       local $SIG{__DIE__} = sub{};
+       eval {
+               Util::disconnect();
+       };
+       if ($EVAL_ERROR) {
+               notify($ERRORS{'WARNING'}, 0, "error generated calling 
Util::disconnect:\n$EVAL_ERROR");
+       }
+       else {
+               notify($ERRORS{'DEBUG'}, 0, "called Util::disconnect");
+       }
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 1;
 __END__
 

Modified: vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=1632652&r1=1632651&r2=1632652&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/State.pm Fri Oct 17 19:16:09 2014
@@ -260,7 +260,9 @@ sub reservation_failed {
        my $computer_state_name         = 
$self->data->get_computer_state_name();
        
        # Check if the request has been deleted
-       if (is_request_deleted($request_id)) {
+       # Ignore if this process's state is deleted
+       # If a 'deleted' request fails during initialization and before the 
request state was changed to 'pending', vcld will try to process over and over 
again
+       if ($request_state_name ne 'deleted' && 
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
@@ -294,6 +296,10 @@ sub reservation_failed {
                $new_request_state_name = 'maintenance';
                $new_computer_state_name = 'maintenance';
        }
+       elsif ($request_state_name eq 'deleted') {
+               $new_request_state_name = 'complete';
+               $new_computer_state_name = 'failed';
+       }
        elsif ($computer_input_state) {
           $new_request_state_name = 'failed';
           $new_computer_state_name = $computer_input_state;
@@ -627,13 +633,13 @@ sub state_exit {
                # If parent of a cluster request, wait for child processes to 
exit before switching the state
                if ($reservation_count > 1) {
                        $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';
+                       
+                       # 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';
+                               }
                        }
                }
                


Reply via email to