Skip to content

Commit

Permalink
ServiceSetServiceInfo: respect deactivation
Browse files Browse the repository at this point in the history
fixes #2323
  • Loading branch information
Thomas-Gelf committed Jun 23, 2021
1 parent c058359 commit 2538fea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ next (will be 1.9.0)
* FIX: show Services applied with Rules involving applied Hostgroups (#2313)
* FIX: Overrides for Services belonging to Sets on root Host Templates (#2333)
* FIX: Service Set preview inline Service Template links (#2334)
* FIX: Links to duplicate services in Sets didn't check for deactivation (#2323)
* FEATURE: show "deprecated" flag on object attribute inspection (#2312)
* FEATURE: Service Template for single Host services provides auto-completion (#1974)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ public static function find(IcingaHost $host, $serviceName)
{
$matcher = HostApplyMatches::prepare($host);
$connection = $host->getConnection();
foreach (static::fetchServiceSetApplyRulesByServiceName($connection, $serviceName) as $rule) {
foreach (static::fetchServiceSetApplyRulesByServiceName($connection, $host->get('id'), $serviceName) as $rule) {
if ($matcher->matchesFilter($rule->filter)) {
return new static($host->getObjectName(), $serviceName, $rule->service_set_name);
return new static(
$host->getObjectName(),
$serviceName,
$rule->service_set_name
);
}
}

Expand Down Expand Up @@ -75,7 +79,7 @@ public function requiresOverrides()
return true;
}

protected static function fetchServiceSetApplyRulesByServiceName(Db $connection, $serviceName)
protected static function fetchServiceSetApplyRulesByServiceName(Db $connection, $hostId, $serviceName)
{
$db = $connection->getDbAdapter();
$query = $db->select()
Expand All @@ -91,7 +95,13 @@ protected static function fetchServiceSetApplyRulesByServiceName(Db $connection,
[]
)
->where('s.object_name = ?', $serviceName)
->where('ss.assign_filter IS NOT NULL');
->where('ss.assign_filter IS NOT NULL')
->where( // Ignore deactivated Services:
'NOT EXISTS (SELECT 1 FROM icinga_host_service_blacklist hsb'
. ' WHERE hsb.host_id = ? AND hsb.service_id = s.id)',
(int) $hostId
);
;

$allRules = $db->fetchAll($query);
foreach ($allRules as $rule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public static function find(IcingaHost $host, $serviceName)
'hs.id = hsi.service_set_id',
[]
)->where('hs.host_id IN (?)', $ids)
->where('s.object_name = ?', $serviceName);
->where('s.object_name = ?', $serviceName)
->where( // Ignore deactivated Services:
'NOT EXISTS (SELECT 1 FROM icinga_host_service_blacklist hsb'
. ' WHERE hsb.host_id = ? AND hsb.service_id = s.id)',
(int) $host->get('id')
);

if ($row = $db->fetchRow($query)) {
return new static($host->getObjectName(), $serviceName, $row->service_set_name);
Expand Down

0 comments on commit 2538fea

Please sign in to comment.