Skip to content

Commit 954b1f1

Browse files
committed
Upload the daily report to the S3 location as outlined in the proposal
Also use a single timestamp for current_time throughout the report.
1 parent ccb5c35 commit 954b1f1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

openshift_metrics/merge.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,10 @@ def main():
213213
report_start_date = datetime.strptime(report_start_date, "%Y-%m-%d").replace(
214214
tzinfo=UTC
215215
)
216-
report_end_date = datetime.strptime(report_end_date, "%Y-%m-%d").replace(
217-
tzinfo=UTC
218-
) + timedelta(days=1)
216+
report_end_date = datetime.strptime(report_end_date, "%Y-%m-%d").replace(tzinfo=UTC)
219217

220218
logger.info(
221-
f"Generating report from {report_start_date} to {report_end_date} for {cluster_name}"
219+
f"Generating report from {report_start_date} to {report_end_date + timedelta(days=1)} for {cluster_name}"
222220
)
223221

224222
if report_start_date.month != report_end_date.month:
@@ -230,13 +228,13 @@ def main():
230228
)
231229

232230
su_definitions = get_su_definitions(report_month)
233-
231+
current_time = datetime.now(UTC)
234232
report_metadata = invoice.ReportMetadata(
235233
report_month=report_month,
236234
cluster_name=cluster_name,
237235
report_start_time=report_start_date,
238-
report_end_time=report_end_date,
239-
generated_at=datetime.now(UTC),
236+
report_end_time=report_end_date + timedelta(days=1),
237+
generated_at=current_time,
240238
)
241239

242240
utils.write_metrics_by_namespace(
@@ -269,8 +267,13 @@ def main():
269267
f"Service Invoices/{cluster_name} {report_month}.csv"
270268
)
271269
utils.upload_to_s3(invoice_file, S3_INVOICE_BUCKET, primary_location)
270+
report_date = report_end_date.strftime("%Y-%m-%d")
271+
daily_report_location = (
272+
f"Invoices/{report_month}/Service Invoices/{cluster_name} {report_date}.csv"
273+
)
274+
utils.upload_to_s3(pod_report_file, S3_INVOICE_BUCKET, daily_report_location)
272275

273-
timestamp = datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
276+
timestamp = current_time.strftime("%Y%m%dT%H%M%SZ")
274277
secondary_location = (
275278
f"Invoices/{report_month}/"
276279
f"Archive/{cluster_name} {report_month} {timestamp}.csv"

0 commit comments

Comments
 (0)