#4020·opencost

customPricing CPU/RAM values silently divided by ~730 before reaching node cost calculation (OVH provider, bare-metal fallback)

Author: malyushkinCreated Aug 26, 2026Updated Aug 26, 2026

Environment

  • opencost 1.120.4 (chart opencost/opencost-helm-chart 2.5.26)
  • Bare-metal on-prem cluster on OVHcloud, no node.k8s.ovh/type label on any node
  • CLOUD_PROVIDER=OVH set explicitly
  • customPricing.enabled=true, costModel.CPU=0.006407, costModel.RAM=0.000859 (EUR/hour), delivered via a ConfigMap watched through ConfigWatcherFor (not file-mounted)

Summary

Bare-metal nodes never match the OVHcloud Public Cloud catalog, so NodePricing() errors on every one of them. GetNodeCost() catches that error and falls back to cfg.CPU/cfg.RAM from cp.GetConfig(). The resulting node_total_hourly_cost comes out ~700-1300x lower than (vCPU × costModel.CPU) + (RAM_GiB × costModel.RAM), varying by node tier.

Evidence

1. Live metric vs. expected, on a 32 vCPU / 188GiB bare-metal node:

expected: 32 × 0.006407 + 188 × 0.000859 = €0.366/hour
actual:   node_total_hourly_cost = €0.000476/hour

Same pattern on a storage-tier node with different specs.

2. Startup logs, right after a pod restart:

Found configmap custom-pricing-model, watching...
Loaded OVH pricing: 156 flavors, 7 volume types
Could not get node pricing for node <redacted>: flavor not found in OVH pricing: advance-4-amd-epyc-4584px. Falling back to default pricing.

No CustomPricing Config Updated line appears before these fallback computations run.

3. The on-disk cache file inside the running pod, /tmp/custom-config/ovh.json, holds:

json
{"CPU":"0.000009","RAM":"0.000001","spotCPU":"0.000009","spotRAM":"0.000001", ...}

These match our configured CPU/RAM/spotCPU/spotRAM divided by 730 (hours/month), rounded to 6 decimals. Other fields in the same file (zoneNetworkEgress, etc.) keep their configured values, so the division targets specifically these four per-resource-hour rate fields.

4. customPricingHasChanged() polls cp.GetConfig() every 500ms and logs on change. Captured live, within one second:

Flushing cost data caches: false:0.006407:0.006655:0.000859:0.000892:0:0:EUR
Flushing cost data caches: false:0.000009:0.000009:0.000001:0.000001:0:0:EUR
CustomPricing Config Updated: modified

GetConfig() returns the correct values, then the divided ones, half a second apart — before the ConfigMap watcher even reports the update. Points to a race or in-place mutation on the shared *models.CustomPricing struct, not a one-time startup cache (the emitter loop recomputes every 60s per pkg/costmodel/metrics.go, and still lands on the wrong value every time).

Ruled out

  • customPricing.provider: custom vs ovh: no effect. CustomPricing.Provider is never read for pricing logic anywhere in the codebase, only as a descriptive field.
  • hoursPerMonth = 730.0 in ovh/provider.go: only used at line 237 to convert a catalog flavor's monthly price for cloud/burst nodes, unrelated to customPricing.
  • SetCustomPricingField, UpdateFromMap, sanitizeFloatString: traced all three, none divide or round beyond formatting.
  • Manually forcing fresh ConfigMap "Modified" events: watcher receives them (confirmed via logs), but node_total_hourly_cost doesn't change.

We couldn't pin the exact line doing the division in the time we spent; it likely needs live debugging (breakpoint or added logging) rather than more static reading.

Related

  • #3627 added the OVH provider; its description confirms bare-metal nodes were never a designed pricing case, only node.k8s.ovh/type-labeled cloud/burst nodes.
  • #3601 / #3604 (open, unmerged) describe a very similar "custom pricing change doesn't take effect, stale value persists" symptom in the settings cache. Possibly the same root cause, possibly adjacent.
  • #1760 is a related but distinct ConfigMapWatcher/file-mount permission issue, open since 2023.

Workaround

CSVProvider (USE_CSV_PROVIDER/CSV_PATH, matching nodes by name) sidesteps this path entirely, since it prices every node explicitly by name instead of relying on the customPricing fallback.