From 01b0d99d57db7a604985e0e5f2cae0face2a1606 Mon Sep 17 00:00:00 2001 From: Ilias Stamatis Date: Fri, 7 Jul 2017 03:37:16 +0300 Subject: [PATCH] Issue 74 - Advice users to set referint-update-delay to 0 Bug Description: Support for asynchronous referential integrity updates might be dropped in the future and the referint-update-delay attribute might become deprecated. We need to warn the users. Fix Description: Display a warning when the healthcheck command is issued and advise the user to set this attribute to 0. https://pagure.io/lib389/issue/74 Author: Ilias95 Review by: ??? --- lib389/cli_conf/health.py | 2 ++ lib389/lint.py | 20 ++++++++++++++++++++ lib389/plugins.py | 8 ++++++++ lib389/tests/healthcheck_test.py | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/lib389/cli_conf/health.py b/lib389/cli_conf/health.py index 02aef14..21c41bc 100644 --- a/lib389/cli_conf/health.py +++ b/lib389/cli_conf/health.py @@ -10,6 +10,7 @@ import argparse from lib389.backend import Backend, Backends from lib389.config import Encryption, Config +from lib389 import plugins # These get all instances, then check them all. CHECK_MANY_OBJECTS = [ @@ -20,6 +21,7 @@ CHECK_MANY_OBJECTS = [ CHECK_OBJECTS = [ Config, Encryption, + plugins.ReferentialIntegrityPlugin ] def _format_check_output(log, result): diff --git a/lib389/lint.py b/lib389/lint.py index 404cff8..8c4b4de 100644 --- a/lib389/lint.py +++ b/lib389/lint.py @@ -108,4 +108,24 @@ set cn=encryption,cn=config sslVersionMin to a version greater than TLS1.0 """ } +DSRILE0001 = { + 'dsle': 'DSRLE0001', + 'severity': 'LOW', + 'items' : ['cn=referential integrity postoperation,cn=plugins,cn=config', ], + 'detail': """ +The referential integrity plugin has an asynchronous processing mode. This is controlled by the update-delay flag. + +When this value is 0, referential integrity plugin processes these changes inside of the operation that modified the entry - ie these are synchronous. + +However, when this is > 0, these are performed asynchronously. + +This leads to only having refint enabled on one master in MMR to prevent replication conflicts and loops. +Additionally, because these are performed in the background these updates may cause spurious update +delays to your server by batching changes rather than smaller updates during sync processing. +We advise that you set this value to 0, and enable refint on all masters as it provides a more predictable behaviour. + """, + 'fix' : """ +Set referint-update-delay to 0. + """ +} diff --git a/lib389/plugins.py b/lib389/plugins.py index 6bbf164..944d130 100644 --- a/lib389/plugins.py +++ b/lib389/plugins.py @@ -12,6 +12,7 @@ import copy from lib389 import tasks from lib389._mapped_object import DSLdapObjects, DSLdapObject from lib389.exceptions import Error +from lib389.lint import DSRILE0001 from lib389._constants import DN_PLUGIN from lib389.properties import ( PLUGINS_OBJECTCLASS_VALUE, PLUGIN_PROPNAME_TO_ATTRNAME, @@ -119,6 +120,13 @@ class ManagedEntriesPlugin(Plugin): class ReferentialIntegrityPlugin(Plugin): def __init__(self, instance, dn="cn=referential integrity postoperation,cn=plugins,cn=config", batch=False): super(ReferentialIntegrityPlugin, self).__init__(instance, dn, batch) + self._lint_functions = [self._lint_update_delay] + + def _lint_update_delay(self): + if self.status(): + delay = self.get_attr_val_int("referint-update-delay") + if delay is not None and delay != 0: + return DSRILE0001 # referint-update-delay: 0 # referint-logfile: /opt/dirsrv/var/log/dirsrv/slapd-standalone_2/referint diff --git a/lib389/tests/healthcheck_test.py b/lib389/tests/healthcheck_test.py index 94711eb..a36e6fb 100644 --- a/lib389/tests/healthcheck_test.py +++ b/lib389/tests/healthcheck_test.py @@ -11,6 +11,7 @@ import pytest import ldap from lib389.topologies import topology_st +from lib389.plugins import ReferentialIntegrityPlugin from lib389.lint import * @@ -40,3 +41,21 @@ def test_hc_config(topology_st): result = topology_st.standalone.config._lint_passwordscheme() assert result == DSCLE0002 +def test_hc_referint(topology_st): + plugin = ReferentialIntegrityPlugin(topology_st.standalone) + plugin.enable() + + # Assert we don't get an error when delay is 0. + plugin.set('referint-update-delay', '0') + result = plugin._lint_update_delay() + assert result is None + + # Assert we get an error when delay is not 0. + plugin.set('referint-update-delay', '10') + result = plugin._lint_update_delay() + assert result == DSRILE0001 + + # Assert we don't get an error when plugin is disabled. + plugin.disable() + result = plugin._lint_update_delay() + assert result is None -- 2.13.4