From 8db31d6b45dbd17d25783cabb0d1a6d701e1abff Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 23 Sep 2009 18:39:05 +0200 Subject: [PATCH] Automatically cleanup _temporary_ids at save Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> (cherry picked from commit 34d657bae4361b9d6fd8c6314dc7cca57b51c773) --- lib/config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/config.py b/lib/config.py index af45aa371..712f599b5 100644 --- a/lib/config.py +++ b/lib/config.py @@ -206,6 +206,13 @@ class ConfigWriter: self._temporary_ids.add(unique_id) return unique_id + def _CleanupTemporaryIDs(self): + """Cleanups the _temporary_ids structure. + + """ + existing = self._AllIDs(include_temporary=False) + self._temporary_ids = self._temporary_ids - existing + def _AllMACs(self): """Return all MACs present in the config. @@ -1114,6 +1121,10 @@ class ConfigWriter: """Write the configuration data to persistent storage. """ + # first, cleanup the _temporary_ids set, if an ID is now in the + # other objects it should be discarded to prevent unbounded growth + # of that structure + self._CleanupTemporaryIDs() config_errors = self._UnlockedVerifyConfig() if config_errors: raise errors.ConfigurationError("Configuration data is not" -- GitLab