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 error when loading custom pricing configuration file #206

Merged
merged 3 commits into from
Jun 3, 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
2 changes: 1 addition & 1 deletion charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
- finops
- monitoring
- opencost
version: 1.37.1
version: 1.38.0
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
2 changes: 1 addition & 1 deletion charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ spec:
readOnly: false
{{- end }}
{{- if .Values.opencost.customPricing.enabled }}
- mountPath: {{ .Values.opencost.customPricing.configPath }}
- mountPath: {{ .Values.opencost.customPricing.configPath }}/{{ include "opencost.configFileName" . }}.json
name: custom-configs
subPath: {{ include "opencost.configFileName" . }}.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the subPath isn't working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it gets mounted as a file:

~ $ ls /tmp/custom-config -l
-rw-r--r--    1 root     root           299 May 15 10:27 /tmp/custom-config
~ $ cat /tmp/custom-config 
{
  "CPU": "1.25",
  "GPU": "0.95",
  "RAM": "0.5",
  "description": "Modified pricing configuration.",
  "internetNetworkEgress": "0.12",
  "regionNetworkEgress": "0.01",
  "spotCPU": "0.006655",
  "spotRAM": "0.000892",
  "storage": "0.25",
  "zoneNetworkEgress": "0.01",
  "provider" : "custom"
}~ $

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @mogaal said,
The subPath specifies what key should be loaded from the configmap. The mountPath is the full path to the file loaded, so it should also contain the file's name or else the custom-config would be considered as the mounted file's name. Final applied deployment should be like this:

        - mountPath: /tmp/custom-config/default.json
          name: custom-configs
          readOnly: true
          subPath: default.json

readOnly: true
Expand Down
Loading