diff --git a/releasenotes/notes/fix-grow-cluster-cache-5625d1a519a4ee01.yaml b/releasenotes/notes/fix-grow-cluster-cache-5625d1a519a4ee01.yaml new file mode 100644 index 0000000..28828b6 --- /dev/null +++ b/releasenotes/notes/fix-grow-cluster-cache-5625d1a519a4ee01.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - The current caching initializes the instance list for the grow + cluster manager each time a new process would instantiate the + manager. Changed to manager to only initialize on creation. diff --git a/trove_dashboard/content/database_clusters/cluster_manager.py b/trove_dashboard/content/database_clusters/cluster_manager.py index 50f60d9..ffc10c6 100644 --- a/trove_dashboard/content/database_clusters/cluster_manager.py +++ b/trove_dashboard/content/database_clusters/cluster_manager.py @@ -42,17 +42,17 @@ def has_cluster(cluster_id): class ClusterInstanceManager(object): - - instances = [] - def __init__(self, cluster_id): self.cluster_id = cluster_id + self.instances = [] def get_instances(self): + if not hasattr(self, 'instances'): + self.instances = [] return self.instances def get_instance(self, id): - for instance in self.instances: + for instance in self.get_instances(): if instance.id == id: return instance return None @@ -63,7 +63,7 @@ class ClusterInstanceManager(object): volume, type, related_to, nics) self.instances.append(instance) update(self.cluster_id, self) - return self.instances + return self.get_instances() def delete_instance(self, id): instance = self.get_instance(id) @@ -72,7 +72,8 @@ class ClusterInstanceManager(object): update(self.cluster_id, self) def clear_instances(self): - del self.instances[:] + self.instances = [] + update(self.cluster_id, self) class ClusterInstance(object):