mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
Sync: do not touch 'disabled' on merge unless...
...it has been defined as a Sync Property fixes #1223
This commit is contained in:
parent
c9c59b3f03
commit
8f7e9e9ecd
@ -10,10 +10,14 @@ before switching to a new version.
|
|||||||
* You can find issues and feature requests related to this release on our
|
* You can find issues and feature requests related to this release on our
|
||||||
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/12?closed=1)
|
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/12?closed=1)
|
||||||
|
|
||||||
|
### Automation
|
||||||
|
* FIX: A Sync Rule with `merge` policy used to re-enable manually disabled objects,
|
||||||
|
even when no Sync Property `disabled` has been defined
|
||||||
|
|
||||||
### Large environments
|
### Large environments
|
||||||
* Director tries to raise it's memory limit for certain memory-intensive tasks.
|
* FIX: Director tries to raise it's memory limit for certain memory-intensive
|
||||||
When granted more (but not infinite) memory however this had the effect that
|
tasks. When granted more (but not infinite) memory however this had the effect
|
||||||
he self-restricted himself to a lower limit. This has now been fixed.
|
that he self-restricted himself to a lower limit.
|
||||||
|
|
||||||
1.4.0
|
1.4.0
|
||||||
-----
|
-----
|
||||||
|
@ -458,6 +458,16 @@ abstract class DbObject
|
|||||||
return $props;
|
return $props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all properties that changed since object creation
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function listModifiedProperties()
|
||||||
|
{
|
||||||
|
return array_keys($this->modifiedProperties);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this object has been modified
|
* Whether this object has been modified
|
||||||
*
|
*
|
||||||
@ -668,6 +678,16 @@ abstract class DbObject
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetProperty($key)
|
||||||
|
{
|
||||||
|
$this->set($key, $this->getOriginalProperty($key));
|
||||||
|
if ($this->listModifiedProperties() === [$key]) {
|
||||||
|
$this->hasBeenModified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasBeenLoadedFromDb()
|
public function hasBeenLoadedFromDb()
|
||||||
{
|
{
|
||||||
return $this->loadedFromDb;
|
return $this->loadedFromDb;
|
||||||
|
@ -14,6 +14,7 @@ use Icinga\Module\Director\Objects\IcingaHostGroup;
|
|||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Objects\ImportSource;
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
|
use Icinga\Module\Director\Objects\SyncProperty;
|
||||||
use Icinga\Module\Director\Objects\SyncRule;
|
use Icinga\Module\Director\Objects\SyncRule;
|
||||||
use Icinga\Module\Director\Objects\SyncRun;
|
use Icinga\Module\Director\Objects\SyncRun;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
@ -72,6 +73,7 @@ class Sync
|
|||||||
|
|
||||||
protected $errors = array();
|
protected $errors = array();
|
||||||
|
|
||||||
|
/** @var SyncProperty[] */
|
||||||
protected $syncProperties;
|
protected $syncProperties;
|
||||||
|
|
||||||
protected $replaceVars = false;
|
protected $replaceVars = false;
|
||||||
@ -585,9 +587,16 @@ class Sync
|
|||||||
// TODO: directly work on existing objects, remember imported keys, then purge
|
// TODO: directly work on existing objects, remember imported keys, then purge
|
||||||
$newObjects = $this->prepareNewObjects();
|
$newObjects = $this->prepareNewObjects();
|
||||||
|
|
||||||
|
$hasDisabled = false;
|
||||||
|
foreach ($this->syncProperties as $property) {
|
||||||
|
if ($property->get('destination_field') === 'disabled') {
|
||||||
|
$hasDisabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($newObjects as $key => $object) {
|
foreach ($newObjects as $key => $object) {
|
||||||
if (array_key_exists($key, $this->objects)) {
|
if (array_key_exists($key, $this->objects)) {
|
||||||
switch ($this->rule->update_policy) {
|
switch ($this->rule->get('update_policy')) {
|
||||||
case 'override':
|
case 'override':
|
||||||
$this->objects[$key]->replaceWith($object);
|
$this->objects[$key]->replaceWith($object);
|
||||||
break;
|
break;
|
||||||
@ -596,6 +605,9 @@ class Sync
|
|||||||
// TODO: re-evaluate merge settings. vars.x instead of
|
// TODO: re-evaluate merge settings. vars.x instead of
|
||||||
// just "vars" might suffice.
|
// just "vars" might suffice.
|
||||||
$this->objects[$key]->merge($object, $this->replaceVars);
|
$this->objects[$key]->merge($object, $this->replaceVars);
|
||||||
|
if (! $hasDisabled) {
|
||||||
|
$this->objects[$key]->resetProperty('disabled');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user