Skip to content

CKS treats a lower-id added node as the control node #14830

Backlog

Description

@bhouse-nexthop

problem

CKS picks "the control node" in KubernetesClusterActionWorker.fetchControlVmIfMissing by sorting every VM id in kubernetes_cluster_vm_map and taking the one at index etcdNodeCount. It never looks at the control_node flag.

If the cluster holds a VM whose id is lower than the control VM's, that VM is taken as the control node. The easy way to hit it: addNodesToKubernetesCluster with a VM that existed before the cluster was created.

caller what goes wrong
KubernetesClusterAddWorker (getControlVmPrivateIp) every later added node gets join config pointing at the worker's IP:6443; its deploy-kube-system loops on "Couldn't connect to server"
getKubernetesClusterServerIpSshPortForSharedNetwork shared/routed clusters SSH to the worker instead of the control node (scale, upgrade, add, remove)
KubernetesClusterStartWorker.isKubernetesClusterKubeConfigAvailable kubeconfig server rewrite looks for the wrong IP and is skipped

Seen on a lab cluster: VMs 4 and 5 added with addNodesToKubernetesCluster (external, worker), control VM is 7. VM 4 was chosen; adding VM 5 afterwards produced a join config pointing at VM 4.

versions

4.22 (also main). Code unchanged since etcd node support.

The steps to reproduce the bug

  1. Create a VM A (CKS template) in the cluster's network.
  2. Create a CKS cluster (VM ids of its nodes are now higher than A's).
  3. addNodesToKubernetesCluster with A; it joins fine (control IP still resolved correctly until A is mapped).
  4. addNodesToKubernetesCluster with another existing VM B.
  5. B's CKS config points at A's IP for the API server and never joins.

What to do about it?

Pick the control VM from rows with control_node set (not etcd, not external), lowest VM id first. Keep a fallback for clusters created before the control_node column existed (all rows 0).

Activity

  1. github-actions commented on Dec 1, 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

    CKS chooses the "control node" in KubernetesClusterActionWorker.fetchControlVmIfMissing by sorting all VM IDs in kubernetes_cluster_vm_map and taking the one at index etcdNodeCount. It does not check the control_node flag. If an externally added VM has a lower ID than the real control VM, that VM is taken as the control node, and later added nodes receive join configuration that points at the wrong API server and never join.

    📊 Assessment

    Dimension Value Reasoning
    Type type:bug Wrong control node is selected, with reproduction steps
    Component component:cks KubernetesClusterActionWorker.fetchControlVmIfMissing and join configuration
    Severity Severity:Major Later nodes cannot join; shared and routed clusters SSH to the wrong VM
    Labels type:bug, component:cks, Severity:Major Based on the issue text
    Coding agent Suitable Fix is specified: choose the control VM by the control_node flag, lowest ID first, with a fallback for older rows

    🔗 Similar issues

    💡 Notes and suggestions
    • Reproduction: create VM A in the cluster's network before creating a CKS cluster, create the cluster, add A, then add another existing VM B and check its join configuration.
    • The fallback for clusters created before the control_node column existed needs a test.

    Generated by Daily Issue Triage · copilot · haiku55 · ~9 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
    
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions