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

Fix condition to keep the compatibility with old version in AWS #21

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

edcoll
Copy link
Contributor

@edcoll edcoll commented Dec 5, 2024

i'm using the next config in k8s to save in AWS

- name: AWS_REGION
  value: <xx-xxxx-x>
- name: OPENCOST_PARQUET_FILE_KEY_PREFIX
  value: <NAME>
- name: OPENCOST_PARQUET_S3_BUCKET
  value: <NAME>
- name: OPENCOST_PARQUET_S3_REGION
  value: <xx-xxxx-x>
- name: OPENCOST_PARQUET_SVC_HOSTNAME
  value: opencost.opencost.svc.cluster.local.
- name: OPENCOST_PARQUET_SVC_PORT
  value: '9003'

with the last commit i'm getting the follow error

Traceback (most recent call last):
  File "/app/opencost_parquet_exporter.py", line 321, in <module>
Starting run
Load data types
Load renaming coloumns
Load allocation keys to ignore
Build config
Retrieving data from opencost api
Opencost data retrieved successfully
Processing the data
Data processed successfully
Saving data
    main()
  File "/app/opencost_parquet_exporter.py", line 317, in main
    save_result(processed_data, config)
  File "/app/opencost_parquet_exporter.py", line 272, in save_result
    storage = get_storage(storage_backend=config['storage_backend'])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/storage_factory.py", line 31, in get_storage
    raise ValueError("Unsupported storage backend")
ValueError: Unsupported storage backend

then i tried with the value, how to indicated the example https://github.com/opencost/opencost-parquet-exporter/blob/v0.2.0/examples/k8s_cron_job.yaml#L39, but don't work

- name: OPENCOST_PARQUET_STORAGE_BACKEND
  value: aws

The error is cause by the default value is 'aws' in the main file https://github.com/opencost/opencost-parquet-exporter/blob/main/src/opencost_parquet_exporter.py#L129-L130 but the condition is with 's3' https://github.com/opencost/opencost-parquet-exporter/blob/v0.2.0/src/storage_factory.py#L28

i'm reading about is to keep the compatibility with de old version, therefore i propuse use IN with both values

@lmello
Copy link
Member

lmello commented Dec 9, 2024

Thank you for your contribution

@lmello lmello merged commit b194d26 into opencost:main Dec 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants