Skip to content

CKS: apply the provider and CSI driver of the new version on upgrade - #14923

Open
bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-upgrade-addons
Open

bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-upgrade-addons

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Contributor

Description

Upgrading a CKS cluster left it on the CloudStack Kubernetes provider and CSI driver it was created with, whatever the binaries ISO of the new version holds. upgrade-kubernetes.sh copies the provider manifest of the ISO to the nodes and the worker calls deployProvider(), but deploy-provider exits as soon as a cloud-controller-manager pod exists. The CSI driver manifests of the ISO were not copied at all. The CNI and dashboard manifests are already applied by the upgrade script, so only these two were left behind.

This PR:

  • Copies the CSI driver manifests of the ISO to /opt/csi in upgrade-kubernetes.sh, as the control node setup does at create, with the same fix for the document separator of the v3.0.0 manifest.
  • Once every node is upgraded and the ISO detached, and before the version of the cluster is recorded, runs kubectl apply on the control node for:
    • the provider, except on a shared network (as deployProvider()), then waits for the cloud-controller-manager rollout;
    • the CSI driver, when the cluster has it, then waits for the controller and node rollouts. The snapshot CRDs are shared with other snapshot users, so they are only created when missing.
  • Tries each cloud.kubernetes.cluster.upgrade.retries + 1 times within the upgrade timeout. If it still fails, the upgrade fails and the version is not recorded, so upgrading to the same version again applies them again.

The commands run from the management server rather than from the node scripts, as clusters created by older releases keep old copies of those scripts.

They are applied after all the nodes, so every node already has the images of the new ISO when the new pods are scheduled. Applying an unchanged manifest changes nothing, so a cluster whose new ISO has the same add-ons sees no restart. Fields that CKS does not set in these manifests are kept, as kubectl apply is client side.

No schema change, no new API parameter or setting.

Fixes #14922

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?

Unit tests in KubernetesClusterUpgradeWorkerTest: both add-ons applied; the provider skipped on a shared network and the CSI driver when the cluster does not have it; retries then the error; an exception without a message reported as a failure; no retry once the upgrade timeout has passed; success after a failed try.

A lab report on a KVM zone follows in a comment.

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

  • A cluster created without the CSI driver: nothing applied for it.
  • An ISO without CSI driver manifests: the CSI step is skipped with a message.
  • Snapshot CRDs already present: left untouched.

upgradeKubernetesCluster copies the provider manifest of the new binaries
ISO to the nodes, and calls deployProvider() before each node, but
deploy-provider exits as soon as a cloud-controller-manager pod exists.
The CSI driver manifests of the ISO are not copied at all. So an upgraded
cluster keeps the provider and CSI driver it was created with, whatever
the ISO of the new version holds. The CNI and dashboard manifests are
already applied by the upgrade script.

- upgrade-kubernetes.sh copies the CSI driver manifests of the ISO to
  /opt/csi, as the control node setup does at create, with the same fix
  for the document separator of the v3.0.0 manifest.
- Once every node is upgraded, and before the version of the cluster is
  recorded, kubectl apply the provider (but on a shared network) and the
  CSI driver (when the cluster has it) on the control node, and wait for
  their rollout. The snapshot CRDs are shared, so only created when
  missing. Each is tried cloud.kubernetes.cluster.upgrade.retries + 1
  times, within the upgrade timeout. If it still fails, the upgrade
  fails, so that upgrading to the same version again applies them
  again.

Applying an unchanged manifest changes nothing, so a cluster whose ISO
has the same add-ons sees no restart.

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

Copy link
Copy Markdown
Contributor Author

Lab test on KVM (Ubuntu 24.04), with this change applied to a 4.22.1 based build. A cluster with 1 control node, 2 workers and the CSI driver, on an isolated network, upgraded from a 1.33.1 binaries ISO to a 1.34.7 ISO. The provider manifest of the 1.34.7 ISO runs the cloud-controller-manager on the host network with a required control-plane node affinity. The 1.33.1 one does neither. Both ISOs have the same CSI driver manifest.

Without this change (baseline): the upgrade succeeds and copies the new provider.yaml to the nodes, but the cloud-controller-manager Deployment stays at generation 1: no host network, no affinity, the old image, and the pod is on a worker.

With this change:

Check Result
Cluster Running at the new version, lasterror empty, 3 nodes Ready and schedulable, no ISO attached PASS
cloud-controller-manager Deployment changed by the upgrade (generation 1 -> 2) PASS
It runs on the host network, requires a control-plane node, and its pod runs on the control node PASS
Management server log has the apply of the provider and of the CSI driver PASS
CSI controller and node pods all Running PASS
CSI driver unchanged between the ISOs: applying it again changed nothing (DaemonSet generation 1 -> 1) PASS
After the upgrade, a LoadBalancer Service gets an IP and a CloudStack load balancer rule, HTTP through it reaches the backend pods, and the rule is removed when the Service is deleted PASS

The upgrade took 495 s, against 437 s without this change. The difference is mostly the rollout of the new cloud-controller-manager.

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.54545% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.34%. Comparing base (069ac79) to head (bd86a4f).

Files with missing lines Patch % Lines
.../actionworkers/KubernetesClusterUpgradeWorker.java 79.54% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14923   +/-   ##
=========================================
  Coverage     18.34%   18.34%           
- Complexity    16670    16684   +14     
=========================================
  Files          5939     5939           
  Lines        537814   537858   +44     
  Branches      65937    65944    +7     
=========================================
+ Hits          98637    98686   +49     
+ Misses       427953   427944    -9     
- Partials      11224    11228    +4     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.44% <79.54%> (+<0.01%) ⬆️

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.

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.

1 participant