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

Create timestamp for indexing as the creation/deletion launch, not when finish #32

Merged
merged 1 commit into from
Oct 21, 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
5 changes: 2 additions & 3 deletions libs/platforms/azure/hypershiftcli/hypershiftcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def delete_cluster(self, platform, cluster_name):
cluster_info = platform.environment["clusters"][cluster_name]
cluster_start_time = int(datetime.datetime.utcnow().timestamp())
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info['mgmt_cluster_name'] = self.environment['mgmt_cluster_name']
cluster_info["install_method"] = "hypershiftcli"
cluster_info['resource_group_name'] = "rg-" + cluster_name
Expand Down Expand Up @@ -225,7 +226,6 @@ def delete_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_destroy.json file located at {cluster_info['path']}")
if self.es is not None:
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
self.es.index_metadata(cluster_info)

def wait_for_cluster_ready(self, cluster_name, wait_time):
Expand Down Expand Up @@ -302,6 +302,7 @@ def create_cluster(self, platform, cluster_name):
myenv["KUBECONFIG"] = self.environment['mc_kubeconfig']
cluster_info = platform.environment["clusters"][cluster_name]
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info["hostedclusters"] = self.environment["cluster_count"]
cluster_info["install_method"] = "hypershiftcli"
cluster_info['mgmt_cluster_name'] = self.environment['mgmt_cluster_name']
Expand Down Expand Up @@ -357,7 +358,6 @@ def create_cluster(self, platform, cluster_name):
# 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(platform, cluster_name)
cluster_info["install_duration"] = cluster_end_time - cluster_start_time
Expand Down Expand Up @@ -403,7 +403,6 @@ def create_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_install.json file located at {cluster_info['path']}")
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}"
Expand Down
5 changes: 2 additions & 3 deletions libs/platforms/rosa/hypershift/hypershift.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def delete_cluster(self, platform, cluster_name):
cluster_info = platform.environment["clusters"][cluster_name]
cluster_start_time = int(datetime.datetime.utcnow().timestamp())
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info["install_method"] = "rosa"
cluster_info["mgmt_cluster_name"] = self._get_mc(cluster_info["metadata"]["cluster_id"])
self.logging.info(f"Deleting cluster {cluster_name} on Hypershift Platform")
Expand Down Expand Up @@ -329,7 +330,6 @@ def delete_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_install.json file located at {cluster_info['path']}")
if self.es is not None:
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
self.es.index_metadata(cluster_info)

def _get_aws_role_name(self, cluster_name):
Expand Down Expand Up @@ -430,6 +430,7 @@ def create_cluster(self, platform, cluster_name):
super().create_cluster(platform, cluster_name)
cluster_info = platform.environment["clusters"][cluster_name]
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info["hostedclusters"] = self.environment["cluster_count"]
cluster_info["environment"] = self.environment["rosa_env"]
cluster_info["install_method"] = "rosa"
Expand Down Expand Up @@ -514,7 +515,6 @@ def create_cluster(self, platform, cluster_name):
else:
cluster_info['status'] = "installed"
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(platform, cluster_name)
cluster_info["install_duration"] = cluster_end_time - cluster_start_time
Expand Down Expand Up @@ -565,7 +565,6 @@ def create_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_install.json file located at {cluster_info['path']}")
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
Expand Down
5 changes: 2 additions & 3 deletions libs/platforms/rosa/terraform/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def delete_cluster(self, platform, cluster_name):
cluster_info = platform.environment["clusters"][cluster_name]
cluster_start_time = int(datetime.datetime.utcnow().timestamp())
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info["install_method"] = "terraform"
self.logging.info(f"Deleting cluster {cluster_name} on Rosa Platform using terraform")
cleanup_code, cleanup_out, cleanup_err = self.utils.subprocess_exec("terraform apply -destroy -state=" + cluster_info['path'] + "/terraform.tfstate --auto-approve", cluster_info["path"] + "/cleanup.log", {"cwd": self.environment['path'] + "/terraform", 'preexec_fn': self.utils.disable_signals, "env": myenv})
Expand Down Expand Up @@ -88,7 +89,6 @@ def delete_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_install.json file located at {cluster_info['path']}")
if self.es is not None:
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
self.es.index_metadata(cluster_info)

def get_workers_ready(self, kubeconfig, cluster_name):
Expand Down Expand Up @@ -120,6 +120,7 @@ def create_cluster(self, platform, cluster_name):
super().create_cluster(platform, cluster_name)
cluster_info = platform.environment["clusters"][cluster_name]
cluster_info["uuid"] = self.environment["uuid"]
cluster_info["timestamp"] = datetime.datetime.utcnow().isoformat()
cluster_info["install_method"] = "terraform"
self.logging.info(f"Creating cluster {cluster_info['index']} on ROSA with name {cluster_name} and {cluster_info['workers']} workers")
cluster_info["path"] = platform.environment["path"] + "/" + cluster_name
Expand Down Expand Up @@ -169,7 +170,6 @@ def create_cluster(self, platform, cluster_name):
return 1
else:
cluster_end_time = int(datetime.datetime.utcnow().timestamp())
index_time = datetime.datetime.utcnow().isoformat()
break

cluster_info['status'] = "installed"
Expand Down Expand Up @@ -203,7 +203,6 @@ def create_cluster(self, platform, cluster_name):
self.logging.error(err)
self.logging.error(f"Failed to write metadata_install.json file located at {cluster_info['path']}")
if self.es is not None:
cluster_info["timestamp"] = index_time
self.es.index_metadata(cluster_info)

def _wait_for_workers(self, kubeconfig, worker_nodes, wait_time, cluster_name, machinepool_name):
Expand Down
Loading