Skip to content
Snippets Groups Projects
Commit 8db31d6b authored by Iustin Pop's avatar Iustin Pop
Browse files

Automatically cleanup _temporary_ids at save


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
(cherry picked from commit 34d657ba)
parent 26b316d0
No related branches found
No related tags found
No related merge requests found
...@@ -206,6 +206,13 @@ class ConfigWriter: ...@@ -206,6 +206,13 @@ class ConfigWriter:
self._temporary_ids.add(unique_id) self._temporary_ids.add(unique_id)
return 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): def _AllMACs(self):
"""Return all MACs present in the config. """Return all MACs present in the config.
...@@ -1114,6 +1121,10 @@ class ConfigWriter: ...@@ -1114,6 +1121,10 @@ class ConfigWriter:
"""Write the configuration data to persistent storage. """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() config_errors = self._UnlockedVerifyConfig()
if config_errors: if config_errors:
raise errors.ConfigurationError("Configuration data is not" raise errors.ConfigurationError("Configuration data is not"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment