DeploymentLog: deal with entries without checksum

This will allow to keep deployment history while dropping outdated generated
configs
This commit is contained in:
Thomas Gelf 2018-09-12 12:43:01 +02:00
parent a2f7ff03c1
commit 3ae39af1cb
3 changed files with 19 additions and 12 deletions

View File

@ -50,6 +50,10 @@ trait DbHelper
public function getShortChecksum($checksum)
{
if ($checksum === null) {
return null;
}
return substr($this->getChecksum($checksum), 0, 7);
}
}

View File

@ -30,7 +30,7 @@ class DeploymentLogTable extends ZfQueryBasedTable
$shortSum = $this->getShortChecksum($row->config_checksum);
$tr = $this::tr([
$this::td(Link::create(
[$row->peer_identity, " ($shortSum)"],
$shortSum === null ? $row->peer_identity : [$row->peer_identity, " ($shortSum)"],
'director/deployment',
['id' => $row->id]
)),

View File

@ -33,18 +33,18 @@ class DeploymentInfo extends HtmlDocument
public function __construct(DirectorDeploymentLog $deployment)
{
$this->deployment = $deployment;
$this->config = IcingaConfig::load(
$deployment->config_checksum,
$deployment->getConnection()
);
if ($deployment->get('config_checksum') !== null) {
$this->config = IcingaConfig::load(
$deployment->get('config_checksum'),
$deployment->getConnection()
);
}
}
/**
* @param Auth $auth
* @param Request $request
* @return Tabs
* @throws \Icinga\Exception\Http\HttpNotFoundException
* @throws \Icinga\Exception\ProgrammingError
*/
public function getTabs(Auth $auth, Request $request)
{
@ -76,8 +76,14 @@ class DeploymentInfo extends HtmlDocument
$table->addNameValuePairs([
$this->translate('Deployment time') => $dep->start_time,
$this->translate('Sent to') => $dep->peer_identity,
$this->translate('Configuration') => $this->getConfigDetails(),
$this->translate('Duration') => $this->getDurationInfo(),
]);
if ($this->config !== null) {
$table->addNameValuePairs([
$this->translate('Configuration') => $this->getConfigDetails(),
$this->translate('Duration') => $this->getDurationInfo(),
]);
}
$table->addNameValuePairs([
$this->translate('Stage name') => $dep->stage_name,
$this->translate('Startup') => $this->getStartupInfo()
]);
@ -151,9 +157,6 @@ class DeploymentInfo extends HtmlDocument
return parent::render();
}
/**
* @throws \Icinga\Exception\IcingaException
*/
protected function addStartupLog()
{
$this->add(Html::tag('h2', null, $this->translate('Startup Log')));