Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

included MC metrics indexing for HCP creation #30

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/platforms/azure/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def get_workers_ready(self, kubeconfig, cluster_name):
super().get_workers_ready(kubeconfig, cluster_name)
return Platform.get_workers_ready(self, kubeconfig, cluster_name)

def get_metadata(self, platform, cluster_name):
super().get_metadata(platform, cluster_name)
metadata = {}
# TODO Implement metadata logic when ready to use
return metadata

def watcher(self):
super().watcher()

Expand Down
18 changes: 9 additions & 9 deletions libs/platforms/azure/hypershiftcli/hypershiftcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def watcher(self):
self.logging.debug(self.environment['clusters'])
self.logging.info("Watcher terminated")

def get_metadata(self, cluster_name):
metadata = {}
def get_metadata(self, platform, cluster_name):
metadata = super().get_metadata(platform, cluster_name)
self.logging.info(f"Getting information for cluster {cluster_name} from {self.environment['mgmt_cluster_name']}")
myenv = os.environ.copy()
myenv["KUBECONFIG"] = self.environment["mc_kubeconfig"]
Expand Down Expand Up @@ -312,7 +312,7 @@ def create_cluster(self, platform, cluster_name):
self.logging.debug("Output directory set to %s" % cluster_info["path"])

# Create the resource group
rg_create_code, rg_create_out, rg_create_err = self.utils.subprocess_exec("az group create --subscription " + self.environment['subscription_id'] + " --location " + self.environment['azure_region'] + " --name rg-" + cluster_name, cluster_info["path"] + "/az_group_create.log")
rg_create_code, rg_create_out, rg_create_err = self.utils.subprocess_exec("az group create --subscription " + self.environment['subscription_id'] + " --location " + self.environment['azure_region'] + " --name rg-" + cluster_name + " --tags TicketId=471", cluster_info["path"] + "/az_group_create.log")
if rg_create_code != 0:
self.logging.error(f"Failed to create the azure resource group rg_{cluster_name} for cluster {cluster_name}")
return 1
Expand Down Expand Up @@ -351,15 +351,15 @@ def create_cluster(self, platform, cluster_name):
break
cluster_info['status'] = "Created"
self.logging.info(f"Cluster {cluster_name} installation finished on the {trying} try")
cluster_info["metadata"] = self.get_metadata(cluster_name)
cluster_info["metadata"] = self.get_metadata(platform, cluster_name)
cluster_info["install_try"] = trying
# mc_namespace = executor.submit(self._namespace_wait, platform.environment["mc_kubeconfig"], cluster_info["metadata"]["cluster_id"], cluster_name, "Management") if platform.environment["mc_kubeconfig"] != "" else 0
# cluster_info["mc_namespace_timing"] = mc_namespace.result() - cluster_start_time if platform.environment["mc_kubeconfig"] != "" else None
# cluster_start_time_on_mc = mc_namespace.result()
cluster_end_time = int(datetime.datetime.utcnow().timestamp())
index_time = datetime.datetime.utcnow().isoformat()
# # Getting againg metadata to update the cluster status
cluster_info["metadata"] = self.get_metadata(cluster_name)
cluster_info["metadata"] = self.get_metadata(platform, cluster_name)
cluster_info["install_duration"] = cluster_end_time - cluster_start_time
self.logging.info(f"Waiting 60 minutes until cluster {cluster_name} status on {self.environment['mgmt_cluster_name']} will be completed")
cluster_info["cluster_ready"] = self.wait_for_cluster_ready(cluster_name, 60)
Expand Down Expand Up @@ -405,12 +405,12 @@ def create_cluster(self, platform, cluster_name):
if self.es is not None:
cluster_info["timestamp"] = index_time
self.es.index_metadata(cluster_info)
# self.logging.info("Indexing Management cluster stats")
# os.environ["START_TIME"] = f"{cluster_start_time_on_mc}" # excludes pre-flight durations
# os.environ["END_TIME"] = f"{cluster_end_time}"
self.logging.info("Indexing Management cluster stats")
os.environ["START_TIME"] = f"{cluster_start_time}"
os.environ["END_TIME"] = f"{cluster_end_time}"
self.logging.info("Waiting 2 minutes for HC prometheus to be available for scrapping")
time.sleep(120)
# self.utils.cluster_load(platform, cluster_name, load="index")
self.utils.cluster_load(platform, cluster_name, load="index")

def _namespace_wait(self, kubeconfig, cluster_id, cluster_name, type):
start_time = int(datetime.datetime.utcnow().timestamp())
Expand Down
Loading