parent
e476282b62
commit
7f79842ddf
|
@ -4,15 +4,13 @@ namespace Icinga\Module\Director\Forms;
|
||||||
|
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Module\Director\Core\DeploymentApiInterface;
|
use Icinga\Module\Director\Core\DeploymentApiInterface;
|
||||||
use Icinga\Module\Director\Db;
|
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||||
// use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
|
||||||
use Icinga\Module\Director\Util;
|
|
||||||
use Icinga\Module\Director\Web\Form\DirectorForm;
|
use Icinga\Module\Director\Web\Form\DirectorForm;
|
||||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
|
||||||
|
|
||||||
class DeployConfigForm extends DirectorForm
|
class DeployConfigForm extends DirectorForm
|
||||||
{
|
{
|
||||||
|
use DeployFormsBug7530;
|
||||||
|
|
||||||
/** @var DeploymentApiInterface */
|
/** @var DeploymentApiInterface */
|
||||||
private $api;
|
private $api;
|
||||||
|
|
||||||
|
@ -70,8 +68,11 @@ class DeployConfigForm extends DirectorForm
|
||||||
|
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
|
if ($this->skipBecauseOfBug7530()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$checksum = $this->checksum;
|
|
||||||
$msg = $this->translate('Config has been submitted, validation is going on');
|
$msg = $this->translate('Config has been submitted, validation is going on');
|
||||||
$this->setSuccessMessage($msg);
|
$this->setSuccessMessage($msg);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Forms;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Core\CoreApi;
|
||||||
|
use ipl\Html\Html;
|
||||||
|
|
||||||
|
trait DeployFormsBug7530
|
||||||
|
{
|
||||||
|
public function hasBeenSubmitted()
|
||||||
|
{
|
||||||
|
if (parent::hasBeenSubmitted()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return \strlen($this->getSentValue('confirm_7530')) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function shouldWarnAboutBug7530()
|
||||||
|
{
|
||||||
|
/** @var \Icinga\Module\Director\Db $db */
|
||||||
|
$db = $this->getDb();
|
||||||
|
|
||||||
|
return $db->settings()->get('ignore_bug7530') !== 'y'
|
||||||
|
&& $this->getSentValue('confirm_7530') !== 'i_know'
|
||||||
|
&& $this->configMightTriggerBug7530()
|
||||||
|
& $this->coreHasBug7530();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configMightTriggerBug7530()
|
||||||
|
{
|
||||||
|
/** @var \Icinga\Module\Director\Db $connection */
|
||||||
|
$connection = $this->getDb();
|
||||||
|
$db = $connection->getDbAdapter();
|
||||||
|
|
||||||
|
$zoneIds = $db->fetchCol(
|
||||||
|
$db->select()
|
||||||
|
->from('icinga_zone', 'id')
|
||||||
|
->where('object_type = ?', 'object')
|
||||||
|
);
|
||||||
|
if (empty($zoneIds)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$objectTypes = [
|
||||||
|
'icinga_host',
|
||||||
|
'icinga_service',
|
||||||
|
'icinga_notification',
|
||||||
|
'icinga_command',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($objectTypes as $objectType) {
|
||||||
|
if ((int) $db->fetchOne(
|
||||||
|
$db->select()
|
||||||
|
->from($objectType, 'COUNT(*)')
|
||||||
|
->where('zone_id IN (?)', $zoneIds)
|
||||||
|
) > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function coreHasBug7530()
|
||||||
|
{
|
||||||
|
if ($this->api instanceof CoreApi) {
|
||||||
|
$version = $this->api->getVersion();
|
||||||
|
if ($version === null) {
|
||||||
|
throw new \RuntimeException($this->translate('Unable to detect your Icinga 2 Core version'));
|
||||||
|
} elseif ($version === '2.11.0') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function skipBecauseOfBug7530()
|
||||||
|
{
|
||||||
|
$bug7530 = $this->getSentValue('confirm_7530');
|
||||||
|
if ($bug7530 === 'whaaat') {
|
||||||
|
$this->setSuccessMessage($this->translate('Config has not been deployed'));
|
||||||
|
parent::onSuccess();
|
||||||
|
} elseif ($bug7530 === 'hell_yes') {
|
||||||
|
$this->db->settings()->set('ignore_bug7530', 'y');
|
||||||
|
}
|
||||||
|
if ($this->shouldWarnAboutBug7530()) {
|
||||||
|
$this->addHtml(Html::tag('p', ['class' => 'state-hint warning'], Html::sprintf($this->translate(
|
||||||
|
"Warning: you're running Icinga v2.11.0 and our configuration looks"
|
||||||
|
. " like you could face issue %s. We're already working on a solution."
|
||||||
|
. " The GitHub Issue and our %s contain related details."
|
||||||
|
), Html::tag('a', [
|
||||||
|
'href' => 'https://github.com/Icinga/icinga2/issues/7530',
|
||||||
|
'target' => '_blank',
|
||||||
|
'title' => sprintf(
|
||||||
|
$this->translate('Show Issue %s on GitHub'),
|
||||||
|
'7530'
|
||||||
|
),
|
||||||
|
'class' => 'icon-github-circled',
|
||||||
|
], '#7530'), Html::tag('a', [
|
||||||
|
'href' => 'https://icinga.com/docs/icinga2/latest/doc/16-upgrading-icinga-2/'
|
||||||
|
. '#config-sync-zones-in-zones',
|
||||||
|
'target' => '_blank',
|
||||||
|
'title' => $this->translate('Upgrading Icinga 2 - Confic Sync: Zones in Zones'),
|
||||||
|
'class' => 'icon-info-circled',
|
||||||
|
], $this->translate('Upgrading documentation')))));
|
||||||
|
$this->addElement('select', 'confirm_7530', [
|
||||||
|
'multiOptions' => $this->optionalEnum([
|
||||||
|
'i_know' => $this->translate("I know what I'm doing, deploy anyway"),
|
||||||
|
'hell_yes' => $this->translate("I know, please don't bother me again"),
|
||||||
|
'whaaat' => $this->translate("Thanks, I'll verify this and come back later"),
|
||||||
|
]),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => ['ViewHelper'],
|
||||||
|
]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,8 @@ use Zend_View_Interface;
|
||||||
|
|
||||||
class DeploymentLinkForm extends DirectorForm
|
class DeploymentLinkForm extends DirectorForm
|
||||||
{
|
{
|
||||||
|
use DeployFormsBug7530;
|
||||||
|
|
||||||
/** @var DeploymentInfo */
|
/** @var DeploymentInfo */
|
||||||
protected $info;
|
protected $info;
|
||||||
|
|
||||||
|
@ -82,10 +84,11 @@ class DeploymentLinkForm extends DirectorForm
|
||||||
|
|
||||||
$this->setAttrib('class', 'inline');
|
$this->setAttrib('class', 'inline');
|
||||||
$this->addHtml(Icon::create('wrench'));
|
$this->addHtml(Icon::create('wrench'));
|
||||||
|
$target = $this->shouldWarnAboutBug7530() ? '_self' : '_next';
|
||||||
$this->addSubmitButton($this->translate('Deploy'), [
|
$this->addSubmitButton($this->translate('Deploy'), [
|
||||||
'class' => 'link-button icon-wrench',
|
'class' => 'link-button icon-wrench',
|
||||||
'title' => $msg,
|
'title' => $msg,
|
||||||
'data-base-target' => '_next'
|
'data-base-target' => $target,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +108,9 @@ class DeploymentLinkForm extends DirectorForm
|
||||||
|
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
|
if ($this->skipBecauseOfBug7530()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->deploy();
|
$this->deploy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,26 @@ class SettingsForm extends DirectorForm
|
||||||
'value' => $settings->getStoredValue('enable_audit_log')
|
'value' => $settings->getStoredValue('enable_audit_log')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if ($settings->getStoredValue('ignore_bug7530')) {
|
||||||
|
// Show this only for those who touched this setting
|
||||||
|
$this->addElement('select', 'ignore_bug7530', array(
|
||||||
|
'label' => $this->translate('Ignore Bug #7530'),
|
||||||
|
'multiOptions' => $this->eventuallyConfiguredEnum(
|
||||||
|
'ignore_bug7530',
|
||||||
|
array(
|
||||||
|
'n' => $this->translate('No'),
|
||||||
|
'y' => $this->translate('Yes'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Icinga v2.11.0 breaks some configurations, the Director will'
|
||||||
|
. ' warn you before every deployment in case your config is'
|
||||||
|
. ' affected. This setting allows to hide this warning.'
|
||||||
|
),
|
||||||
|
'value' => $settings->getStoredValue('ignore_bug7530')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$this->addElement('select', 'config_format', array(
|
$this->addElement('select', 'config_format', array(
|
||||||
'label' => $this->translate('Configuration format'),
|
'label' => $this->translate('Configuration format'),
|
||||||
'multiOptions' => $this->eventuallyConfiguredEnum(
|
'multiOptions' => $this->eventuallyConfiguredEnum(
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Settings
|
||||||
'self-service/agent_name' => 'fqdn',
|
'self-service/agent_name' => 'fqdn',
|
||||||
'self-service/transform_hostname' => '0',
|
'self-service/transform_hostname' => '0',
|
||||||
'self-service/global_zones' => ['director-global'],
|
'self-service/global_zones' => ['director-global'],
|
||||||
|
'ignore_bug7530' => 'n',
|
||||||
// 'experimental_features' => null, // 'allow'
|
// 'experimental_features' => null, // 'allow'
|
||||||
// 'master_zone' => null,
|
// 'master_zone' => null,
|
||||||
];
|
];
|
||||||
|
|
|
@ -32,6 +32,12 @@ div.action-bar {
|
||||||
form input {
|
form input {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
input {
|
||||||
|
max-width: unset;
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
line-height: 1.25em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.action-bar ul {
|
div.action-bar ul {
|
||||||
|
|
Loading…
Reference in New Issue