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

Conversation

mogaal
Copy link
Contributor

@mogaal mogaal commented May 15, 2024

This fixes the bug I reported in #205, where the CONFIG_PATH directory is mounted as a file instead of as a directory:

~ $ 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"
}~ $

This causes the pod to fail with:

opencost 2024-05-15T10:27:58.127897889Z ERR error accessing cloud provider configuration: stat /tmp/custom-config/default.json: not a directory

@mogaal
Copy link
Contributor Author

mogaal commented May 15, 2024

@mattray Hi, when you have some time, pls let me know if this looks good to you 🙏

@@ -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

@valdisrigdon
Copy link
Contributor

#208 should have the full fix for this, as you need to fix the custom metrics too.

Signed-off-by: Matt Ray <github@mattray.dev>
@mattray mattray merged commit 048ec6c into opencost:main Jun 3, 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.

4 participants