Skip to content

Commit 29e7457

Browse files
committed
Remove caching of values from Cluster object
This caching is an optimization but is causing some failures in our tests. Signed-off-by: Nicola Sirena <[email protected]>
1 parent 0622c08 commit 29e7457

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

tests/integration-tests/clusters_factory.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ def __init__(self, name, ssh_key, config_file, region, custom_cli_credentials=No
6262
self.__cfn_resources = None
6363
self.__cfn_stack_arn = None
6464
self.custom_cli_credentials = custom_cli_credentials
65-
self.cluster_info = None
66-
self.login_nodes_info = None
6765

6866
def __repr__(self):
6967
attrs = ", ".join(["{key}={value}".format(key=key, value=repr(value)) for key, value in self.__dict__.items()])
@@ -183,32 +181,22 @@ def stop(self):
183181
result = run_pcluster_command(cmd_args, log_error=False, custom_cli_credentials=self.custom_cli_credentials)
184182
logging.info("Cluster {0} stopped successfully".format(self.name))
185183

186-
# reset cached info
187-
self.cluster_info = None
188-
self.login_nodes_info = None
189-
190184
return result.stdout
191185
except subprocess.CalledProcessError as e:
192186
logging.error("Failed stopping cluster with error:\n%s\nand output:\n%s", e.stderr, e.stdout)
193187
raise
194188

195189
def describe_cluster(self):
196190
"""Run pcluster describe-cluster and return the result."""
197-
if self.cluster_info:
198-
return self.cluster_info
199-
else:
200-
cmd_args = ["pcluster", "describe-cluster", "--cluster-name", self.name]
201-
try:
202-
result = run_pcluster_command(
203-
cmd_args, log_error=False, custom_cli_credentials=self.custom_cli_credentials
204-
)
205-
response = json.loads(result.stdout)
206-
logging.info("Get cluster {0} status successfully".format(self.name))
207-
self.cluster_info = response
208-
return self.cluster_info
209-
except subprocess.CalledProcessError as e:
210-
logging.error("Failed when getting cluster status with error:\n%s\nand output:\n%s", e.stderr, e.stdout)
211-
raise
191+
cmd_args = ["pcluster", "describe-cluster", "--cluster-name", self.name]
192+
try:
193+
result = run_pcluster_command(cmd_args, log_error=False, custom_cli_credentials=self.custom_cli_credentials)
194+
response = json.loads(result.stdout)
195+
logging.info("Get cluster {0} status successfully".format(self.name))
196+
return response
197+
except subprocess.CalledProcessError as e:
198+
logging.error("Failed when getting cluster status with error:\n%s\nand output:\n%s", e.stderr, e.stdout)
199+
raise
212200

213201
def describe_compute_fleet(self):
214202
"""Run pcluster describe-compute-fleet and return the result."""
@@ -255,10 +243,7 @@ def get_cluster_instance_ids(self, node_type=None, queue_name=None):
255243

256244
def describe_login_nodes(self):
257245
"""List login node instances."""
258-
if self.login_nodes_info is None:
259-
self.login_nodes_info = self.describe_cluster_instances(node_type="LoginNode")
260-
261-
return self.login_nodes_info
246+
return self.describe_cluster_instances(node_type="LoginNode")
262247

263248
def get_login_node_public_ip(self):
264249
"""Return the ip address of the first healthy login node if exists."""
@@ -421,8 +406,6 @@ def _reset_cached_properties(self):
421406
self.__cfn_parameters = None
422407
self.__cfn_outputs = None
423408
self.__cfn_resources = None
424-
self.cluster_info = None
425-
self.login_nodes_info = None
426409

427410
def delete_resource_by_stack_id_tag(self):
428411
"""Delete resources by stack id tag."""

0 commit comments

Comments
 (0)