ConfigController: do not show an exception...
...when a deployment fails
This commit is contained in:
parent
f614d75edc
commit
ade7b1415e
|
@ -59,7 +59,6 @@ class ConfigController extends ActionController
|
||||||
$this->assertPermission('director/deploy');
|
$this->assertPermission('director/deploy');
|
||||||
|
|
||||||
// TODO: require POST
|
// TODO: require POST
|
||||||
$isApiRequest = $this->getRequest()->isApiRequest();
|
|
||||||
$checksum = $this->params->get('checksum');
|
$checksum = $this->params->get('checksum');
|
||||||
if ($checksum) {
|
if ($checksum) {
|
||||||
$config = IcingaConfig::load(Util::hex2binary($checksum), $this->db());
|
$config = IcingaConfig::load(Util::hex2binary($checksum), $this->db());
|
||||||
|
@ -68,10 +67,22 @@ class ConfigController extends ActionController
|
||||||
$checksum = $config->getHexChecksum();
|
$checksum = $config->getHexChecksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$this->api()->wipeInactiveStages($this->db());
|
$this->api()->wipeInactiveStages($this->db());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->deploymentFailed($checksum, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->api()->dumpConfig($config, $this->db())) {
|
if ($this->api()->dumpConfig($config, $this->db())) {
|
||||||
if ($isApiRequest) {
|
$this->deploymentSucceeded($checksum);
|
||||||
|
} else {
|
||||||
|
$this->deploymentFailed($checksum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function deploymentSucceeded($checksum)
|
||||||
|
{
|
||||||
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
return $this->sendJson((object) array('checksum' => $checksum));
|
return $this->sendJson((object) array('checksum' => $checksum));
|
||||||
} else {
|
} else {
|
||||||
$url = Url::fromPath('director/config/deployments');
|
$url = Url::fromPath('director/config/deployments');
|
||||||
|
@ -80,18 +91,22 @@ class ConfigController extends ActionController
|
||||||
);
|
);
|
||||||
$this->redirectNow($url);
|
$this->redirectNow($url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function deploymentFailed($checksum, $error = null)
|
||||||
|
{
|
||||||
|
$extra = $error ? ': ' . $error: '';
|
||||||
|
|
||||||
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
|
return $this->sendJsonError('Config deployment failed' . $extra);
|
||||||
} else {
|
} else {
|
||||||
if ($isApiRequest) {
|
$url = Url::fromPath('director/config/files', array('checksum' => $checksum));
|
||||||
return $this->sendJsonError('Config deployment failed');
|
Notification::error(
|
||||||
} else {
|
$this->translate('Config deployment failed') . $extra
|
||||||
$url = Url::fromPath('director/config/show', array('checksum' => $checksum));
|
|
||||||
Notification::success(
|
|
||||||
$this->translate('Config deployment failed')
|
|
||||||
);
|
);
|
||||||
$this->redirectNow($url);
|
$this->redirectNow($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function activitiesAction()
|
public function activitiesAction()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue