Author: arkurth Date: Fri Jun 19 19:12:42 2009 New Revision: 786633 URL: http://svn.apache.org/viewvc?rev=786633&view=rev Log: VCL-165 Added check to utils.pm::write_currentimage_txt to make sure $ssh_output is defined before trying to access it. This was causing processes to die and be left in the pending state because the following error occurred: "Can't use an undefined value as an ARRAY reference"
Added "return 0" to the capture() sub in vmware.pm, xCAT.pm, and xCAT21.pm if write_currentimage_txt failed. It wasn't catching this. Not having the correct currentimage.txt saved in an image may cause unnecessary reloads. Added several checks in vmware.pm to make sure result is defined after running run_ssh_command before attempting to use it. If ssh command failed, the process would die because of a "Can't use an undefined value as an ARRAY reference" error and the reservation would be left in the pending state. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm?rev=786633&r1=786632&r2=786633&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm Fri Jun 19 19:12:42 2009 @@ -1203,6 +1203,7 @@ } else { notify($ERRORS{'WARNING'}, 0, "$notify_prefix unable to update currentimage.txt on $computer_shortname"); + return 0; } # Set some vm paths and names @@ -1885,6 +1886,10 @@ #common checks notify($ERRORS{'OK'}, 0, "checking for base image on $hostnode $datastorepath"); @sshcmd = run_ssh_command($hostnode, $identity, "ls -1 $datastorepath", "root"); + if (!...@sshcmd) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: ls -1 $datastorepath"); + return 0; + } notify($ERRORS{'OK'}, 0, "@{ $sshcmd[1] }"); foreach my $l (@{$sshcmd[1]}) { if ($l =~ /denied|No such/) { @@ -1918,6 +1923,10 @@ ##find the correct vmx file for this node -- if running undef @sshcmd; @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd -l", "root"); + if (!...@sshcmd) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd -l"); + return 0; + } foreach my $l (@{$sshcmd[1]}) { chomp($l); next if ($l =~ /Warning:/); @@ -1931,12 +1940,20 @@ notify($ERRORS{'OK'}, 0, "my vmx $l_myvmx"); my @sshcmd_1 = run_ssh_command($hostnode, $identity, "vmware-cmd $l_myvmx getstate"); + if (!...@sshcmd_1) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd $l_myvmx getstate"); + return 0; + } foreach my $l (@{$sshcmd_1[1]}) { if ($l =~ /= off/) { #good - move on } elsif ($l =~ /= on/) { my @sshcmd_2 = run_ssh_command($hostnode, $identity, "vmware-cmd $l_myvmx stop hard"); + if (!...@sshcmd_2) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd $l_myvmx stop hard"); + return 0; + } foreach my $l (@{$sshcmd_2[1]}) { next if ($l =~ /Warning:/); if ($l =~ /= 1/) { @@ -1953,6 +1970,10 @@ #list processes for vmx and kill pid notify($ERRORS{'OK'}, 0, "vm reported in stuck state, attempting to kill process"); my @ssh_pid = run_ssh_command($hostnode, $identity, "vmware-cmd -q $l_myvmx getpid"); + if (!...@ssh_pid) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd -q $l_myvmx getpid"); + return 0; + } foreach my $p (@{$ssh_pid[1]}) { if ($p =~ /(\D*)(\s*)([0-9]*)/) { notify($ERRORS{'OK'}, 0, "vm pid= $3"); @@ -1970,6 +1991,10 @@ #unregister undef @sshcmd_1; @sshcmd_1 = run_ssh_command($hostnode, $identity, "vmware-cmd -s unregister $l_myvmx "); + if (!...@sshcmd_1) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd -s unregister $l_myvmx"); + return 0; + } foreach my $l (@{$sshcmd_1[1]}) { notify($ERRORS{'OK'}, 0, "vm $l_myvmx unregistered") if ($l =~ /= 1/); } @@ -1992,6 +2017,10 @@ notify($ERRORS{'OK'}, 0, "turning off $myvmx"); undef @sshcmd; @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd $myvmx stop hard", "root"); + if (!...@sshcmd) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd $myvmx stop hard"); + return 0; + } foreach my $l (@{$sshcmd[1]}) { if ($l) { notify($ERRORS{'OK'}, 0, "$myvmx strange output $l"); @@ -2002,6 +2031,10 @@ #confirm undef @sshcmd; @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd $myvmx getstate", "root"); + if (!...@sshcmd) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd $myvmx getstate7"); + return 0; + } foreach my $l (@{$sshcmd[1]}) { if ($l =~ /= off/) { #good Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=786633&r1=786632&r2=786633&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Fri Jun 19 19:12:42 2009 @@ -1237,6 +1237,7 @@ } else { notify($ERRORS{'WARNING'}, 0, "unable to update currentimage.txt on $computer_short_name"); + return 0; } # Check if pre_capture() subroutine has been implemented by the OS module Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm?rev=786633&r1=786632&r2=786633&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm Fri Jun 19 19:12:42 2009 @@ -1334,6 +1334,7 @@ } else { notify($ERRORS{'WARNING'}, 0, "unable to update currentimage.txt on $computer_short_name"); + return 0; } # Check if pre_capture() subroutine has been implemented by the OS module Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=786633&r1=786632&r2=786633&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Fri Jun 19 19:12:42 2009 @@ -6953,10 +6953,14 @@ notify($ERRORS{'OK'}, 0, "created currentimage.txt file on $computer_node_name:\n" . join "\n", @{$ssh_output}); return 1; } - else { + elsif (defined($ssh_output)) { notify($ERRORS{'WARNING'}, 0, "failed to create currentimage.txt file on $computer_node_name:\n" . join "\n", @{$ssh_output}); return; } + else { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to create currentimage.txt file on $computer_node_name"); + return; + } } ## end sub write_currentimage_txt