From 2db5004c54708008bf68768ea24aa895be2b5943 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 23 Apr 2014 09:38:42 -0400 Subject: [PATCH] Fix clearing of a group attribute not clearing inherited values --- confluent/config/configmanager.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 0752ca35..7bfe290f 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -821,8 +821,17 @@ class ConfigManager(object): pass for node in groupentry['nodes']: nodecfg = self._cfgstore['nodes'][node] - self._do_inheritance( - nodecfg, attrib, node, changeset) + try: + delnodeattrib = ( + nodecfg[attrib]['inheritedfrom'] == group) + except KeyError: + delnodeattrib = False + if delnodeattrib: + _mark_dirtykey('nodes', node, self.tenant) + del nodecfg[attrib] + self._do_inheritance(nodecfg, attrib, node, + changeset) + _addchange(changeset, node, attrib) self._notif_attribwatchers(changeset) self._bg_sync_to_file() @@ -1104,3 +1113,13 @@ try: ConfigManager._read_from_path() except IOError: _cfgstore = {} + + +# some unit tests worth implementing: +# set group attribute on lower priority group, result is that node should not +# change +# after that point, then unset on the higher priority group, lower priority +# group should get it then +# rinse and repeat for set on node versus set on group +# clear group attribute and assure than it becomes unset on all nodes +# set various expressions \ No newline at end of file