Skip to content

Commit

Permalink
check cluster state before pulling MC details
Browse files Browse the repository at this point in the history
Signed-off-by: Murali Krishnasamy <[email protected]>
  • Loading branch information
mukrishn committed Aug 21, 2024
1 parent 218ea8b commit 9f30e90
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions libs/platforms/rosa/hypershift/hypershift.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,22 @@ def _get_mc(self, cluster_id):
# Get Hypershift cluster metadata and set required platform environment variables
def get_metadata(self, platform, cluster_name):
metadata = {}
self.logging.debug(f"Get metadata of Hypershift cluster {cluster_name}")
cluster_mc = self._get_mc(self.get_cluster_id(cluster_name))
metadata["mgmt_cluster_name"] = cluster_mc
platform.environment["mc_kubeconfig"] = platform.environment["path"] + "/kubeconfig_" + cluster_mc
self.logging.info(f"Getting information for cluster {cluster_name}")
metadata_code, metadata_out, metadata_err = self.utils.subprocess_exec(
"rosa describe cluster -c " + cluster_name + " -o json",
extra_params={"universal_newlines": True}
)
try:
status = json.loads(metadata_out)["state"]
except Exception as err:
self.logging.error(f"Cannot load metadata for cluster {cluster_name}")
self.logging.error(err)

if status == "ready":
self.logging.debug(f"Get metadata of Hypershift cluster {cluster_name}")
cluster_mc = self._get_mc(self.get_cluster_id(cluster_name))
metadata["mgmt_cluster_name"] = cluster_mc
platform.environment["mc_kubeconfig"] = platform.environment["path"] + "/kubeconfig_" + cluster_mc
return metadata

def platform_cleanup(self):
Expand Down

0 comments on commit 9f30e90

Please sign in to comment.