Skip to content

fix: convertMemToBytes helper #1716

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

darkweaver87
Copy link

@darkweaver87 darkweaver87 commented Jun 16, 2025

This PR fixes convertMemToBytes helper.

This function aims to handle SI, IEC prefixes or no prefixes (cf. https://github.com/kubeflow/crd-validation/blob/master/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go#L44).
SI prefixes use power of 10 (e.g. 1e18 = 1 x 10^18) (m | "" | k | M | G | T | P | E).
IEC prefixes use power of 2 (e.g. 0x1p60 = 2^60) (Ki | Mi | Gi | Ti | Pi | Ei).

The values should be the same:

  • 128974848 ✅
  • 129e6 ✅
  • 129M ✅
  • 128974848000m ❌
  • 123Mi ✅

Test:

$ helm template test ./charts/opentelemetry-collector/ -f charts/opentelemetry-collector/examples/using-GOMEMLIMIT/values.yaml --set resources.limits.memory=128974848000m | grep GOMEMLIMIT -A 1
            - name: GOMEMLIMIT
              value: "98400000000MiB"
$ git checkout fix/helper 
$ helm template test ./charts/opentelemetry-collector/ -f charts/opentelemetry-collector/examples/using-GOMEMLIMIT/values.yaml --set resources.limits.memory=128974848000m | grep GOMEMLIMIT -A 1
            - name: GOMEMLIMIT
              value: "98MiB"

Copy link
Contributor

github-actions bot commented Jul 5, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 5, 2025
@TylerHelmuth
Copy link
Member

@darkweaver87 please bump the chart's patch version and run make generate-examples CHARTS=opentelemetry-collector

@github-actions github-actions bot removed the Stale label Jul 9, 2025
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