* Fixed a bug in anvil-daemon where rebooting was clearing the reboot-needed flag.

* Finished (for now) adding support for monitoring jobs while a node is in maintenance mode!
* Cleaned up the display of job data and redid how buttons (real and classed links) are displayed to be consistent.
* Fixed a bug in anvil-daemon where a disconnect wasn't being called between loops, causing DB connections to pile up.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 93124ea3ae
commit 423fda2ad6
  1. 1
      Anvil/Tools.pm
  2. 1
      Anvil/Tools/Database.pm
  3. 1
      cgi-bin/striker
  4. 6
      html/skins/alteeve/config.html
  5. 32
      html/skins/alteeve/jobs.js
  6. 28
      html/skins/alteeve/main.css
  7. 72
      html/skins/alteeve/striker.html
  8. 3
      share/words.xml
  9. 26
      tools/anvil-daemon
  10. 4
      tools/anvil-update-system

@ -888,6 +888,7 @@ sub _set_paths
'anvil-manage-striker-peers' => "/usr/sbin/anvil-manage-striker-peers", 'anvil-manage-striker-peers' => "/usr/sbin/anvil-manage-striker-peers",
'anvil-prep-database' => "/usr/sbin/anvil-prep-database", 'anvil-prep-database' => "/usr/sbin/anvil-prep-database",
'anvil-update-states' => "/usr/sbin/anvil-update-states", 'anvil-update-states' => "/usr/sbin/anvil-update-states",
'anvil-reboot-needed' => "/usr/sbin/anvil-reboot-needed",
'anvil-report-memory' => "/usr/sbin/anvil-report-memory", 'anvil-report-memory' => "/usr/sbin/anvil-report-memory",
'chmod' => "/usr/bin/chmod", 'chmod' => "/usr/bin/chmod",
'chown' => "/usr/bin/chown", 'chown' => "/usr/bin/chown",

@ -1207,6 +1207,7 @@ sub disconnect
# Set the connection count to 0. # Set the connection count to 0.
$anvil->data->{sys}{database}{connections} = 0; $anvil->data->{sys}{database}{connections} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::database::connections" => $anvil->data->{sys}{database}{connections} }});
return(0); return(0);
} }

@ -839,6 +839,7 @@ sub check_availability
title => $say_title, title => $say_title,
description => $say_description, description => $say_description,
progress_bar => "job_progress_".$job_uuid, progress_bar => "job_progress_".$job_uuid,
progress_percent => "job_progress_percent_".$job_uuid,
status => "job_status_".$job_uuid, status => "job_status_".$job_uuid,
}}); }});

@ -94,7 +94,7 @@
<td> <td>
<br /> <br />
<hr> <hr>
<input type="submit" name="next" id="next" value="#!string!striker_0013!#"> <input type="submit" name="next" id="next" class="button" value="#!string!striker_0013!#">
</td> </td>
</tr> </tr>
<!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. --> <!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. -->
@ -228,7 +228,7 @@
<td colspan="2"> <td colspan="2">
<br /> <br />
<hr> <hr>
<input type="submit" name="next" id="next" value="#!string!striker_0013!#"> <input type="submit" name="next" id="next" class="button" value="#!string!striker_0013!#">
</td> </td>
</tr> </tr>
<input type="hidden" name="bcn_count" id="bcn_count" value="#!variable!bcn_count!#"> <input type="hidden" name="bcn_count" id="bcn_count" value="#!variable!bcn_count!#">
@ -319,7 +319,7 @@
<td> <td>
<br /> <br />
<hr> <hr>
<input type="submit" name="next" id="next" value="#!string!striker_0043!#"> <input type="submit" name="next" id="next" class="button" value="#!string!striker_0043!#">
</td> </td>
</tr> </tr>
<!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. --> <!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. -->

