Author: arkurth
Date: Wed Oct 26 20:35:44 2016
New Revision: 1766734
URL: http://svn.apache.org/viewvc?rev=1766734&view=rev
Log:
VCL-862
Updated OS.pm::set_tainted_status to accept a $reason argument. This gets added
to currentimage.txt instead of simply 'true'. Updated sub to append to previous
'vcld_tainted' messages instead of overwriting.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
vcl/trunk/managementnode/lib/VCL/reserved.pm
vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1766734&r1=1766733&r2=1766734&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Wed Oct 26 20:35:44 2016
@@ -1370,21 +1370,10 @@ sub update_public_ip_address {
=head2 get_current_image_tag
Parameters : $tag_name
- Returns : string or array
+ Returns : string
Description : Reads currentimage.txt and attempts to locate a line beginning
with the tag name specified by the argument.
-
- If found and called in scalar context, the tag value following
- the = sign is returned. Example currentimage.txt line:
- mytag=0 (Wed Jun 29 17:47:36 2016)
-
- my $x = get_current_image_tag('mytag');
- $x = 0
-
- my ($x, $y) = get_current_image_tag('mytag');
- $x = 0
- $y = 'Wed Jun 29 17:47:36 2016'
-
+ If found, the tag value following the = sign is returned.
Null is returned if a line with the tag name doesn't exist.
=cut
@@ -1408,17 +1397,11 @@ sub get_current_image_tag {
my @lines = $self->get_file_contents($current_image_file_path);
for my $line (@lines) {
- my ($tag_value, $timestamp) = $line =~
/^$tag_name=([^\s]+)\s?\(?(.+)?\)?$/gx;
+ my ($tag_value) = $line =~ /^$tag_name=(.*)$/gx;
if (defined($tag_value)) {
- $timestamp = '' if (!defined($timestamp));
- if (wantarray) {
- notify($ERRORS{'DEBUG'}, 0, "found '$tag_name'
tag line in $current_image_file_path: '$line', returning array: ('$tag_value',
'$timestamp')");
- return ($tag_value, $timestamp);
- }
- else {
- notify($ERRORS{'DEBUG'}, 0, "found '$tag_name'
tag line in $current_image_file_path: '$line', returning tag value:
'$tag_value'");
- return $tag_value;
- }
+ $tag_value = '' unless length($tag_value);
+ notify($ERRORS{'DEBUG'}, 0, "found '$tag_name' tag line
in $current_image_file_path: '$line', returning tag value: '$tag_value'");
+ return $tag_value;
}
}
@@ -1492,7 +1475,7 @@ sub set_current_image_tag {
my $computer_name = $self->data->get_computer_short_name();
my $current_image_file_path = 'currentimage.txt';
- my $timestamp = localtime;
+ my $timestamp = makedatestring();
my $tag_line = "$tag_name=$tag_value ($timestamp)";
my $updated_contents = '';
@@ -1558,9 +1541,9 @@ sub get_post_load_status {
my $computer_name = $self->data->get_computer_short_name();
- my ($post_load_value, $timestamp) =
$self->get_current_image_tag('vcld_post_load');
- if (defined($post_load_value)) {
- notify($ERRORS{'DEBUG'}, 0, "post-load tasks have been
completed on $computer_name: $post_load_value ($timestamp)");
+ my ($post_load_status) = $self->get_current_image_tag('vcld_post_load');
+ if (defined($post_load_status)) {
+ notify($ERRORS{'DEBUG'}, 0, "post-load tasks have been
completed on $computer_name: $post_load_status");
return 1;
}
else {
@@ -1573,7 +1556,7 @@ sub get_post_load_status {
=head2 set_tainted_status
- Parameters : none
+ Parameters : $reason (optional)
Returns : boolean
Description : Adds a line to currentimage.txt indicating a loaded computer is
tainted and must be reloaded for any subsequent reservations.
@@ -1603,7 +1586,16 @@ sub set_tainted_status {
return;
}
- return $self->set_current_image_tag('vcld_tainted', 'true');
+ my $reason = shift || 'no reason given';
+
+ # This may be called multiple times for a reservation
+ # It's useful to append concatenate the status rather than overwriting
it so you know all of the reasons a computer may be tainted
+ my $previous_tained_status = $self->get_tainted_status();
+ if ($previous_tained_status) {
+ $reason = "$previous_tained_status, $reason";
+ }
+
+ return $self->set_current_image_tag('vcld_tainted', $reason);
}
#/////////////////////////////////////////////////////////////////////////////
@@ -1611,7 +1603,7 @@ sub set_tainted_status {
=head2 get_tainted_status
Parameters : none
- Returns : boolean
+ Returns : string
Description : Checks if a line exists in currentimage.txt indicated a user may
have logged in.
@@ -1626,10 +1618,10 @@ sub get_tainted_status {
my $computer_name = $self->data->get_computer_short_name();
- my ($tainted_value, $timestamp) =
$self->get_current_image_tag('vcld_tainted');
- if (defined($tainted_value)) {
- notify($ERRORS{'DEBUG'}, 0, "image currently loaded on
$computer_name has been tainted: $tainted_value ($timestamp)");
- return 1;
+ my $tainted_status = $self->get_current_image_tag('vcld_tainted');
+ if (defined($tainted_status)) {
+ notify($ERRORS{'DEBUG'}, 0, "image currently loaded on
$computer_name has been tainted: $tainted_status");
+ return $tainted_status;
}
else {
notify($ERRORS{'DEBUG'}, 0, "image currently loaded on
$computer_name has NOT been tainted");
@@ -4263,7 +4255,7 @@ sub run_management_node_tools_scripts {
# If the user never connects and the reservation times out, there's no
way to revert these actions in order to clean the computer for another user
# Tag the image as tainted so it is reloaded
if ($stage =~ /(post_reserve)/) {
- $self->set_tainted_status();
+ $self->set_tainted_status('post-reserve scripts residing on the
management node executed');
}
notify($ERRORS{'DEBUG'}, 0, "attempting to execute custom scripts
residing on the management node for $image_name on $computer_node_name:\n" .
join("\n", @computer_tools_files));
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1766734&r1=1766733&r2=1766734&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Wed Oct 26 20:35:44 2016
@@ -610,7 +610,7 @@ sub post_reserve {
# If post_reserve script exists, assume it does user or
reservation-specific actions
# If the user never connects and the reservation times
out, there's no way to revert these actions in order to clean the computer for
another user
# Tag the image as tainted so it is reloaded
- $self->set_tainted_status();
+ $self->set_tainted_status('post-reserve scripts
residing in the image executed');
# Run the vcl_post_reserve script if it exists in the
image
my $result = $self->run_script($script_path, '1',
'300', '1');
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1766734&r1=1766733&r2=1766734&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Wed Oct 26 20:35:44
2016
@@ -1011,7 +1011,7 @@ sub post_reserve {
# If post_reserve script exists, assume it does user or
reservation-specific actions
# If the user never connects and the reservation times out,
there's no way to revert these actions in order to clean the computer for
another user
# Tag the image as tainted so it is reloaded
- $self->set_tainted_status();
+ $self->set_tainted_status('post-reserve scripts residing in the
image executed');
# Run the post_reserve script
$self->run_script($script_path);
Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1766734&r1=1766733&r2=1766734&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Wed Oct 26 20:35:44 2016
@@ -183,7 +183,7 @@ sub process {
notify($ERRORS{'DEBUG'}, 0, "retrieved timestamp of
computerloadlog 'initialconnecttimeout' entry inserted by web frontend:
$connection_check_start_epoch_seconds");
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to retrieve
timestamp of computerloadlog 'initialconnecttimeout' entry, web frontend should
have inserted this, inserting new entry");
+ notify($ERRORS{'DEBUG'}, 0, "could not retrieve
timestamp of computerloadlog 'initialconnecttimeout' entry, web frontend should
have inserted this, inserting new entry");
$connection_check_start_epoch_seconds = time;
insertloadlog($reservation_id, $computer_id,
"initialconnecttimeout", "begin initial connection timeout
($initial_connect_timeout_seconds seconds)");
}
@@ -262,7 +262,7 @@ sub process {
}
# Add a line to currentimage.txt indicating it's possible a user logged
on to the computer
- $self->os->set_tainted_status();
+ $self->os->set_tainted_status('user may have logged in');
# Update reservation lastcheck, otherwise inuse request will be
processed immediately again
update_reservation_lastcheck($reservation_id);
Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1766734&r1=1766733&r2=1766734&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Wed Oct 26 20:35:44 2016
@@ -9071,7 +9071,7 @@ sub get_reservation_computerloadlog_time
# Get all computerloadlog entries for the reservation
my @computerloadlog_entries =
get_reservation_computerloadlog_entries($reservation_id);
if (!@computerloadlog_entries) {
- notify($ERRORS{'WARNING'}, 0, "failed to retrieve timestamp of
computerloadlog '$loadstatename' entry for reservation $reservation_id,
computerloadlog entries could not be retrieved");
+ notify($ERRORS{'OK'}, 0, "computerloadlog entry does not exist
for reservation $reservation_id");
return;
}
@@ -9090,7 +9090,7 @@ sub get_reservation_computerloadlog_time
return $timestamp_epoch;
}
else {
- notify($ERRORS{'WARNING'}, 0, "failed to retrieve $type
timestamp of first '$loadstatename' computerloadlog entry for reservation
$reservation_id");
+ notify($ERRORS{'OK'}, 0, "no '$loadstatename' computerloadlog
entries exist for reservation $reservation_id");
return;
}
}