Added a global variable to force fresh SSH connections.

Signed-off-by: digimer <mkelly@alteeve.ca>
This commit is contained in:
digimer 2024-02-16 23:28:58 -05:00
parent 5517e43a81
commit a9850bef4e
4 changed files with 27 additions and 0 deletions

View File

@ -908,6 +908,9 @@ sub _set_defaults
manage => { manage => {
firewall => 1, firewall => 1,
}, },
net => {
always_reconnect => 0,
},
password => { password => {
algorithm => "sha512", algorithm => "sha512",
hash_count => 500000, hash_count => 500000,

View File

@ -338,6 +338,21 @@ sub call
password => $anvil->Log->is_secure($password), password => $anvil->Log->is_secure($password),
}}); }});
} }
# Is the global "always reconnect" is set, set 'close' to 1 and clear any cached connections.
$anvil->data->{sys}{net}{always_reconnect} = 0 if not defined $anvil->data->{sys}{net}{always_reconnect};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::net::always_reconnect" => $anvil->data->{sys}{net}{always_reconnect},
}});
if ($anvil->data->{sys}{net}{always_reconnect})
{
$close = 1;
$no_cache = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
'close' => $close,
no_cache => $no_cache,
}});
}
### NOTE: This caused problems that are currently unsolved. ### NOTE: This caused problems that are currently unsolved.
=cut =cut

View File

@ -52,6 +52,12 @@ if (($< != 0) && ($> != 0))
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# Because we're working with the network config, we can't reliable use cached connections.
$anvil->data->{sys}{net}{always_reconnect} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => {
"sys::net::always_reconnect" => $anvil->data->{sys}{net}{always_reconnect},
}});
# Connect # Connect
$anvil->Database->connect({debug => 2, check_for_resync => 1}); $anvil->Database->connect({debug => 2, check_for_resync => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "message_0031"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "message_0031"});

View File

@ -139,6 +139,9 @@ sub check_Storage_groups
debug => 2, debug => 2,
anvil_uuid => $anvil_uuid, anvil_uuid => $anvil_uuid,
}); });
# Reload in case we created one.
$anvil->Database->get_storage_group_data({debug => 2});
} }
return(0); return(0);