@ -3,25 +3,43 @@ $.ajaxSetup({
}); });
// TODO: Loop through jobs found on HTML and hide and divs that aren't found in jobs.json. // TODO: Loop through jobs found on HTML and hide and divs that aren't found in jobs.json.
$(function() { $(function() {
var say_status_waiting = $('input#status_waiting').val();
if($("#running_jobs").length) { if($("#running_jobs").length) {
console.log('Looking for running jobs.'); //console.log('Looking for running jobs.');
setInterval(function() { setInterval(function() {
$.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) { $.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) {
$.each(data.jobs, function(index, element) { $.each(data.jobs, function(index, element) {
var progress = element.job_progress var progress = element.job_progress;
console.log('entry: ['+index+'], uuid: ['+element.job_uuid+'], progress: ['+progress+']'); var status = element.job_status;
//console.log('status: ['+element.job_status+']'); var status_length = status.length;
//console.log('entry: ['+index+'], uuid: ['+element.job_uuid+'], progress: ['+progress+']');
// Initialize // Show the status, if there is any yet.
if (!status.length)
{
$("#job_status_"+element.job_uuid).removeClass('job_output');
$("#job_status_"+element.job_uuid).addClass('subtle_text');
$("#job_status_"+element.job_uuid).html('&lt;'+say_status_waiting+'&gt;');
//console.log('status is waiting');
}
else
{
$("#job_status_"+element.job_uuid).removeClass('subtle_text');
$("#job_status_"+element.job_uuid).addClass('job_output');
$("#job_status_"+element.job_uuid).html(status);
//console.log('status: ['+status+']');
}
// Push data
$("#job_progress_"+element.job_uuid).progressbar({value: parseInt(element.job_progress)}); $("#job_progress_"+element.job_uuid).progressbar({value: parseInt(element.job_progress)});
$("#job_status_"+element.job_uuid).html(element.job_status); $("#job_progress_percent_"+element.job_uuid).html(element.job_progress+'%');
}); });
}); });
}, 1000); }, 1000);
} }
else else
{ {
alert('Jobs status not loaded.'); //console.log('Jobs status not loaded.');
} }
}); });

