bhouse-nexthop opened a new pull request, #14912: URL: https://github.com/apache/cloudstack/pull/14912
### Description The first control node's upgrade attempt always failed. `upgrade-kubernetes.sh` applies `network.yaml` and the dashboard manifest right after it restarts containerd and kubelet, while the upgraded API server is still restarting. `kubectl apply` failed with `unexpected EOF`, then with `User "kubernetes-admin" cannot get resource "customresourcedefinitions"` until the API server authorized requests again. Only a rerun of the whole script got past it, so with `cloud.kubernetes.cluster.upgrade.retries=0` every upgrade stopped at the control node. Details in #14911. The script now applies these two manifests through `apply_manifest`, which retries every 10 seconds while `kubectl apply` fails: | Setting | Value | Why | |---|---|---| | `APPLY_RETRY_TIMEOUT` | 180 s per manifest | no retry starts after this | | `APPLY_ATTEMPT_TIMEOUT` | 90 s | an apply that hangs on a half-up API server is stopped and retried | | `APPLY_RETRY_SLEEP` | 10 s | | When 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 `/readyz` first: 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.sh` changes, and only the first control node runs these applies. On main the dashboard step is the `headlamp.yaml` / `dashboard.yaml` choice; both applies there should use `apply_manifest` when this is merged forward. Fixes: #14911 ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [x] 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 #### Feature/Enhancement Scale - [ ] Major - [ ] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [x] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? `apply_manifest` with a stub `kubectl`, under `bash -e`: | Stub | Result | |---|---| | fails twice, then works | applied on the 3rd attempt, script continues | | always fails (window shortened to 25 s) | 3 attempts, `ERROR: Unable to apply ...`, script exits 1, no attempt after the window | | first attempt hangs (attempt timeout shortened to 5 s) | attempt killed, applied on the next one | Lab, 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. A lab run of this exact commit on 4.22 will follow in a comment. #### How did you try to break this feature and the system with this change? - `set -e` still ends the script when the retries run out: `kubectl` runs in the `until` condition, and `apply_manifest` returns 1 from a plain call. - Re-applying after an interrupted apply is safe: objects the server already stored carry their last-applied annotation, so the next attempt patches them. - A manifest that can never apply (bad YAML, an immutable field) now fails after about 3 minutes instead of at once, with the same `kubectl` error followed by `ERROR: Unable to apply <file>`. - Output is printed at least every ~100 s, so the management server's SSH read does not time out while the script retries. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
