Skip to content

CKS: reconcile node capacity after live resize - #14223

Open
andrijapanicsb wants to merge 17 commits into
mainfrom
cks-live-resize-capacity-reconciliation
Open

andrijapanicsb wants to merge 17 commits into
mainfrom
cks-live-resize-capacity-reconciliation

Conversation

@andrijapanicsb

@andrijapanicsb andrijapanicsb commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Context

#13226 added live compute-offering changes for CKS nodes, building on #12975. The VM could gain CPU/RAM while Kubernetes still reported the old capacity. Operators had to activate guest resources and restart kubelet manually. #14213 tracks that gap.

Changes

CKS now activates and verifies the added guest CPU/RAM, restarts kubelet when needed, and waits for the Node to report the new capacity and allocatable resources before completing the scale operation.

Nodes are handled one at a time without draining resident Pods. While a node's resize is in progress, the node carries a cloudstack.apache.org/cks-live-resize-pending annotation and, unless an operator had already cordoned it, a CKS cordon. Both are set and removed with single conditional Node updates. If a scale fails, the annotation stays, and the CKS cordon stays too if the VM already reached the new offering. A retry of the same scale finishes that node before it changes any other. An existing operator cordon is preserved.

QA also exposed a pre-existing cluster CPU/RAM accounting bug, not a regression from this PR. Totals are now calculated from the configured per-node-type offerings and counts, so the API and UI reflect mixed control/worker offerings correctly.

Functional and regression testing

Test environment: Cloud-managed KVM, isolated network, published packages from f92e52d736b9, before the review changes.

The tests will be repeated on the final commit - see comment #14223 (comment)

Test Result
Two-worker CPU-only, RAM-only and combined live increases (API) Guest and Kubernetes capacity/allocatable updated correctly
Control CPU increase (API) and RAM increase (UI) Automatic reconciliation; UI scale task successful
Injected kubelet failure and retry (API) Expected failure left the first node cordoned and second untouched; retry completed both; temporary fault cleaned
Operator cordon, cap-only and same-offering requests Cordon preserved; no unnecessary kubelet restart
Stop/start, stopped offering change, worker scale-out/in and live migration Passed; scale-in used worker count and the current worker offering
Invalid parameters and insufficient CPU capacity Correctly rejected without resource changes
Final UI Refresh, API, guest and Kubernetes checks Correct 6 CPU / 7168 MiB total; both Nodes Ready; no VM reboot; 17 Pod UIDs/restart counts unchanged; HTTP/DNS passed

VPC/direct-access and multi-control HA were not tested. Dedicated etcd VMs are resized the same way as on main; they are not Kubernetes nodes, so nothing is reconciled on them (not live-tested). The separate existing nodeids-only scale-in issue found during QA is tracked in #14458, with its fix in #14459.

UI evidence

Successful scale task and correct aggregate capacity:

Successful UI scale and correct CPU/RAM total

Scale request and result after Refresh

Control RAM: 2048 → 3072 MiB; worker unchanged at 3 CPU / 4096 MiB.

Control RAM-only scale request

After Refresh: 6 CPU / 7168 MiB.

Capacity after UI Refresh

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.16794% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.89%. Comparing base (af9764b) to head (c8e9058).
⚠️ Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
...utils/KubernetesClusterNodeCapacityReconciler.java 86.08% 14 Missing and 29 partials ⚠️
...er/actionworkers/KubernetesClusterScaleWorker.java 79.43% 8 Missing and 14 partials ⚠️
...nworkers/KubernetesClusterNodeOfferingResizer.java 94.57% 2 Missing and 7 partials ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 89.02% 4 Missing and 5 partials ⚠️
...cloud/kubernetes/cluster/utils/GuestResources.java 81.81% 3 Missing and 1 partial ⚠️
...kubernetes/cluster/utils/NodeCapacitySnapshot.java 95.45% 0 Missing and 2 partials ⚠️
...ubernetes/cluster/utils/KubernetesClusterUtil.java 88.88% 1 Missing ⚠️
...com/cloud/kubernetes/cluster/utils/NodeAccess.java 96.29% 0 Missing and 1 partial ⚠️
...ter/utils/NodeCapacityReconciliationException.java 80.00% 0 Missing and 1 partial ⚠️
.../cloud/kubernetes/cluster/utils/NodeResources.java 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14223      +/-   ##
============================================
+ Coverage     20.45%   20.89%   +0.44%     
- Complexity    21415    22175     +760     
============================================
  Files          6487     6503      +16     
  Lines        589303   592331    +3028     
  Branches      72245    72685     +440     
============================================
+ Hits         120525   123791    +3266     
+ Misses       455643   455097     -546     
- Partials      13135    13443     +308     
Flag Coverage Δ
uitests 3.88% <ø> (+0.17%) ⬆️
unittests 22.21% <88.16%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andrijapanicsb andrijapanicsb changed the title CKS: reconcile node capacity after live resize (WIP)CKS: reconcile node capacity after live resize Sep 22, 2026
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

ACSHomeBot commented Sep 22, 2026 •

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform
PASS RPM EL (EL8/9/10)
PASS DEB Ubuntu, Debian

Test packages are available at:

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 26.03%
Branch coverage 20.43%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

@andrijapanicsb
andrijapanicsb force-pushed the cks-live-resize-capacity-reconciliation branch from 40b50b0 to 7e5a95a Compare October 20, 2026 05:18
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

Copy link
Copy Markdown

Accepted: package kvm G for 2a404aa1ffcc.

Planned: RPM + DEB, KVM SystemVM.

