Repository navigation
Conversation
…ests apply_config treated every huge page a worker carried before simplyblock as the host's own and added simplyblock's pages on top. On Kubernetes that pool is accounted for: a pod can use only the hugepages-2Mi it requests, so pages no pod requests are unused. apply_config now lists the pods on the node, leaves simplyblock's storage pods out, and keeps the host's share at no more than what the others request. A pool that already holds both is left as it is; one that does not grows by the shortfall. When the pods cannot be listed, the previous behavior stays. The e2e lblk run 44678939560 reserved 7958 pages that no pod requested; apply_config raised the pool to 12028 (23.5 GiB of 31 GiB), the kubelet took all of it out of the node's memory, and the SPDK pod stayed Pending on "Insufficient memory" until the run timed out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Huge-page sizing can leave capacity below combined workload demand by undercounting growing pod claims and native sidecars, while valid Kubernetes quantity requests can cause configuration to fail.
3 open issues
What changed in this PR
This PR adjusts Kubernetes worker huge-page sizing to reuse existing capacity based on other pods’ requests, aiming to avoid unnecessary pool growth that reduces memory available for scheduling.
Changes:
- Counts other pods’ huge-page requests, excluding simplyblock storage pods and finished pods.
- Passes those claims into pool sizing while preserving previous behavior when pod listing fails.
- Adds six regression tests and isolates an existing sizing test from Kubernetes access.
| File | Description |
|---|---|
tests/unit/test_talos_hugepages.py |
Mocks pod accounting in the existing sizing test. |
tests/unit/test_hugepages_kube_accounting.py |
Covers pool reuse, growth, pod exclusions, and listing failure. |
simplyblock_web/api/internal/storage_node/kubernetes.py |
Collects pod huge-page requests and supplies them to sizing. |
simplyblock_core/utils/__init__.py |
Adds optional claim-aware huge-page allocation. |
Review effort: Balanced
Three gaps in the pod accounting, from the review of #1698: - The pods' claim was capped at the recorded baseline. On a host that reserved nothing itself, a pool simplyblock had grown to 4096 and a pod claiming 2000 of it was left at 4096, short of the 2000 beside simplyblock's 3990. The claim is now the host's share as it stands, and a claim above the baseline raises the baseline, so release_hugepages leaves those pages to the host. - Requests were read with the MiB-only converter, which raised on valid quantities such as 4194304k outside the error handling and failed apply_config. They are now parsed with kubernetes.utils.parse_quantity, inside the handler. - Native sidecars (init containers with restartPolicy Always) were counted like init containers that finish. They now add to the app containers and to every init container started after them, as the scheduler counts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
apply_configtreated every huge page the host carried before simplyblock as the host's own and added simplyblock's pages on top.hugepages-2Miit requests, because the kubelet sets each container's hugetlb limit to its request. Pages that no pod requests are therefore unused, and the kubelet still removes them from the node's memory.apply_confignow lists the pods on the node, leaves out simplyblock's storage pods (role=simplyblock-storage-node) and finished pods, and sums theirhugepages-2Mirequests. That sum becomes the host's share. A sum above the recorded baseline raises the baseline, sorelease_hugepagesleaves those pages to the host. Requests are parsed as Kubernetes quantities, and native sidecars (init containers withrestartPolicy: Always) count beside the app containers, as the scheduler counts them. A pool that already holds both shares is left as it is, and one that doesn't grows by the shortfall.set_hugepages_if_neededtakes the sum as an optionalclaimed_by_others; without it, the function behaves as before.Why
In e2e lblk run 44678939560, the test bootstrap reserved 7958 pages on a 31 GiB n2-standard-8, and no pod requested them.
apply_configraised the pool to 12028 pages (23.5 GiB), which left about 7.6 GiB of ordinary memory on the worker. The SPDK pod's 2188 MiB didn't fit beside the 5.9 GiB the control-plane pods on that worker requested. It stayed Pending withFailedScheduling: Insufficient memory, and node add retried until the run timed out. With this change the pool stays at 7958 pages, which already covers the 3990 simplyblock needs.Limits
_talos_managed_pool) is unchanged.Test plan
tests/unit/test_hugepages_kube_accounting.pyreproduces the e2e worker. Against unchanged code, 5 of its 6 tests fail withassert 12028 == 7958, the pool size from the e2e run. With the fix, all 6 pass.adjust_hugepages(6000 + 3990)), a leftover simplyblock storage pod, finished pods, and pods that can't be listed (previous behavior).release_hugepages, a4194304krequest reads as 2000 pages, a native sidecar counts beside the app containers, and an ordinary init container counts only while it runs. The first three failed against the previous commit.apply_configsizing), and theapply_configsizing test no longer reaches a real Kubernetes client.tox -e unit,py314t-unit,types: 7485 passed on each interpreter and mypy is clean. The one failure,test_spdk_proxy_unit.py::TestMetricsEndpoint::test_metrics_are_served, also fails without this change on macOS, becauseprocess_open_fdsis exported only on Linux.🤖 Generated with Claude Code