Skip to content

Commit 64129b8

Browse files
committed
Add support so that we can still generate reports from old metrics files
Older metrics files will not have cluster_name in those.
1 parent e96c586 commit 64129b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

openshift_metrics/merge.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ def main():
9898

9999
report_start_date = None
100100
report_end_date = None
101-
101+
cluster_name = None
102102
processor = MetricsProcessor()
103103

104104
for file in files:
105105
with open(file, "r") as jsonfile:
106106
metrics_from_file = json.load(jsonfile)
107-
cluster_name = metrics_from_file["cluster_name"]
107+
if cluster_name is None:
108+
cluster_name = metrics_from_file.get("cluster_name")
108109
cpu_request_metrics = metrics_from_file["cpu_metrics"]
109110
memory_request_metrics = metrics_from_file["memory_metrics"]
110111
gpu_request_metrics = metrics_from_file.get("gpu_metrics", None)
@@ -123,7 +124,10 @@ def main():
123124
elif compare_dates(report_end_date, metrics_from_file["end_date"]):
124125
report_end_date = metrics_from_file["end_date"]
125126

126-
logger.info(f"Generating report from {report_start_date} to {report_end_date}")
127+
if cluster_name is None:
128+
cluster_name = "Unknown Cluster"
129+
130+
logger.info(f"Generating report from {report_start_date} to {report_end_date} for {cluster_name}")
127131
if ignore_hours:
128132
for start_time, end_time in ignore_hours:
129133
logger.info(f"{start_time} to {end_time} will be excluded from the invoice")

0 commit comments

Comments
 (0)