* Fixed a bug with deleting bad keys where jobs to delete keys on non-dashboard machine wasn't being assigned to the proper target machine.

* Fixed a bug with anvil-manage-keys where a state_uuid entry recorded on one database may not be read from a machine reading from another database.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 16c20ae69c
commit e15c1651ed
  1. 53
      cgi-bin/striker
  2. 20
      tools/anvil-manage-keys

@ -1282,13 +1282,13 @@ sub process_keys
{ {
my ($anvil) = @_; my ($anvil) = @_;
### NOTE: This doesn't update Striker (the Alteeve) stack yet, just the base OK. ### NOTE: This doesn't update Striker (the Alteeve) stack yet, just the base OS.
my $show_list = 1; my $show_list = 1;
$anvil->data->{cgi}{'delete'}{value} = "" if not defined $anvil->data->{cgi}{'delete'}{value}; $anvil->data->{cgi}{'delete'}{value} = "" if not defined $anvil->data->{cgi}{'delete'}{value};
if ($anvil->data->{cgi}{'delete'}{value}) if ($anvil->data->{cgi}{'delete'}{value})
{ {
# Record the job! # Record the job!
my $job_data = ""; my $job_data = {};
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{cgi}}) foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{cgi}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { key => $key }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { key => $key }});
@ -1296,34 +1296,63 @@ sub process_keys
{ {
my $state_uuid = $1; my $state_uuid = $1;
$show_list = 0; $show_list = 0;
$job_data .= $state_uuid.",";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
state_uuid => $state_uuid, state_uuid => $state_uuid,
show_list => $show_list, show_list => $show_list,
job_data => $job_data, }});
my $query = "SELECT state_host_uuid FROM states WHERE state_uuid = ".$anvil->Database->quote($state_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $host_uuid = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$host_uuid = "" if not defined $host_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_uuid => $host_uuid }});
next if not $host_uuid;
if (not exists $job_data->{$host_uuid})
{
$job_data->{$host_uuid} = "";
}
$job_data->{$host_uuid} .= $state_uuid.",";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"job_data->{$host_uuid}" => $job_data->{$host_uuid},
}}); }});
} }
} }
$job_data =~ s/,$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_data => $job_data }});
if ($job_data) my $show_template = 0;
foreach my $host_uuid (keys %{$job_data})
{
$job_data->{$host_uuid} =~ s/,$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"job_data->{$host_uuid}" => $job_data->{$host_uuid},
}});
if ($job_data->{$host_uuid})
{ {
$show_template = 1;
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({ my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
file => $THIS_FILE, file => $THIS_FILE,
line => __LINE__, line => __LINE__,
job_command => $anvil->data->{path}{exe}{'anvil-manage-keys'}.$anvil->Log->switches, job_command => $anvil->data->{path}{exe}{'anvil-manage-keys'}.$anvil->Log->switches,
job_data => $job_data, job_data => $job_data->{$host_uuid},
job_name => "manage::broken_keys", job_name => "manage::broken_keys",
job_title => "job_0056", job_title => "job_0056",
job_description => "job_0057", job_description => "job_0057",
job_progress => 0, job_progress => 0,
job_host_uuid => $anvil->data->{sys}{host_uuid}, job_host_uuid => $host_uuid,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
show_template => $show_template,
job_uuid => $job_uuid,
}});
}
}
# We don't need to store anything as hidden variables, we'll read it back from the database if ($show_template)
# later. {
# We don't need to store anything as hidden variables, we'll read it back from the
# database later.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "job recorded", variables => { $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "job recorded", variables => {
title_id => "", title_id => "",
message_id => "", message_id => "",

@ -41,8 +41,8 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list
'switches::job-uuid' => $anvil->data->{switches}{'job-uuid'}, 'switches::job-uuid' => $anvil->data->{switches}{'job-uuid'},
}}); }});
$anvil->Database->connect(); $anvil->Database->connect({check_for_resync => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections}) if (not $anvil->data->{sys}{database}{connections})
{ {
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try # No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try
@ -85,13 +85,25 @@ WHERE
state_uuid = ".$anvil->Database->quote($state_uuid)." state_uuid = ".$anvil->Database->quote($state_uuid)."
;"; ;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
# States aren't sync'ed, so we may need to check both/all DBs to find our data.
my $state_found = 0;
my $results = [];
foreach my $uuid (keys %{$anvil->data->{cache}{database_handle}})
{
$results = $anvil->Database->query({uuid => $uuid, query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
if (not $count) if ($count)
{
$state_found = 1;
last;
}
}
if (not $state_found)
{ {
# No bad keys found on this host. # No bad keys found on this host.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0078"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0078"});

Loading…
Cancel
Save