Repository navigation
CKS: find a project cluster by id for the cluster autoscaler - #14916
bhouse-nexthop wants to merge 1 commit into
Conversation
The cluster autoscaler looks its cluster up with listKubernetesClusters and the id only, using the key of the Kubernetes service account. For a cluster owned by a project that account is a project member, and a list by id without projectid only searches the caller's own account, so the autoscaler gets an empty list, logs "Unable to fetch cluster" and never scales. When a user account lists by id alone, a cluster of a project it may list (the usual entity access check, project roles included) is now found as if projectid were given. Other lists, admin callers and lists with projectid, account or domainid are unchanged. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14916 +/- ##
=========================================
Coverage 18.34% 18.34%
- Complexity 16671 16682 +11
=========================================
Files 5939 5939
Lines 537817 537835 +18
Branches 65938 65942 +4
=========================================
+ Hits 98640 98678 +38
+ Misses 427954 427932 -22
- Partials 11223 11225 +2
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 (nested, Ceph RBD primary storage), with the cluster autoscaler that the v1.33.1 CKS ISO deploys ( On 4.22 (4.22.1.1 plus this change):
On main the same steps pass, same results: the bug reproduced on one project cluster, then with the change the same cluster scaled up and back down. A cluster owned by an account (not a project) also scaled up and down with the change, and its id-only lookup still works. Not tested: project roles that deny |
Description
The cluster autoscaler never scales a CKS cluster owned by a project (#14915). Its CloudStack provider looks the
cluster up with
listKubernetesClusters id=<id>and noprojectid, using the key of the project's Kubernetesservice account. For a user account, a list without
projectidonly searches the caller's own account, so theautoscaler gets an empty list and logs "Unable to fetch cluster with id".
When a user account lists by
idalone,listKubernetesClustersnow also finds a cluster of a project it may list,as if
projectidhad been given. Whether it may list the cluster is decided by the usual entity access check(
checkAccesswithListEntry), so project membership and project roles apply as they do withprojectid.Unchanged: lists without an id; lists with
projectid,accountordomainid; admin and domain admin callers(they already find a cluster by id).
The provider could also send the
project-idit reads from the cloud-config. This change makes the autoscalerimages that are already deployed work without a new image.
Fixes: #14915
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests in
KubernetesClusterManagerImplTest: the project is resolved for a cluster the caller may list, notwhen the access check denies it, not for an account-owned or unknown cluster; the search is unchanged with
projectid,accountordomainid, without an id, and for admin and domain admin callers.mvn -pl plugins/integrations/kubernetes-service -am test: all tests pass.A lab test on a KVM zone follows in a comment.