From 29ada79e96c606c3fdf88d14b3cb32793fd2d218 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 28 Nov 2024 10:19:15 +0100 Subject: [PATCH 1/4] db: Add `is_reachable` to `RedundancyGroupState` --- library/Icingadb/Model/RedundancyGroupState.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Icingadb/Model/RedundancyGroupState.php b/library/Icingadb/Model/RedundancyGroupState.php index df30f581e..b38ee930f 100644 --- a/library/Icingadb/Model/RedundancyGroupState.php +++ b/library/Icingadb/Model/RedundancyGroupState.php @@ -19,6 +19,7 @@ * @property string $id * @property string $redundancy_group_id * @property bool $failed + * @property bool $is_reachable * @property DateTime $last_state_change * * @property RedundancyGroup|Query $redundancy_group @@ -40,6 +41,7 @@ public function getColumns(): array return [ 'redundancy_group_id', 'failed', + 'is_reachable', 'last_state_change' ]; } @@ -51,7 +53,8 @@ public function createBehaviors(Behaviors $behaviors): void 'redundancy_group_id' ])); $behaviors->add(new BoolCast([ - 'failed' + 'failed', + 'is_reachable' ])); $behaviors->add(new MillisecondTimestamp([ 'last_state_change' From 1332ba3bccb8fbc781c557fb441629d56c2b11c0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 28 Nov 2024 10:21:17 +0100 Subject: [PATCH 2/4] RedundancyGroupDetail: Show root problems if unreachable, not failed --- library/Icingadb/Widget/Detail/RedundancyGroupDetail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icingadb/Widget/Detail/RedundancyGroupDetail.php b/library/Icingadb/Widget/Detail/RedundancyGroupDetail.php index 1c07e4c13..8e7f4f593 100644 --- a/library/Icingadb/Widget/Detail/RedundancyGroupDetail.php +++ b/library/Icingadb/Widget/Detail/RedundancyGroupDetail.php @@ -63,7 +63,7 @@ protected function createExtensions(): array */ protected function createRootProblems(): ?array { - if (! $this->group->state->failed) { + if ($this->group->state->is_reachable) { return null; } From e1ccc25961f7ec89f5bd3cc9bed8a82910f60466 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 28 Nov 2024 10:22:22 +0100 Subject: [PATCH 3/4] UnreachableParent: Only fetch responsible nodes A node is responsible if: * it's a host which is reachable but has a problem * it's a service which is reachable but has a problem * it's a redundancy group which is reachable but has failed --- library/Icingadb/Model/UnreachableParent.php | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/library/Icingadb/Model/UnreachableParent.php b/library/Icingadb/Model/UnreachableParent.php index c984fddd4..49062ed84 100644 --- a/library/Icingadb/Model/UnreachableParent.php +++ b/library/Icingadb/Model/UnreachableParent.php @@ -92,10 +92,23 @@ public static function on(Connection $db, Model $root = null): Query self::selectNodes($db, $root), 'unreachable_parent', true - )->where([ - 'unreachable_parent.level > ?' => 0, - 'unreachable_parent.is_group_member = ?' => 0 - ]); + ); + + $query->filter(Filter::all( + Filter::greaterThan('level', 0), + Filter::equal('is_group_member', 0), + Filter::any( + Filter::equal('service.state.affects_children', 'y'), + Filter::all( + Filter::unlike('service_id', '*'), + Filter::equal('host.state.affects_children', 'y') + ), + Filter::all( + Filter::equal('redundancy_group.state.failed', 'y'), + Filter::equal('redundancy_group.state.is_reachable', 'y') + ) + ) + )); return $query; } From 30269efbe2736196b9b0a651efe3db2ad051e632 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 28 Nov 2024 10:38:49 +0100 Subject: [PATCH 4/4] ui: Change visualization of redundancy group states They can now be unreachable, thus get the same icon as others. The state then isn't about reachability anymore, so it's just critical or ok. --- .../Icingadb/Model/RedundancyGroupState.php | 26 +++++++++++++++++-- .../Widget/Detail/RedundancyGroupHeader.php | 5 +++- .../ItemList/RedundancyGroupListItem.php | 5 +++- public/css/common.less | 10 ------- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/library/Icingadb/Model/RedundancyGroupState.php b/library/Icingadb/Model/RedundancyGroupState.php index b38ee930f..e37327939 100644 --- a/library/Icingadb/Model/RedundancyGroupState.php +++ b/library/Icingadb/Model/RedundancyGroupState.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Icingadb\Model; use DateTime; +use Icinga\Module\Icingadb\Common\Icons; use ipl\Orm\Behavior\Binary; use ipl\Orm\Behavior\BoolCast; use ipl\Orm\Behavior\MillisecondTimestamp; @@ -12,6 +13,7 @@ use ipl\Orm\Model; use ipl\Orm\Query; use ipl\Orm\Relations; +use ipl\Web\Widget\Icon; /** * Redundancy group state model. @@ -66,9 +68,29 @@ public function createRelations(Relations $relations): void $relations->belongsTo('redundancy_group', RedundancyGroup::class); } + /** + * Get the state text for the redundancy group state + * + * Do not use this method to label the state of a redundancy group. + * + * @return string + */ public function getStateText(): string { - // The method should only be called to fake state balls and not to show the group's state - return $this->failed ? 'unreachable' : 'reachable'; + return $this->failed ? 'critical' : 'ok'; + } + + /** + * Get the state icon + * + * @return ?Icon + */ + public function getIcon(): ?Icon + { + if (! $this->is_reachable) { + return new Icon(Icons::UNREACHABLE); + } + + return null; } } diff --git a/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php b/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php index 12154c348..d98c7b0f5 100644 --- a/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php +++ b/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php @@ -29,7 +29,10 @@ public function __construct(RedundancyGroup $object, RedundancyGroupSummary $sum protected function assembleVisual(BaseHtmlElement $visual): void { - $visual->addHtml(new StateBall($this->object->state->getStateText(), $this->getStateBallSize())); + $stateBall = new StateBall($this->object->state->getStateText(), $this->getStateBallSize()); + $stateBall->add($this->object->state->getIcon()); + + $visual->addHtml($stateBall); } protected function assembleTitle(BaseHtmlElement $title): void diff --git a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php index eca3c9271..7b56f5cac 100644 --- a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php +++ b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php @@ -62,7 +62,10 @@ protected function createSubject(): Link protected function assembleVisual(BaseHtmlElement $visual): void { - $visual->addHtml(new StateBall($this->state->getStateText(), $this->getStateBallSize())); + $stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize()); + $stateBall->add($this->state->getIcon()); + + $visual->addHtml($stateBall); } protected function assembleCaption(BaseHtmlElement $caption): void diff --git a/public/css/common.less b/public/css/common.less index 3a28d03b0..8d314741a 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -412,13 +412,3 @@ form[name="form_confirm_removal"] { padding: 0 0.25em; .rounded-corners(); } - -.state-ball { - &.state-unreachable { - background-color: @color-critical; - } - - &.state-reachable { - background-color: @color-ok; - } -}