mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
config/deploy(ments): re-enable stage wiping
This commit is contained in:
parent
d27c8a9948
commit
a6be710379
@ -18,7 +18,7 @@ class ConfigController extends ActionController
|
||||
$this->setAutorefreshInterval(5);
|
||||
try {
|
||||
if ($this->getRequest()->getUrl()->shift('checkforchanges')) {
|
||||
$this->fetchLogs();
|
||||
$this->api()->collectLogFiles($this->db());
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// No problem, Icinga might be reloading
|
||||
@ -57,6 +57,8 @@ class ConfigController extends ActionController
|
||||
$checksum = $config->getHexChecksum();
|
||||
}
|
||||
|
||||
$this->api()->wipeInactiveStages($this->db());
|
||||
|
||||
if ($this->api()->dumpConfig($config, $this->db())) {
|
||||
if ($isApiRequest) {
|
||||
return $this->sendJson((object) array('checksum' => $checksum));
|
||||
@ -91,42 +93,6 @@ class ConfigController extends ActionController
|
||||
$this->render('list/table', null, true);
|
||||
}
|
||||
|
||||
protected function fetchLogs()
|
||||
{
|
||||
$api = $this->api();
|
||||
$collected = false;
|
||||
foreach ($this->db()->getUncollectedDeployments() as $deployment) {
|
||||
$stage = $deployment->stage_name;
|
||||
try {
|
||||
$availableFiles = $api->listStageFiles($stage);
|
||||
} catch (Exception $e) {
|
||||
// This is not correct. We might miss logs as af an ongoing reload
|
||||
$deployment->stage_collected = 'y';
|
||||
$deployment->store();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array('startup.log', $availableFiles)
|
||||
&& in_array('status', $availableFiles)
|
||||
) {
|
||||
if ($api->getStagedFile($stage, 'status') === '0') {
|
||||
$deployment->startup_succeeded = 'y';
|
||||
} else {
|
||||
$deployment->startup_succeeded = 'n';
|
||||
}
|
||||
$deployment->startup_log = $this->api()->getStagedFile($stage, 'startup.log');
|
||||
}
|
||||
$collected = true;
|
||||
|
||||
$deployment->store();
|
||||
}
|
||||
|
||||
// TODO: Not correct, we might clear logs we formerly skipped
|
||||
if ($collected) {
|
||||
// $api->wipeInactiveStages();
|
||||
}
|
||||
}
|
||||
|
||||
// Show all files for a given config
|
||||
public function filesAction()
|
||||
{
|
||||
|
@ -439,6 +439,41 @@ constants
|
||||
return $found;
|
||||
}
|
||||
|
||||
public function collectLogFiles($db)
|
||||
{
|
||||
|
||||
$existing = $this->listModuleStages('director');
|
||||
foreach ($db->getUncollectedDeployments() as $deployment) {
|
||||
$stage = $deployment->stage_name;
|
||||
if (! in_array($stage, $existing)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$availableFiles = $this->listStageFiles($stage);
|
||||
} catch (Exception $e) {
|
||||
// This is not correct. We might miss logs as af an ongoing reload
|
||||
$deployment->stage_collected = 'y';
|
||||
$deployment->store();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array('startup.log', $availableFiles)
|
||||
&& in_array('status', $availableFiles)
|
||||
) {
|
||||
if ($this->getStagedFile($stage, 'status') === '0') {
|
||||
$deployment->startup_succeeded = 'y';
|
||||
} else {
|
||||
$deployment->startup_succeeded = 'n';
|
||||
}
|
||||
$deployment->startup_log = $this->getStagedFile($stage, 'startup.log');
|
||||
}
|
||||
$collected = true;
|
||||
|
||||
$deployment->store();
|
||||
}
|
||||
}
|
||||
|
||||
public function wipeInactiveStages($db)
|
||||
{
|
||||
$uncollected = $db->getUncollectedDeployments();
|
||||
|
Loading…
x
Reference in New Issue
Block a user