Repository navigation
CKS: retry the upgrade manifests while the API server restarts - #14912
bhouse-nexthop wants to merge 1 commit into
Conversation
upgrade-kubernetes.sh applied the CNI and dashboard manifests on the first control node right after restarting containerd and kubelet, while the upgraded API server was still restarting. kubectl failed with "unexpected EOF", then with "Forbidden" until the API server authorized requests again, so the first upgrade attempt of the control node failed and only a retry of the whole script got past it. With cloud.kubernetes.cluster.upgrade.retries=0 the upgrade stopped there. Apply each manifest again every 10 seconds while it fails. No retry starts more than 180 seconds after the first attempt, and each attempt is stopped after 90 seconds, so an apply that hangs on a restarting API server is retried too. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14912 +/- ##
=========================================
Coverage 18.34% 18.34%
+ Complexity 16671 16670 -1
=========================================
Files 5939 5939
Lines 537817 537817
Branches 65938 65938
=========================================
Hits 98640 98640
Misses 427954 427954
Partials 11223 11223
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tested on a KVM lab running a 4.22 build that includes this commit. Primary storage is Ceph RBD. The CKS cluster has 1 control and 2 worker nodes with Calico. It was upgraded from Kubernetes 1.33.1 to 1.34.7, using a binaries ISO made with the 4.22 Result: 15 of 15 checks passed.
The upgrade took 390 s. Without this change, earlier upgrades on the same lab failed the control node's first attempt with the The cluster was deleted afterwards and the setting was put back to 3. Not tested: clusters with more than one control node (only the first control node runs these applies), and an API server that never comes back (the stub test in the description covers that path). |
Description
The first control node's upgrade attempt always failed.
upgrade-kubernetes.shappliesnetwork.yamland the dashboard manifest right after it restarts containerd and kubelet, while the upgraded API server is still restarting.kubectl applyfailed withunexpected EOF, then withUser "kubernetes-admin" cannot get resource "customresourcedefinitions"until the API server authorized requests again. Only a rerun of the whole script got past it, so withcloud.kubernetes.cluster.upgrade.retries=0every upgrade stopped at the control node. Details in #14911.The script now applies these two manifests through
apply_manifest, which retries every 10 seconds whilekubectl applyfails:APPLY_RETRY_TIMEOUTAPPLY_ATTEMPT_TIMEOUTAPPLY_RETRY_SLEEPWhen the retries run out the script fails as before, and the management server's own retries still apply. If the API server never comes back, the script fails after about 3 to 4.5 minutes per manifest instead of at once.
It does not wait on
/readyzfirst: CKS accepts Kubernetes versions before 1.16, which don't have it, and the EOF can also happen in the middle of an apply.Only
upgrade-kubernetes.shchanges, and only the first control node runs these applies. On main the dashboard step is theheadlamp.yaml/dashboard.yamlchoice; both applies there should useapply_manifestwhen this is merged forward.Fixes: #14911
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
apply_manifestwith a stubkubectl, underbash -e:ERROR: Unable to apply ..., script exits 1, no attempt after the windowLab, KVM with Ceph RBD primary storage, CKS cluster of 1 control and 2 worker nodes upgraded from Kubernetes 1.33.1 to 1.34.7 with
cloud.kubernetes.cluster.upgrade.retries=0, on a main build with an earlier version of this change (120 s window, 60 s per attempt): the upgrade passed with no failed script attempt. Before the change the control node's first attempt failed in 4 of 4 upgrades. This commit on a 4.22 build, same setup with a 4.22-built ISO and retries 0: 15 of 15 checks passed, no failed script attempt (report in the comments).How did you try to break this feature and the system with this change?
set -estill ends the script when the retries run out:kubectlruns in theuntilcondition, andapply_manifestreturns 1 from a plain call.kubectlerror followed byERROR: Unable to apply <file>.