Skip to content

CKS: fix scaling failures for clusters without a default service offering - #14138

Draft
Pearl1594 wants to merge 3 commits into
4.22from
fix-cks-scale-etcd
Draft

Pearl1594 wants to merge 3 commits into
4.22from
fix-cks-scale-etcd

Conversation

@Pearl1594

@Pearl1594 Pearl1594 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR #14122 #14148

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Deployed a CKS cluster with dedicated service offerings for the node types (v1.35.6) - this isnt reproducible via UI, because via UI passing the common service offering is mandatory (so the kubernetes_cluster.service_offering_id column is never null). Scaled the offering to a default/common one - successfully scaled. (for KVM the cluster needs to be stopped prior upgrade)

Also tried upgrading the cluster - form v1.35.6 to 1.36.2 - Successfully upgraded

How did you try to break this feature and the system with this change?

@Pearl1594
Pearl1594 changed the base branch from main to 4.22 September 10, 2026 19:57
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.28571% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.84%. Comparing base (a9b2f33) to head (1549543).
⚠️ Report is 85 commits behind head on 4.22.

Files with missing lines Patch % Lines
...bernetes/cluster/KubernetesClusterManagerImpl.java 18.33% 43 Missing and 6 partials ⚠️
...er/actionworkers/KubernetesClusterScaleWorker.java 7.14% 13 Missing ⚠️
...KubernetesClusterResourceModifierActionWorker.java 0.00% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14138      +/-   ##
============================================
+ Coverage     17.86%   18.84%   +0.98%     
- Complexity    16037    17304    +1267     
============================================
  Files          5928     5939      +11     
  Lines        534479   562677   +28198     
  Branches      65410    76557   +11147     
============================================
+ Hits          95468   106043   +10575     
- Misses       428173   444788   +16615     
- Partials      10838    11846    +1008     
Flag Coverage Δ
uitests 4.20% <ø> (+0.18%) ⬆️
unittests 19.94% <14.28%> (+1.02%) ⬆️

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.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
19.4% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

@kiranchavala

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@kiranchavala a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware 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 19246

@weizhouapache weizhouapache changed the title CCKS: fix scaling failures for clusters without a default service offering CKS: fix scaling failures for clusters without a default service offering Sep 15, 2026

@kiranchavala kiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pearl1594

Still hitting the following issues

Issue 1

  1. Deploy a cks with etcd node with size 1

  2. scale the cks cluster size 2

``

(localcloud) 🐱 > scale kubernetescluster id=fc2459db-4e65-48d4-9c91-34c479346417 size=2

cks cluster scaled successfully 


3. Downscale the cks cluster back to size 1 > Exception> cks cluster goes into alert state > vm is expunged

(localcloud) 🐱 > scale kubernetescluster id=fc2459db-4e65-48d4-9c91-34c479346417 size=1
{
"account": "admin",
"accountid": "994826d5-d36a-11f1-bb47-1e003c000122",
"cmd": "org.apache.cloudstack.api.command.user.kubernetes.cluster.ScaleKubernetesClusterCmd",
"completed": "2026-10-30T05:59:16+0000",
"created": "2026-10-30T05:59:00+0000",
"domainid": "3d20f963-d36a-11f1-bb47-1e003c000122",
"domainpath": "ROOT",
"jobid": "ce7a745b-a5b6-4a35-ba18-2d45baf0109f",
"jobprocstatus": 0,
"jobresult": {
"errorcode": 530,
"errortext": "Scaling failed for Kubernetes cluster KubernetesCluster {"id":2,"name":"cks2","uuid":"fc2459db-4e65-48d4-9c91-34c479346417"}, unable to update network rules"
},
"jobresultcode": 530,
"jobresulttype": "object",
"jobstatus": 2,
"userid": "9948cdb5-d36a-11f1-bb47-1e003c000122"
}
🙈 Error: async API failed for job ce7a745b-a5b6-4a35-ba18-2d45baf0109f

