Skip to content

CKS: don't fail when a node still has an ISO attached - #14637

Open
bhouse-nexthop wants to merge 3 commits into
apache:mainfrom
bhouse-nexthop:cks-iso-already-attached
Open

bhouse-nexthop wants to merge 3 commits into
apache:mainfrom
bhouse-nexthop:cks-iso-already-attached

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator

Description

Since #13101 (multiple CD-ROMs per VM), attachIso on main refuses an ISO that is already attached, and any ISO beyond the number of CD-ROMs, one by default. KubernetesClusterActionWorker.attachIsoKubernetesVMs relied on the attach replacing whatever ISO a node had. So a node left holding the binaries ISO by an operation that didn't finish, for example because the management server stopped, made every later upgrade, scale-up or start fail before it started, with "The specified ISO is already attached to this Instance."

Fixes #14630

For each node, attachIsoKubernetesVMs now reads the VM again and:

  • leaves the binaries ISO in place if it is already attached, in the primary CD-ROM or in another one;
  • otherwise detaches the ISO in the primary CD-ROM, if any, before attaching the binaries ISO, as the attach used to replace it.

4.22 is not affected, so this is for main only.

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

New unit tests in KubernetesClusterActionWorkerIsoTest:

  • a node with no ISO gets the binaries ISO attached, and nothing is detached;
  • a node that already has the binaries ISO, in the primary CD-ROM or in another one, is left as it is;
  • a node with another ISO has it detached, then the binaries ISO attached.

Without the fix, the last three fail. mvn -pl plugins/integrations/kubernetes-service -am test -Dtest='KubernetesClusterActionWorker*Test' passes.

On a test environment running main, an upgrade failed as described in #14630 while both nodes still held the binaries ISO, and ran once the ISO was detached from both by hand. This PR itself has not been run against a live cluster.

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

  • A node with no ISO takes the same path as before.
  • If the detach fails, the operation fails as an attach failure did before.
  • If the attach fails after the detach, the node is left with no ISO, and the operation fails as before.
  • detachIsoKubernetesVMs is unchanged.

attachIsoKubernetesVMs attaches the binaries ISO to every node before
an upgrade, a scale-up or a start, and relied on the attach replacing
whatever ISO the node had. Since an Instance can have several CD-ROMs,
attachIso refuses an ISO that is already attached, and any ISO beyond
the number of CD-ROMs, one by default. A node left holding the binaries
ISO by an operation that did not finish, for example because the
management server stopped, then made every later operation fail before
it started.

Leave the binaries ISO in place if the node has it already, and detach
any other ISO from the node first, as the attach used to replace it.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.93%. Comparing base (a95eb59) to head (10053ed).
⚠️ Report is 44 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14637      +/-   ##
============================================
+ Coverage     20.78%   20.93%   +0.15%     
+ Complexity    21927    21155     -772     
============================================
  Files          6496     6057     -439     
  Lines        591657   549571   -42086     
  Branches      72592    73482     +890     
============================================
- Hits         122955   115034    -7921     
+ Misses       455356   421081   -34275     
- Partials      13346    13456     +110     
Flag Coverage Δ
uitests 3.86% <ø> (-0.02%) ⬇️
unittests 22.37% <100.00%> (+0.28%) ⬆️

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.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Test report: CKS upgrade with the binaries ISO already attached to a node

Summary: with the upgrade's binaries ISO already attached to the control node, as an operation that didn't finish would leave it, upgradeKubernetesCluster no longer fails at the attach step. It leaves the ISO in place on that node, attaches it to the other node, upgrades both, and detaches it from both at the end.

Environment

Method

  1. attachIso of the v1.33.13 binaries ISO to the control node. listVirtualMachines then showed that ISO on the control node and no ISO anywhere else.
  2. upgradeKubernetesCluster to v1.33.13.
  3. Check the log, the cluster, the nodes and which VMs hold an ISO.

Results

  • The upgrade succeeded in 334 s: Running -> Upgrading -> Running.
  • The attach step, trimmed:
    20:30:56,899 INFO  KubernetesClusterUpgradeWorker  Upgrading Kubernetes cluster: cluster B
    20:30:56,984 INFO  KubernetesClusterUpgradeWorker  Binaries ISO is already attached to VM: ... control-1 ...
    20:30:57,260 INFO  KubernetesClusterUpgradeWorker  Attached binaries ISO for VM: ... worker-1 ...
    20:30:57,261 INFO  KubernetesClusterUpgradeWorker  Upgrading node control-1 ...
    20:35:14,855 INFO  KubernetesClusterUpgradeWorker  Successfully upgraded node on VM ... control-1 ...
    20:36:26,576 INFO  KubernetesClusterUpgradeWorker  Successfully upgraded node on VM ... worker-1 ...
    20:36:28,844 INFO  KubernetesClusterUpgradeWorker  Detached Kubernetes binaries from VM: ... control-1 ...
    20:36:29,755 INFO  KubernetesClusterUpgradeWorker  Detached Kubernetes binaries from VM: ... worker-1 ...
    
  • The log has no The specified ISO is already attached to this Instance, which is the stock failure in CKS (main): an upgrade, scale or start fails if a node still has an ISO attached #14630.
  • kubectl get nodes afterwards: both nodes Ready, on v1.33.13. Every pod was Running or Completed.
  • No VM held an ISO afterwards.

