Skip to content

cluster-autoscaler cannot count migrated PVs (CSI enabled) and cannot scale up on exceed max volume count #4517

@ialidzhikov

Description

@ialidzhikov

Which component are you using?:

cluster-autoscaler

What version of the component are you using?:

Component version: v1.18.0

What k8s version are you using (kubectl version)?:

1.17 and 1.18

What environment is this in?:

Gardener

What did you expect to happen?:

cluster-autoscaler to properly count migrated PVs and to scale up appropriately on scheduling failures with reason exceed max volume count.

What happened instead?:

cluster-autoscaler cannot count migrated PVs when CSI enabled -> cannot scale up on exceed max volume count. Pod(s) hangs forever in Pending state.

How to reproduce it (as minimally and precisely as possible):

  1. Create a single node cluster with K8s that does not have CSI enabled (for example AWS cluster with K8s 1.17)
    For machine type select a one that allows 25 volume attachments - for example m5.large

    Make sure that you have a single Node. Its allocatable volume attachments should be 25.

    $ k get csinode
    
    spec:
      drivers:
      - allocatable:
          count: 25
        name: ebs.csi.aws.com
    
  2. Create dummy StatefulSet and scale to 20 replicas

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      ports:
      - port: 80
        name: web
      clusterIP: None
      selector:
        app: nginx
    ---
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: web
    spec:
      selector:
        matchLabels:
          app: nginx # has to match .spec.template.metadata.labels
      serviceName: "nginx"
      replicas: 3 # by default is 1
      template:
        metadata:
          labels:
            app: nginx # has to match .spec.selector.matchLabels
        spec:
          terminationGracePeriodSeconds: 10
          containers:
          - name: nginx
            image: k8s.gcr.io/nginx-slim:0.8
            ports:
            - containerPort: 80
              name: web
            volumeMounts:
            - name: www
              mountPath: /usr/share/nginx/html
      volumeClaimTemplates:
      - metadata:
          name: www
        spec:
          accessModes: [ "ReadWriteOnce" ]
          resources:
            requests:
              storage: 1Gi
    $ k scale sts web --replicas=20
    

    This will create 20 Pods and PVs (note that PV are created with the internal volume driver).

  3. Update to K8s version with CSI enabled (for example AWS cluster with K8s 1.18)

    After completing this spec you should have 20 "migrated" PVs (PVs that are provisioned with the in-tree volume plugin).

  4. Scale the StatefulSet to 26 replicas

    $ k scale sts web --replicas=26
    
  5. Make sure that the 26th replica (Pod web-25) fails to be scheduled (as expected) but cluster-autoscaler never triggers a scale up

    Events:
    Type     Reason            Age   From               Message
    ----     ------            ----  ----               -------
    Warning  FailedScheduling  54m   default-scheduler  0/1 nodes are available: 1 node(s) exceed max volume count.
    Warning  FailedScheduling  54m   default-scheduler  0/1 nodes are available: 1 node(s) exceed max volume count.
    

    Logs of cluster-autoscaler:

    I1124 14:44:02.817569       1 csi.go:178] Persistent volume had no name for claim default/www-web-25
    I1124 14:44:02.817584       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817592       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817599       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817606       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817612       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817615       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817629       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817634       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817641       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817644       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817649       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817652       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817659       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817662       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817668       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817671       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817678       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817685       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817691       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817694       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817700       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817705       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817713       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817721       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817729       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817732       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817738       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817741       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817751       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817759       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817766       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817769       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817774       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817778       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817787       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817791       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817797       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817800       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817806       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
    I1124 14:44:02.817809       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume
    I1124 14:44:02.817818       1 scheduler_binder.go:241] FindPodVolumes for pod "default/web-25", node "ip-10-250-28-64.eu-west-1.compute.internal"
    I1124 14:44:02.817842       1 scheduler_binder.go:819] No matching volumes for Pod "default/web-25", PVC "default/www-web-25" on node "ip-10-250-28-64.eu-west-1.compute.internal"
    I1124 14:44:02.817852       1 scheduler_binder.go:883] Provisioning for 1 claims of pod "default/web-25" that has no matching volumes on node "ip-10-250-28-64.eu-west-1.compute.internal" ...
    I1124 14:44:02.817868       1 filter_out_schedulable.go:118] Pod default.web-25 marked as unschedulable can be scheduled on node ip-10-250-28-64.eu-west-1.compute.internal (based on hinting). Ignoring in scale up.
    I1124 14:44:02.817878       1 filter_out_schedulable.go:132] Filtered out 1 pods using hints
    I1124 14:44:02.817884       1 filter_out_schedulable.go:170] 0 pods were kept as unschedulable based on caching
    I1124 14:44:02.817888       1 filter_out_schedulable.go:171] 1 pods marked as unschedulable can be scheduled.
    I1124 14:44:02.817894       1 filter_out_schedulable.go:79] Schedulable pods present
    I1124 14:44:02.817913       1 static_autoscaler.go:402] No unschedulable pods
    I1124 14:44:02.817929       1 static_autoscaler.go:449] Calculating unneeded nodes
    

Anything else we need to know?:

From what I managed to track in the autoscaler repository, the autoscaler creates a new scheduler framework and "simulates" whether the Pod is really unschedulable (most probably using default scheduling config).

I1124 14:44:02.817868       1 filter_out_schedulable.go:118] Pod default.web-25 marked as unschedulable can be scheduled on node ip-10-250-28-64.eu-west-1.compute.internal (based on hinting). Ignoring in scale up.

The above log entry makes it clear that the Pod is unschedulable according to the kube-scheduler (exceed max volume count) but the same Pod is schedulable according to the cluster-autoscaler. The differences comes from the NodeVolumeLimits filter in the scheduler - kube-scheduler obviously has the required CSI migration feature gates set and can correctly count migrated volumes. cluster-autoscaler current does not have any such config, hence it cannot count volumes with CSI enabled:

I1124 14:44:02.817806       1 csi.go:205] CSI Migration of plugin kubernetes.io/aws-ebs is not enabled
I1124 14:44:02.817809       1 csi.go:158] Could not find a CSI driver name or volume handle, not counting volume

(Note that kube-scheduler has the required CSI migration flags and CSI migration is enabled for AWS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions