$ the-wire · showcase
Kubernetes resource quantities saturate instead of silently wrapping
By RepoJournal · Filed · About Kubernetes · Composed from the cited sources · methodology
Kubernetes added Quantity.AsScaledInt64 and AsMilliInt64 so overflow returns a clamped int64 with ok=false instead of a silently wrong number, while the cloud-provider-openstack chart release process moves to a -dev suffix on master.
The resource package now exposes Quantity.AsScaledInt64(scale) and AsMilliInt64, each returning ok=false when the value does not fit an int64 and saturating to math.MinInt64 or math.MaxInt64 on the sign-correct rail [1]. The existing Value, MilliValue and ScaledValue become wrappers that drop the bool, so their callers see a saturated value. The commit states the motivating bug plainly: "Value, MilliValue and ScaledValue wrap silently on overflow, so NewScaledQuantity(math.MaxInt64, 1).Value() returns -10 instead of a clamped result" [1]. A follow-up flipped the accessor baseline for the saturating wrappers, moving rows that carried saturatePos or saturateNeg to math.MaxInt64 or math.MinInt64 and dropping the two shared constants [2].
In cloud-provider-openstack, the chart release process changes: master charts now carry a '-dev' suffix, restricting releases from master to new major versions such as the forthcoming v1.37.0 [3]. The PR notes that 'appVersion' cannot follow, since images are only promoted on explicit release tags, so these -dev releases still use the .0 from the latest stable release, which the author describes as making them 'kind of useless' while still exercising the machinery regularly [3]. The same effort adds a make lint-charts target intended for a separate prow job, allowing the GitHub Actions workflow to be removed [4], and adds dependabot configuration for master plus the supported release-1.36 and release-1.34 branches, since release-1.33 and below are no longer supported [5]. A servicemonitor helm test was fixed after label reduction on the OCCM chart manifests removed managed-by, version, and chart labels from the Service selector [6].
On the docs side, kubernetes/website added an overview page for the Configuration concept [7] and updated the Service CIDR docs validation admission policy example [8]. The latter addresses the apiserver now being allowed to update the default ServiceCIDR during a single-to-dual-stack migration, which broke existing guardrails; the new ValidationAdmissionPolicy lets cluster admins enforce the previous behavior [8]. Two in-flight docs changes cover CEL cidr and isCIDR examples that currently render as run-on lines because the site does not enable hardWraps [9], and a switch from yum to dnf with an RHEL10 install command for kubeadm, tied to kubelet's iptables dependency becoming Recommended rather than Requires [10].
Routine dependency work continues across the release tooling: golang.org/x/mod moved 0.40.0 to 0.41.0 and golang.org/x/oauth2 0.36.0 to 0.37.0 in publishing-bot [11][12], and google.golang.org/api went 0.290.0 to 0.297.0 in kubernetes/release [13].
Action items
- → Audit code calling Quantity.Value, MilliValue, or ScaledValue that could overflow, and switch to AsScaledInt64 or AsMilliInt64 where the ok result matters kubernetes/kubernetes [plan]
- → Update chart release tooling in cloud-provider-openstack for the '-dev' suffix on master charts kubernetes/cloud-provider-openstack [plan]
- → Review the new Service CIDR ValidationAdmissionPolicy example if you run single-to-dual-stack migration kubernetes/website [monitor]
References
- [1] resource: add Quantity.AsScaledInt64 and AsMilliInt64 ↗ kubernetes/kubernetes
- [2] resource: flip the accessor baseline for the saturating wrappers ↗ kubernetes/kubernetes
- [3] Change Chart release process (#3195) ↗ kubernetes/cloud-provider-openstack
- [4] make: Add lint-charts target (#3208) ↗ kubernetes/cloud-provider-openstack
- [5] Add dependabot configuration ↗ kubernetes/cloud-provider-openstack
- [6] [occm] test: fix servicemonitor test after label reduction (#3200) ↗ kubernetes/cloud-provider-openstack
- [7] Add overview for Configuration concept ↗ kubernetes/website
- [8] update service cidr docs validation admission policy example ↗ kubernetes/website
- [9] Use tables for the cidr and isCIDR examples on the CEL page ↗ kubernetes/website
- [10] Change `yum` to `dnf` and update RHEL10 install command ↗ kubernetes/website
- [11] Merge pull request #570 from kubernetes/dependabot/go_modules/golang.org/x/mod-0.41.0 ↗ kubernetes/publishing-bot
- [12] Merge pull request #571 from kubernetes/dependabot/go_modules/golang.org/x/oauth2-0.37.0 ↗ kubernetes/publishing-bot
- [13] Merge pull request #4527 from kubernetes/dependabot/go_modules/google.golang.org/api-0.297.0 ↗ kubernetes/release