IcingaDependencies: allow unknown service...

...with a given specific host

fixes #2669
This commit is contained in:
Thomas Gelf 2022-12-05 12:58:57 +01:00
parent e5de673f68
commit ef010f961b
2 changed files with 20 additions and 1 deletions

View File

@ -12,6 +12,7 @@ This version hasn't been released yet
### UI
* FEATURE: allow to clone commands with fields (#2264)
* FEATURE: Data Fields are now sorted in a case-insensitive way (#2358)
* FIX: do not fail for (some) Service Dependencies (#2669)
### Icinga Configuration
* FIX: render Set Services to individual zones where required (#1589, #2356)

View File

@ -589,7 +589,25 @@ class IcingaDependency extends IcingaObject implements ExportInterface
$this->reallySet($name, $object->get('id'));
unset($this->unresolvedRelatedProperties[$name]);
} else {
throw new NotFoundError('Unable to resolve related property: "%s"', $name);
// Depend on a single service on a single host. Rare case, as usually you want to
// depend on a service on the very same host - and leave the Host field empty. The
// latter is already being handled above. This duplicates some code, but I'll leave
// it this way for now. There might have been a reason for the parent_host_id = null
// check in that code.
if ($name === 'parent_service_id' && $this->get('object_type') === 'apply') {
$this->reallySet(
'parent_service_by_name',
$this->unresolvedRelatedProperties[$name]
);
$this->reallySet('parent_service_id', null);
unset($this->unresolvedRelatedProperties[$name]);
return;
}
throw new NotFoundError(sprintf(
'Unable to resolve related property: %s "%s"',
$name,
$this->unresolvedRelatedProperties[$name]
));
}
}