Accept a memory target in the autoscaling values

What does this MR do?

Setting autoscaling.targetMemoryUtilizationPercentage makes every helm install, helm upgrade and helm template of the chart fail:

Error: values don't meet the specifications of the schema(s) in the following chart(s):
openbao:
- at '/autoscaling': additional properties 'targetMemoryUtilizationPercentage' not allowed

templates/hpa.yaml adds a memory metric when that key is set, and values.yaml shows it as a commented-out example. Since the values schema came in with !39 (merged), the autoscaling block carries additionalProperties: false and declares only the replica bounds and the CPU target, so the memory metric can never render.

As suggested in review, this MR keeps the HorizontalPodAutoscaler with all its scaling values and adds the memory target to the schema, in two commits:

  • Adds tests/hpa_test.yaml for the HorizontalPodAutoscaler as it renders today: the OpenBao Deployment as its target, the replica bounds and the CPU metric.
  • Declares targetMemoryUtilizationPercentage in values.yaml as a nullable integer that defaults to null, annotated # @schema type:[integer, null] like the nullable integers of the PostgreSQL storage block, and regenerates values.schema.json with helm schema. The new property is the only change to the schema. Adds tests for the memory metric and for the refusal of a target that is not an integer, and bumps the chart version to 0.20.1.

With the default values the HorizontalPodAutoscaler still scales on CPU only, and the rendered manifests are the same as on main apart from the chart version label, checksum/config, which hashes the ConfigMap that carries that label, and the randomly generated static unseal key.

Like the CPU target, the memory target is a percentage of the pods' memory request, so it takes effect only when resources.requests.memory is set; !81 proposes default requests.

The OpenBao page of the GitLab chart lists the memory target as autoscaling.targetCPUMemoryPercentage, a key the schema refuses; I will correct the name there when the GitLab chart moves to a release of this chart that accepts the memory target.

Author's Checklist

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Ensure a release milestone is set.
  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline on GitLab.com. (Pending the pipeline for the new head; helm-lint, helm-unittest and check-values-schema pass locally on each commit, see the test plan.)
  • When ready for review, MR is labeled workflowready for review per the MR workflow.

Expected

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation is created or updated. (The chart documentation lives in the GitLab chart; follow-up described above.)
  • Tests are added.
Test plan and results

All commands ran in registry.gitlab.com/gitlab-com/gl-infra/common-ci-tasks-images/helm:3.19.0, the image the helm-lint, helm-unittest and check-values-schema jobs use (Helm 3.19.0, helm-unittest 1.0.3, helm-values-schema-json 2.6.0 installed from its repository as the job does), on each commit of the branch, which is based on the current main.

The memory tests on the first commit, before the schema change:

 FAIL  Test HorizontalPodAutoscaler	tests/hpa_test.yaml
	- Adds a memory metric when targetMemoryUtilizationPercentage is set
		Error: values don't meet the specifications of the schema(s) in the following chart(s):
openbao:
- at '/autoscaling': additional properties 'targetMemoryUtilizationPercentage' not allowed
	- Rejects a targetMemoryUtilizationPercentage that is not an integer
		Error: values don't meet the specifications of the schema(s) in the following chart(s):
openbao:
- at '/autoscaling': additional properties 'targetMemoryUtilizationPercentage' not allowed
Tests:       2 failed, 2 errored, 92 passed, 94 total

With the change:

  • helm unittest ./: 14 suites, 94 tests passed (92 on the first commit).
  • helm lint ./ --strict: 1 chart linted, 0 failed, on both commits.
  • helm schema && git diff --exit-code values.schema.json: no difference, on both commits.
  • helm template t ./ --show-only templates/hpa.yaml: only the cpu metric, as before.
  • helm template t ./ --show-only templates/hpa.yaml --set autoscaling.targetMemoryUtilizationPercentage=80: a second metric, memory with averageUtilization: 80.
  • --set-string autoscaling.targetMemoryUtilizationPercentage=80: refused with at '/autoscaling/targetMemoryUtilizationPercentage': got string, want null or integer.
  • helm template t ./ with the default values and with each file under examples/: same output as main apart from the chart version label, checksum/config and the randomly generated static unseal key, which differs between any two renders.

The new tests fail if the memory branch is removed from templates/hpa.yaml, if the schema accepts any value for the key, if the key defaults to 80, or if the template reads the wrong replica bound or a fixed CPU target.

No issue covers this. Related to !39 (merged), which introduced the schema, and !81, which proposes default resource requests, the values both utilization targets are measured against.

Edited by José M. Requena Plens

Merge request reports

Loading
Loading