Status: Queued for worker G. Jobs ahead: 0.

@ACSHomeBot

Copy link
Copy Markdown

Package building started on worker G.

@ACSHomeBot

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 31 min
PASS DEB Ubuntu, Debian 22 min

Test packages are available at:

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

Copy link
Copy Markdown

Accepted: package kvm G for f92e52d736b9.

Planned: RPM + DEB, KVM SystemVM.

Status: Queued for worker G. Jobs ahead: 0.

@ACSHomeBot

Copy link
Copy Markdown

Package building started on worker G.

@ACSHomeBot

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 30 min
PASS DEB Ubuntu, Debian 22 min

Test packages are available at:

@andrijapanicsb andrijapanicsb changed the title (WIP)CKS: reconcile node capacity after live resize CKS: reconcile node capacity after live resize Oct 21, 2026
@andrijapanicsb
andrijapanicsb marked this pull request as ready for review October 21, 2026 20:09
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19802

@ACSHomeBot

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 34 min
PASS DEB Ubuntu, Debian 23 min

Test packages are available at:

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17329)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 64763 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14223-t17329-kvm-ol8.zip
Smoke tests completed. 157 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Defer node preparation until a live CPU or memory change can be dispatched. On a retry of the committed offering, reconcile owned pending work without changing individual VM offerings or operator cordons.
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

ACSHomeBot commented Oct 31, 2026 •

Copy link
Copy Markdown

Accepted: package kvm G for a8a500f02238.

Planned: RPM + DEB, KVM SystemVM.

Status: Completed. Packaging results.

@ACSHomeBot

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 29 min
PASS DEB Ubuntu, Debian 21 min

Test packages are available at:

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

Functional and regression testing on the final commit a8a500f

Lab: 2 management servers + 2 KVM hosts (AlmaLinux 9.1, libvirt 8.5.0 / QEMU 7.0.0), Kubernetes 1.33.1, CloudManaged cluster 1 control + 2 workers (3 after scale-out), isolated network. Packages built from a8a500f, identical management jar on both servers, new classes present. Hosts have 3 cores, so offerings went up to 3 vCPU and RAM moved in 256–512 MiB steps.

Area Tests Result
Live increases: worker CPU-only, RAM-only, combined; control CPU-only (API) and RAM-only (UI); both node types in one call; cluster-wide offering; scale-out + offering change in one call 13 PASS
Jobs executed on either management server (node access and reconciliation from MGMT_B) – PASS
Same committed offering again, same-capacity offering change, stopped-cluster offering change – PASS: no node reads beyond one get node, no markers, no kubelet restart
Node preparation only after placement: control VM live-migrated for capacity, then node read, then the single preparation patch – PASS
Failure paths: control plane unreachable, node SSH unreachable, placement/capacity failure (no pending marker left), placement failure with earlier pending work (kept byte-identical), guest already above target, kubelet failure after resize (pending + CKS cordon kept, second worker untouched, retry finishes), scale timeout, operator cordon with failure, stale ownership marker, foreign marker, committed-offering retry with a mixed-offering node, VM stopped outside CKS, concurrent scale, parameter validation 15 PASS
Regression: scale-out, scale-in (size and nodeids), migrate after resize, stop/start, deleted offering in totals, plain (non-CKS) VM live/stopped scale, UI totals with mixed offerings 7 PASS
Autoscaling toggle 1 Pre-existing issue, same code on main → #14552

In every live resize: no VM reboot, no pod restart or UID change, DNS/HTTP service checks passed, the API server answered every readiness poll during control-node resizes, cluster metadata was committed only after all nodes succeeded.

Not tested: VPC tier / Netris and shared (direct-access) networks (node access changed in 306cc2e), multi-control HA, dedicated etcd, hypervisor rejection after dispatch (covered by unit tests), Kubernetes version upgrade after resizes.

Found during testing, pre-existing and independent of this PR:

The Trillian smoke run on a8a500f is still to be done.

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@andrijapanicsb a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✖️ suse15. SL-JID 19872

@DaanHoogland

DaanHoogland commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

suse build failed:

02:52:41 [ERROR] Failures: 
02:52:41 [ERROR]   MetalinkDirectTemplateDownloaderTest.testCheckUrlMetalink:33

looks like a generic test so rebuilding in the background

@DaanHoogland

Copy link
Copy Markdown
Contributor

suse build failed:

02:52:41 [ERROR] Failures: 
02:52:41 [ERROR]   MetalinkDirectTemplateDownloaderTest.testCheckUrlMetalink:33

looks like a generic test so rebuilding in the background

false positive, i.e. rebuild passed

@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package

@ACSHomeBot

ACSHomeBot commented Nov 7, 2026 •

Copy link
Copy Markdown

Accepted: package kvm for c8e9058956aa.

Planned: RPM + DEB, KVM SystemVM.

Status: Completed. Packaging results.

@ACSHomeBot

Copy link
Copy Markdown

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 29 min
PASS DEB Ubuntu, Debian 21 min

Test packages are available at:

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

Retested the published packages from c8e9058956: 35 of 36 functional and regression tests passed. The only exception was the known issue #14552: autoscaling without an explicit offering still falls back to the old cluster-wide offering.

Both workers brought the delayed CPU online automatically. The UI retry preserved the operator cordon, and the final CPU and RAM totals matched the API and Kubernetes checks.

The attached PDF contains the full test matrix and screenshots.

cloudstack-pr-14223-functional-testing-c8e9058956-20261107.pdf

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@andrijapanicsb a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19931

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CKS: Kubernetes nodes report stale CPU/RAM capacity after live resize

5 participants