diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2019-12-13 16:18:33 +0000 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2019-12-18 18:47:41 +0000 |
commit | 0a9c6c156a6eedf149528fd853f72a8ddd83e147 (patch) | |
tree | e4fff4f801e5b4567208f76dc09bcd0c4e94049c | |
parent | 7f1375eb5e58f3dfc7864ed3c68c731ac3c51115 (diff) | |
download | oslo-config-stable/stein.tar.gz |
Ensure option groups don't change during loggingstein-em6.8.2stable/stein
oslo.config allows us to configure groups and options dynamically. This
can cause a race with our logging as we attempt to iterate through
option groups that are changing under our feet. This wouldn't be a huge
issue, since these are just logs are we can always log again, if needed,
but we store groups in a dictionary and Python doesn't like us changing
the size of a dict it's iterating through:
RuntimeError: dictionary changed size during iteration
Given that we're only reading through this option group and don't need
to worry about a group _disappearing_, the solution is pretty simple:
create a copy of our option group names ahead of time so we don't need
to worry about new ones coming and messing things up.
No tests are included since this is a race and the only way I see to
reproduce this would involve lots of ugly threading.
Change-Id: Id3b28465d645a24f0fcebff2dd68a9bd30e21594
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1856312
(cherry picked from commit e3e2ba55eeeb86a9bc0624bb2592e46583e839e7)
(cherry picked from commit 22c286c63b15b6f0acf6f696b98226a9257bf745)
-rw-r--r-- | oslo_config/cfg.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index b151cff..6a47cfd 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -2566,7 +2566,7 @@ class ConfigOpts(collections.Mapping): logger.log(lvl, "%-30s = %s", opt_name, _sanitize(opt, getattr(self, opt_name))) - for group_name in self._groups: + for group_name in list(self._groups): group_attr = self.GroupAttr(self, self._get_group(group_name)) for opt_name in sorted(self._groups[group_name]._opts): opt = self._get_opt_info(opt_name, group_name)['opt'] |