2026-10-30 05:59:16,594 ERROR [c.c.k.c.a.KubernetesClusterScaleWorker] (API-Job-Executor-36:[ctx-4702e3ef, job-62, ctx-35c81aea]) (logid:ce7a745b) Scaling failed for Kubernetes cluster KubernetesCluster {"id":2,"name":"cks2","uuid":"fc2459db-4e65-48d4-9c91-34c479346417"}, unable to update network rules com.cloud.exception.ManagementServerException: Failed to provision firewall rules for SSH access for the Kubernetes cluster : cks2
at com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterActionWorker.addFirewallRulesForNodes(KubernetesClusterActionWorker.java:1037)
at com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterResourceModifierActionWorker.createFirewallRules(KubernetesClusterResourceModifierActionWorker.java:668)

    at java.base/java.lang.Thread.run(Thread.java:840)
  Caused by: com.cloud.exception.NetworkRuleConflictException: The range specified, 2222-2223, conflicts with rule FirewallRule {"id":17,"networkId":205,"purpose":"Firewall","state":"Active","uuid":"3198c529-f76d-45aa-9d83-e74f90dffd06"} which has 2222-2224
            at com.cloud.network.firewall.FirewallManagerImpl.detectRulesConflict(FirewallManagerImpl.java:486)
            at com.cloud.network.firewall.FirewallManagerImpl.lambda$createFirewallRule$0(FirewallManagerImpl.java:265)
            at com.cloud.utils.db.Transaction.execute(Transaction.java:38)
            at com.cloud.network.firewall.FirewallManagerImpl.createFirewallRule(FirewallManagerImpl.java:255)
            at com.cloud.network.firewall.FirewallManagerImpl.createIngressFirewallRule(FirewallManagerImpl.java:207)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:569)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
            at org.apache.cloudstack.network.contrail.management.EventUtils$EventInterceptor.invoke(EventUtils.java:109)

2026-10-30 05:59:16,599 INFO [c.c.k.c.a.KubernetesClusterScaleWorker] (API-Job-Executor-36:[ctx-4702e3ef, job-62, ctx-35c81aea]) (logid:ce7a745b) Revoking launch permission for systemVM Template
2026-10-30 05:59:16,609 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-36:[ctx-4702e3ef, job-62]) (logid:ce7a745b) Complete async job-62, jobStatus: FAILED, resultCode: 530, result: org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":"530","errortext":"Scaling failed for Kubernetes cluster KubernetesCluster {"id":2,"name":"cks2","uuid":"fc2459db-4e65-48d4-9c91-34c479346417"}, unable to update network rules"}


Issue 2 

Scale to  common offering

create kubernetescluster name=cks-npe zoneid= kubernetesversionid= networkid=
controlnodes=1 size=1 hypervisor=KVM
nodeofferings[0].node=control nodeofferings[0].offering=
nodeofferings[1].node=worker nodeofferings[1].offering=

mysql> select control_node_service_offering_id,worker_node_service_offering_id,etcd_node_service_offering_id from kubernetes_cluster where id=3;
+----------------------------------+---------------------------------+-------------------------------+
| control_node_service_offering_id | worker_node_service_offering_id | etcd_node_service_offering_id |
+----------------------------------+---------------------------------+-------------------------------+
| 13 | 13 | NULL |
+----------------------------------+---------------------------------+-------------------------------+
1 row in set (0.00 sec)


Stop the cks cluster 



scale kubernetescluster id=<> serviceofferingid=<>

mysql> select control_node_service_offering_id,worker_node_service_offering_id,etcd_node_service_offering_id from kubernetes_cluster where id=3;
+----------------------------------+---------------------------------+-------------------------------+
| control_node_service_offering_id | worker_node_service_offering_id | etcd_node_service_offering_id |
+----------------------------------+---------------------------------+-------------------------------+
| 14 | 14 | 14 |
+----------------------------------+---------------------------------+-------------------------------+
1 row in set (0.00 sec)

Cloudstack changed the  etcd node service offering 


Issue 3 

still hitting npe when try to scale a running/stopped cks cluster 

(localcloud) 🐱 > scale kubernetescluster id=985d339e-0744-4d91-82a8-de95fcfac3cc nodeofferings[0].key=worker nodeofferings=19948eb4-4ef3-42f0-87a6-ec621718f704
🙈 Error: (HTTP 530, error code 9999) Cannot invoke "java.util.Map.put(Object, Object)" because "mapValue" is null


2026-10-30 06:43:15,369 ERROR [c.c.a.ApiServer] (qtp253011924-16:[ctx-64f43a55, ctx-83720331, ctx-f4b35cf7]) (logid:38be252b) unhandled exception executing api command: [Ljava.lang.String;@2027d8b4 java.lang.NullPointerException: Cannot invoke "java.util.Map.put(Object, Object)" because "mapValue" is null
at com.cloud.api.dispatch.ParamUnpackWorker.handle(ParamUnpackWorker.java:104)
at com.cloud.api.dispatch.DispatchChain.dispatch(DispatchChain.java:37)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:814)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:697)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:409)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:194)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:191)
at com.cloud.api.ApiServlet.doPost(ApiServlet.java:150)


@kiranchavala
kiranchavala self-requested a review October 30, 2026 07:36
@kiranchavala

Copy link
Copy Markdown
Member

@Pearl1594 could please you look into the issue again

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@kiranchavala I've addressed issues 1 and 2, while issue 3 is a non issue, atleast not pertaining to CKS. The issue occured due to incorrect usage of nodeofferingids. Its a map and you passed a map as well as a UUID, and that's the reason for the failure. This would fail for any API parameter of map type.

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
15.2% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

@blueorangutan

Copy link
Copy Markdown

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

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 upgrade fails in the following scenario Scaling issues with cks cluster

3 participants