Result: pass. A node already holding the binaries ISO no longer blocks the upgrade. The ISO is kept on that node for the upgrade, and detached from every node at the end, as for a node that had none.

Not covered

  • A node holding a different ISO, which the PR detaches before attaching the binaries ISO. That path is covered by the unit tests only.
  • The same case in a scale-up or a start. A scale-up attaches the ISO only to the new nodes, so a leftover ISO on an existing node doesn't reach this code there.
  • A leftover ISO in a second CD-ROM: the lab VMs have one CD-ROM.

attachIsoKubernetesVMs fetched each node from UserVmDao just to read its
primary ISO, even though the UserVm objects it iterates already expose
getIsoId() and are loaded from UserVmDao (or freshly provisioned). Read
the ISO directly from the object, removing a redundant query and the
now unnecessary null guard.
attachIsoKubernetesVMs only detached the primary ISO. With more than
one CD-ROM a node could keep a non-binaries ISO in an extra slot, or
keep both the binaries ISO in an extra slot and another ISO in the
primary slot. The later detachIsoKubernetesVMs calls detachIso with a
null ISO, which fails when more than one ISO is attached, leaving the
binaries ISO mounted.

Look at every ISO attached to the node, detach all except the binaries
ISO, and attach the binaries ISO only when it is not already present on
any CD-ROM.

@winterhazel winterhazel 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.

@bhouse-nexthop the code and the testing looks good. I have pushed 2 commits to address a bug and a small refactoring, could you review them? You're free to revert them if you think they're not required.

@winterhazel

Copy link
Copy Markdown
Member

@blueorangutan package

@winterhazel

Copy link
Copy Markdown
Member

Trying again...

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Thanks @winterhazel, both look good to me, I'm keeping them.

  • Reuse the ISO from the VM object: every caller passes VMs that were just loaded from UserVmDao or just provisioned, and nothing changes their ISO between that and the attach, so the extra lookup wasn't needed.
  • Detach the non-binaries ISOs from every CD-ROM: good catch. With the binaries ISO in an extra slot and another ISO in the primary slot, the later detachIso(vmId, null) would hit "more than one ISO attached" and leave the binaries mounted. Detaching everything else first leaves exactly one ISO, so that call resolves it.

The KubernetesCluster*Test tests pass on the new head, including the two new cases.

@blueorangutan

Copy link
Copy Markdown

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

@winterhazel

Copy link
Copy Markdown
Member

@RosiKyu @nvazquez can we run the smoke tests here?

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Tested again at the current head, which adds the two commits pushed during review (detaching any non-binaries ISO before attaching the binaries ISO, and reusing the node ISO). Same kind of lab as my earlier report: a KVM lab running a main (24.0) build that includes this change, Ceph RBD primary storage, a CKS cluster on Kubernetes 1.34.7 with 1 control and 2 worker nodes.

During a scale-up the binaries ISO is only attached to the new VMs, so the case "a node holds some other ISO" was set up through addNodesToKubernetesCluster with mountcksisoonvr=false, which attaches the binaries ISO to the VMs being added:

  1. Deployed a VM from a template marked for CKS on the cluster's network.
  2. Attached a different ISO to it (the 1.33.1 binaries ISO; the cluster runs 1.34.7).
  3. Called addNodesToKubernetesCluster with that VM.

Result: 13 of 13 checks passed (gates included).

  • The management server log shows the other ISO detached first, then the cluster's binaries ISO attached:
    KubernetesClusterAddWorker  Detaching ISO 203 from VM: VM instance {"id":230,...} in cluster: ... to attach the binaries ISO
    KubernetesClusterAddWorker  Attached binaries ISO for VM: VM instance {"id":230,...} in cluster: ...
    
  • There was no Failed to attach binaries ISO and no already attached error, and the other ISO was no longer on the VM afterwards.

The add itself then failed later, at node validation: that template is a Cluster API image, not a CKS node image, so this says nothing about this PR. The cluster stayed Running and the VM was destroyed afterwards.

Not tested at this head: an upgrade with the binaries ISO already attached (my earlier report covers that path, with the first commit).

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 (main): an upgrade, scale or start fails if a node still has an ISO attached

4 participants