Skip to content

CKS: a cluster created before 4.21 can't be scaled up after the upgrade (NullPointerException, template is null) #14628

Open

Description

@bhouse-nexthop

problem

A CKS cluster created before 4.21 can't be scaled up after CloudStack is upgraded to 4.21 or later. scaleKubernetesCluster with a larger size fails within seconds, with no VM created:

Unexpected exception while executing org.apache.cloudstack.api.command.user.kubernetes.cluster.ScaleKubernetesClusterCmd
java.lang.NullPointerException: Cannot invoke "com.cloud.template.VirtualMachineTemplate.getUniqueName()" because "template" is null
  at com.cloud.vm.VirtualMachineManagerImpl.isBlankInstanceDefaultTemplate(VirtualMachineManagerImpl.java)
  at com.cloud.vm.VirtualMachineManagerImpl.isBlankInstance(VirtualMachineManagerImpl.java)
  at com.cloud.vm.UserVmManagerImpl.createAdvancedVirtualMachine(UserVmManagerImpl.java)
  at com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterResourceModifierActionWorker.createKubernetesNode(KubernetesClusterResourceModifierActionWorker.java)
  at com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterResourceModifierActionWorker.provisionKubernetesClusterNodeVms(KubernetesClusterResourceModifierActionWorker.java)
  at com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterScaleWorker.scaleUpKubernetesClusterSize(KubernetesClusterScaleWorker.java)

The cluster goes back to Running.

Cause:

  • CKS Enhancements #9102 (4.21) added control_node_template_id, worker_node_template_id and etcd_node_template_id to kubernetes_cluster. The upgrade adds the columns but doesn't fill them in, so they are NULL for every cluster created before 4.21.
  • KubernetesClusterActionWorker.init() looks the node templates up from those columns only (templateDao.findById(kubernetesCluster.getWorkerNodeTemplateId())), which gives null.
  • createKubernetesNode passes that null template to createAdvancedVirtualMachine.
  • Before 4.21, nodes were deployed from the template CKS picks by default (clusterTemplate), and the owner was given launch permission for it during the operation. isDefaultTemplateUsed(), which decides about that launch permission, also returns false for these clusters, since none of the three columns equals template_id.

versions

4.21.0.0 and later, including 4.22 and main, for clusters created on 4.20 or earlier.

The steps to reproduce the bug

  1. On 4.20, create a CKS cluster and let it start.
  2. Upgrade CloudStack to 4.22.
  3. Scale the cluster up by one worker (scaleKubernetesCluster id=<cluster> size=<current + 1>).
  4. The job fails with the NullPointerException above. The cluster's control_node_template_id, worker_node_template_id and etcd_node_template_id are NULL.

Setting control_node_template_id and worker_node_template_id to the cluster's template_id in the database works around it.

What to do about it?

When a node type has no template set, deploy its nodes from the default CKS template, as before 4.21, and count the cluster as using the default template so the owner gets launch permission for it. Filling the columns in during the upgrade would be a schema change; the code fallback also covers clusters that were already upgraded.

Activity

  1. github-actions commented on Nov 10, 2026

    @github-actions

    Warning

    threat detection engine error
    The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

    What happened

    The threat detection engine failed to produce results.

    Review the workflow run logs for details.

    🎯 Triage report

    A CKS cluster created before 4.21 cannot be scaled up after upgrading to 4.21 or later. The per-node-type template columns added in 4.21 are NULL for these clusters, so node VM creation receives a null template and throws an NPE. The reporter has a DB workaround (set the control and worker template IDs to the cluster's template_id) and proposes falling back to the default CKS template in code.

    📊 Assessment

    Dimension Value Reasoning
    Type type:bug NPE on scale-up for clusters created before 4.21
    Component component:cks CKS node provisioning
    Severity Severity:Major Scale-up of upgraded clusters fails; a DB workaround exists
    Labels type:bug, component:cks, Severity:Major
    Coding agent Suitable Cause and fix direction are specific: fall back to the default template and treat it as default for launch permission

    🔗 Similar issues

    💡 Notes and suggestions
    • Reproduction: create a CKS cluster on 4.20, upgrade to 4.21 or later, then scale up by one worker.
    • Check isDefaultTemplateUsed() as well, since the report says the launch-permission logic is affected too.

    Generated by Daily Issue Triage · copilot · haiku55 · ~5 AIC · ⊞ 3.8K · ◷

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/daily-issue-triage.md@139fa09ef17cde4135e696ff8e7af09bc5ddfa6e
    
  2. added this to the 4.22.3 milestone on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions