Skip to content

Commit 4a9f8e3

Browse files
authored
Merge pull request #113 from naved001/set-cluster-name
Add option to set cluster_name when uploading report to S3/B2
2 parents 77a3fd7 + 79ad4a1 commit 4a9f8e3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

k8s/base/produce-report-cronjob.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ spec:
1212
- name: daily-openshift-metrics-collector
1313
image: ghcr.io/cci-moc/openshift-usage-scripts:main
1414
env:
15+
- name: OPENSHIFT_CLUSTER_NAME
16+
value: nerc-ocp-prod
1517
- name: S3_OUTPUT_ACCESS_KEY_ID
1618
valueFrom:
1719
secretKeyRef:

openshift_metrics/merge.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,23 @@ def main():
160160

161161
if args.upload_to_s3:
162162
bucket_name = os.environ.get("S3_INVOICE_BUCKET", "nerc-invoicing")
163+
cluster_name = os.environ.get("OPENSHIFT_CLUSTER_NAME")
164+
assert cluster_name, "Please set OPENSHIFT_CLUSTER_NAME to upload to S3"
163165
primary_location = (
164166
f"Invoices/{report_month}/"
165-
f"Service Invoices/NERC OpenShift {report_month}.csv"
167+
f"Service Invoices/{cluster_name} {report_month}.csv"
166168
)
167169
utils.upload_to_s3(invoice_file, bucket_name, primary_location)
168170

169171
timestamp = datetime.utcnow().strftime('%Y%m%dT%H%M%SZ')
170172
secondary_location = (
171173
f"Invoices/{report_month}/"
172-
f"Archive/NERC OpenShift {report_month} {timestamp}.csv"
174+
f"Archive/{cluster_name} {report_month} {timestamp}.csv"
173175
)
174176
utils.upload_to_s3(invoice_file, bucket_name, secondary_location)
175177
pod_report_location = (
176178
f"Invoices/{report_month}/"
177-
f"Archive/Pod-NERC OpenShift {report_month} {timestamp}.csv"
179+
f"Archive/Pod-{cluster_name} {report_month} {timestamp}.csv"
178180
)
179181
utils.upload_to_s3(pod_report_file, bucket_name, pod_report_location)
180182

0 commit comments

Comments
 (0)