From e61e6150113e237873038e1d8646ced29d95edb5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 9 Feb 2024 13:21:35 +0100 Subject: [PATCH] DeleteDowntimesCommandForm: Ignore 404's fixes #5183 --- .../Command/Object/DeleteDowntimesCommandForm.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index d4ee8034870..efe542d3c5f 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; +use Icinga\Module\Monitoring\Exception\CommandTransportException; use Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; @@ -75,7 +76,15 @@ public function onSuccess() ->setDowntimeName($downtime->name) ->setAuthor($this->Auth()->getUser()->getUsername()) ->setIsService(isset($downtime->service_description)); - $this->getTransport($this->request)->send($delDowntime); + + try { + $this->getTransport($this->request)->send($delDowntime); + } catch (CommandTransportException $e) { + // Negative lookahead because there may be messages from other endpoints with different status codes + if (preg_match('/Can\'t send external Icinga command: (?!404)/', $e->getMessage())) { + throw $e; + } + } } $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) {