@ -121,6 +121,11 @@ td.column_header {
color: #9ba0a5; color: #9ba0a5;
padding: 0.15em; padding: 0.15em;
} }
.column_header {
text-align: left;
color: #9ba0a5;
padding: 0.15em;
}
td.column_row_name { td.column_row_name {
text-align: left; text-align: left;
@ -281,8 +286,13 @@ td {
} }
.button { .button {
padding: 10px 5px; color: #343434;
text-align: center; font: 0.9em 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
text-decoration: none;
background-color: #f2f2f2;
padding: 5px 10px 5px 10px;
border: 1px solid #343434;
border-radius: 3px;
} }
.icon_button { .icon_button {
@ -309,3 +319,17 @@ td {
padding: 0.2em; padding: 0.2em;
font-size: 0.9em; font-size: 0.9em;
} }
.job_table {
border-left: 1px dotted #d02724;
}
.job_status {
border: 1px solid #9ba0a5;
}
.job_output {
font: 0.8em 'Dejavu Sans Mono', Courier;
color: #d2e2d2;
white-space: nowrap;
}

@ -45,8 +45,11 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="button_cell" colspan="2"> <td class="button_cell" style="text-align: left;">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#"> <a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td> </td>
</tr> </tr>
<input type="hidden" name="new_peer_access" id="new_peer_access" value="#!data!cgi::new_peer_access::value!#"> <input type="hidden" name="new_peer_access" id="new_peer_access" value="#!data!cgi::new_peer_access::value!#">
@ -69,23 +72,26 @@
<form name="confirm-reconfig" action="" method="post"> <form name="confirm-reconfig" action="" method="post">
<div id="confirm-reconfig"> <div id="confirm-reconfig">
<tr> <tr>
<td class="menu_title"> <td class="menu_title" colspan="2">
#!string!striker_0078!# #!string!striker_0078!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="menu_details"> <td class="menu_details" colspan="2">
#!string!striker_0083!# #!string!striker_0083!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td colspan="2">
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="button_cell" colspan="2"> <td class="button_cell" style="text-align: left;">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#"> <a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td> </td>
</tr> </tr>
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#"> <input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
@ -101,23 +107,26 @@
<form name="confirm-update" action="" method="post"> <form name="confirm-update" action="" method="post">
<div id="confirm-update"> <div id="confirm-update">
<tr> <tr>
<td class="menu_title"> <td class="menu_title" colspan="2">
#!string!striker_0078!# #!string!striker_0078!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="menu_details"> <td class="menu_details" colspan="2">
#!string!striker_0086!# #!string!striker_0086!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td colspan="2">
&nbsp; &nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="button_cell" colspan="2"> <td class="button_cell" style="text-align: left;">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#"> <a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td> </td>
</tr> </tr>
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#"> <input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
@ -147,7 +156,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/" class="button">#!string!striker_0053!#</a> <a href="/cgi-bin/striker" class="button">#!string!striker_0053!#</a>
</td> </td>
</tr> </tr>
</table> </table>
@ -171,7 +180,7 @@
&nbsp; &nbsp;
</td> </td>
<td> <td>
<input type="submit" name="login" id="login" value="#!string!striker_0049!#"> <input type="submit" name="login" id="login" class="button" value="#!string!striker_0049!#">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -186,7 +195,7 @@
<!-- end striker-login --> <!-- end striker-login -->
<!-- start striker-offline --> <!-- start striker-offline -->
<table class="centered"> <table class="centered" width="90%">
<tr> <tr>
<td> <td>
&nbsp; &nbsp;
@ -198,8 +207,8 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br /> <span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header3">#!variable!description!#</span> <span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header3">#!variable!description!#</span>
<br /> <br />
<hr> <hr />
<a href="/" class="button">#!string!striker_0053!#</a> <a href="/cgi-bin/striker" class="button">#!string!striker_0053!#</a>
</td> </td>
</tr> </tr>
</div> </div>
@ -212,10 +221,11 @@
<script type="text/javascript" src="/skins/alteeve/jobs.js"></script> <script type="text/javascript" src="/skins/alteeve/jobs.js"></script>
<tr> <tr>
<td> <td>
<input type="hidden" name="status_waiting" id="status_waiting" value="#!string!js_0004!#">
<span name="jobs-title" id="jobs-title" class="config_header2">#!string!header_0011!#</span><br /> <span name="jobs-title" id="jobs-title" class="config_header2">#!string!header_0011!#</span><br />
<span name="jobs-message" id="jobs-message" class="config_header3">#!string!striker_0096!#</span> <span name="jobs-message" id="jobs-message" class="config_header3">#!string!striker_0096!#</span>
<br /> <br />
<hr> <hr />
#!variable!job_list!# #!variable!job_list!#
</td> </td>
</tr> </tr>
@ -226,26 +236,32 @@
<!-- start job-details --> <!-- start job-details -->
<div id="#!variable!div_id!#"> <div id="#!variable!div_id!#">
<br /> <br />
<table style="border: 1px solid white"> <table class="job_table" width="90%">
<tr> <tr>
<td width="50%"> <td width="48%" style="padding-left: 4px;">
<span class="column_header">#!variable!title!#</span> <span class="column_header">#!string!striker_0099!#:</span> #!variable!title!#
</td>
<td width="4%" class="subtle_text" style="text-align: center; white-space: nowrap;">
<div id="#!variable!progress_percent!#"></div>
</td> </td>
<td width="50%"> <td width="48%">
<div id="#!variable!progress_bar!#"></div> <div id="#!variable!progress_bar!#"></div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="3" style="padding-left: 4px;">
<span class="column_row_name">#!variable!description!#</span> <span class="column_row_name">#!variable!description!#</span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="3" style="padding: 6px;">
<div id="#!variable!status!#"></div> <div class="job_status" id="#!variable!status!#"></div>
</td> </td>
</tr> </tr>
</table> </table>
<br />
<hr />
<br />
</div> </div>
<!-- end job-details --> <!-- end job-details -->
@ -399,7 +415,7 @@
</tr> </tr>
<tr> <tr>
<td class="button_cell" colspan="4" align="center"> <td class="button_cell" colspan="4" align="center">
<input type="submit" id="save" name="save" value="#!string!striker_0067!#" /> <input type="submit" id="save" name="save" class="button" value="#!string!striker_0067!#" />
</td> </td>
</tr> </tr>
<input type="hidden" name="striker" value="true" /> <input type="hidden" name="striker" value="true" />
@ -530,7 +546,7 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br /> <span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span> <span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span>
<br /> <br />
<hr> <hr />
<a href="/" class="button">Reload</a> <a href="/" class="button">Reload</a>
</td> </td>
</tr> </tr>
@ -546,7 +562,7 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br /> <span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span> <span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span>
<br /> <br />
<hr> <hr />
<a href="/" class="button">Reload</a> <a href="/" class="button">Reload</a>
</td> </td>
</tr> </tr>

@ -467,6 +467,8 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_0095">This will power off the Striker machine and leave it off. To power it back on, you will need physical access or cycle the power of the PDU feeding this Striker.</key> <key name="striker_0095">This will power off the Striker machine and leave it off. To power it back on, you will need physical access or cycle the power of the PDU feeding this Striker.</key>
<key name="striker_0096">Recent and Running Jobs</key> <key name="striker_0096">Recent and Running Jobs</key>
<key name="striker_0097">There are no jobs currently running or recently completed.</key> <key name="striker_0097">There are no jobs currently running or recently completed.</key>
<key name="striker_0098">Back</key>
<key name="striker_0099">Job</key>
<!-- Strings used by jobs --> <!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key> <key name="job_0001">Configure Network</key>
@ -535,6 +537,7 @@ The update appears to have not completed successfully. The output was:
<key name="js_0001">Up</key> <key name="js_0001">Up</key>
<key name="js_0002">Down</key> <key name="js_0002">Down</key>
<key name="js_0003">Mbps</key> <key name="js_0003">Mbps</key>
<key name="js_0004">waiting for job output...</key>
</language> </language>
<!-- 日本語 --> <!-- 日本語 -->

@ -69,7 +69,7 @@ run_once($anvil) if not $anvil->data->{switches}{'main-loop-only'};
$anvil->Storage->record_md5sums; $anvil->Storage->record_md5sums;
# Disconnect. We'll reconnect inside the loop # Disconnect. We'll reconnect inside the loop
$anvil->Database->disconnect; $anvil->Database->disconnect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"});
# These are the things we always want running. # These are the things we always want running.
@ -77,7 +77,7 @@ while(1)
{ {
# Connect to the database(s) # Connect to the database(s)
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"}); $anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
$anvil->Database->connect; $anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
@ -110,7 +110,8 @@ while(1)
$anvil->nice_exit({code => 0}); $anvil->nice_exit({code => 0});
} }
# Sleep now. # Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect();
sleep 2; sleep 2;
} }
@ -148,7 +149,7 @@ sub run_once
# Clear the reboot request. # Clear the reboot request.
my $output = $anvil->System->call({ my $output = $anvil->System->call({
debug => 2, debug => 2,
shell_call => $anvil->data->{path}{exe}{'anvil-clear-reboot'}, shell_call => $anvil->data->{path}{exe}{'anvil-reboot-needed'}." --set 0",
source => $THIS_FILE, source => $THIS_FILE,
line => __LINE__, line => __LINE__,
}); });
@ -291,6 +292,10 @@ sub run_jobs
### TODO: Add a check to verify the job isn't hung. ### TODO: Add a check to verify the job isn't hung.
# Skip if this job is in progress. # Skip if this job is in progress.
if (not exists $anvil->data->{pids}{$job_picked_up_by}) if (not exists $anvil->data->{pids}{$job_picked_up_by})
{
# If the job is done, just clear the 'job_picked_up_by' and be done.
clear_job($anvil, $job_uuid);
if ($job_progress ne "100")
{ {
# The previous job is gone, but the job isn't finished. Start it again. # The previous job is gone, but the job isn't finished. Start it again.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "striker_warning_0007", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "striker_warning_0007", variables => {
@ -298,24 +303,26 @@ sub run_jobs
pid => $job_picked_up_by, pid => $job_picked_up_by,
percent => $job_progress, percent => $job_progress,
}}); }});
clear_job($anvil, $job_uuid);
# Clear some variables. # Clear some variables.
$job_picked_up_by = 0;
$job_progress = 0; $job_progress = 0;
$job_status = "message_0056"; $job_status = "message_0056";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
job_picked_up_by => $job_picked_up_by,
job_progress => $job_progress, job_progress => $job_progress,
job_status => $job_status, job_status => $job_status,
}}); }});
} }
# Clear the PID
$job_picked_up_by = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_picked_up_by => $job_picked_up_by }});
}
} }
# Convert the double-banged strings into a proper message. # Convert the double-banged strings into a proper message.
my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : ""; my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : ""; my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
my $say_status = $job_progress ? $anvil->Words->parse_banged_string({key_string => $job_status}) : ""; my $say_status = $job_status ? $anvil->Words->parse_banged_string({key_string => $job_status}) : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_title => $job_title, job_title => $job_title,
say_description => $say_description, say_description => $say_description,
@ -323,6 +330,8 @@ sub run_jobs
}}); }});
# Make the status HTML friendly. Strip any embedded HTML then encode the text string. # Make the status HTML friendly. Strip any embedded HTML then encode the text string.
if ($say_status)
{
my $html_strip = HTML::Strip->new(); my $html_strip = HTML::Strip->new();
$say_status = $html_strip->parse($say_status); $say_status = $html_strip->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
@ -335,6 +344,7 @@ sub run_jobs
}); });
$say_status = $text_to_html->parse($say_status); $say_status = $text_to_html->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
}
# Add this to the jobs.json file # Add this to the jobs.json file
my $json_string = to_json ({ my $json_string = to_json ({

@ -147,7 +147,7 @@ update_progress($anvil, 0, "clear");
update_progress($anvil, 1, "message_0033"); update_progress($anvil, 1, "message_0033");
# Make sure maintenance mode is enabled. # Make sure maintenance mode is enabled.
$anvil->System->maintenance_mode({debug => 2, set => 1}); $anvil->System->maintenance_mode({debug => 3, set => 1});
# Run the update # Run the update
run_os_update($anvil); run_os_update($anvil);
@ -165,7 +165,7 @@ else
} }
# Clear maintenance mode. # Clear maintenance mode.
$anvil->System->maintenance_mode({debug => 2, set => 0}); $anvil->System->maintenance_mode({debug => 3, set => 0});
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});

Loading…
Cancel
Save