<p>I have the problem that I cannot mount volumes to pods in Kubernetes using the Azure File CSI in Azure cloud.</p>
<p>The error message I am receiving in the pod is</p>
<pre><code>  Warning  FailedMount  38s    kubelet            Unable to attach or mount volumes: unmounted volumes=[sensu-backend-etcd], unattached volumes=[default-token-42kfh sensu-backend-etcd sensu-asset-server-ca-cert]: timed out waiting for the condition
</code></pre>
<p>My storageclass looks like the following:</p>
<pre><code>items:
- allowVolumeExpansion: true
  apiVersion: storage.k8s.io/v1
  kind: StorageClass
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {&quot;allowVolumeExpansion&quot;:true,&quot;apiVersion&quot;:&quot;storage.k8s.io/v1&quot;,&quot;kind&quot;:&quot;StorageClass&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{&quot;storageclass.kubernetes.io/is-default-class&quot;:&quot;true&quot;},&quot;name&quot;:&quot;azure-csi-standard-lrs&quot;},&quot;mountOptions&quot;:[&quot;dir_mode=0640&quot;,&quot;file_mode=0640&quot;,&quot;uid=0&quot;,&quot;gid=0&quot;,&quot;mfsymlinks&quot;,&quot;cache=strict&quot;,&quot;nosharesock&quot;],&quot;parameters&quot;:{&quot;location&quot;:&quot;eastus&quot;,&quot;resourceGroup&quot;:&quot;kubernetes-resource-group&quot;,&quot;shareName&quot;:&quot;kubernetes&quot;,&quot;skuName&quot;:&quot;Standard_LRS&quot;,&quot;storageAccount&quot;:&quot;kubernetesrf&quot;},&quot;provisioner&quot;:&quot;kubernetes.io/azure-file&quot;,&quot;reclaimPolicy&quot;:&quot;Delete&quot;,&quot;volumeBindingMode&quot;:&quot;Immediate&quot;}
      storageclass.kubernetes.io/is-default-class: &quot;true&quot;
    creationTimestamp: &quot;2020-12-21T19:16:19Z&quot;
    managedFields:
    - apiVersion: storage.k8s.io/v1
      fieldsType: FieldsV1
      fieldsV1:
        f:allowVolumeExpansion: {}
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
            f:storageclass.kubernetes.io/is-default-class: {}
        f:mountOptions: {}
        f:parameters:
          .: {}
          f:location: {}
          f:resourceGroup: {}
          f:shareName: {}
          f:skuName: {}
          f:storageAccount: {}
        f:provisioner: {}
        f:reclaimPolicy: {}
        f:volumeBindingMode: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: &quot;2020-12-21T19:16:19Z&quot;
    name: azure-csi-standard-lrs
    resourceVersion: &quot;15914&quot;
    selfLink: /apis/storage.k8s.io/v1/storageclasses/azure-csi-standard-lrs
    uid: 3de65d08-14e7-4d0b-a6fe-39ab9a714191
  mountOptions:
  - dir_mode=0640
  - file_mode=0640
  - uid=0
  - gid=0
  - mfsymlinks
  - cache=strict
  - nosharesock
  parameters:
    location: eastus
    resourceGroup: kubernetes-resource-group
    shareName: kubernetes
    skuName: Standard_LRS
    storageAccount: kubernetesrf
  provisioner: kubernetes.io/azure-file
  reclaimPolicy: Delete
  volumeBindingMode: Immediate
kind: List
metadata:
  resourceVersion: &quot;&quot;
  selfLink: &quot;&quot;
</code></pre>
<p>My PV and PVC are bound:</p>
<pre><code>sensu-backend-etcd   10Gi       RWX            Retain           Bound    sensu-system/sensu-backend-etcd   azure-csi-standard-lrs            4m31s
</code></pre>
<pre><code>NAME                 STATUS   VOLUME               CAPACITY   ACCESS MODES   STORAGECLASS             AGE
sensu-backend-etcd   Bound    sensu-backend-etcd   10Gi       RWX            azure-csi-standard-lrs   4m47s
</code></pre>
<p>In the kubelet log I get the following:</p>
<pre><code>Dez 21 19:26:37 kubernetes-3 kubelet[34828]: E1221 19:26:37.766476   34828 pod_workers.go:191] Error syncing pod bab5a69a-f8af-43f1-a3ae-642de8daa05d (&quot;sensu-backend-0_sensu-system(bab5a69a-f8af-43f1-a3ae-642de8daa05d)&quot;), skipping: unmounted volumes=[sensu-backend-etcd], unattached volumes=[sensu-backend-etcd sensu-asset-server-ca-cert default-token-42kfh]: timed out waiting for the condition
Dez 21 19:26:58 kubernetes-3 kubelet[34828]: I1221 19:26:58.002474   34828 reconciler.go:224] operationExecutor.VerifyControllerAttachedVolume started for volume &quot;sensu-backend-etcd&quot; (UniqueName: &quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd&quot;) pod &quot;sensu-backend-0&quot; (UID: &quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d&quot;)
Dez 21 19:26:58 kubernetes-3 kubelet[34828]: E1221 19:26:58.006699   34828 nestedpendingoperations.go:301] Operation for &quot;{volumeName:kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd podName: nodeName:}&quot; failed. No retries permitted until 2020-12-21 19:29:00.006639988 +0000 UTC m=+3608.682310977 (durationBeforeRetry 2m2s). Error: &quot;Volume not attached according to node status for volume \&quot;sensu-backend-etcd\&quot; (UniqueName: \&quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd\&quot;) pod \&quot;sensu-backend-0\&quot; (UID: \&quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d\&quot;) &quot;
Dez 21 19:28:51 kubernetes-3 kubelet[34828]: E1221 19:28:51.768309   34828 kubelet.go:1594] Unable to attach or mount volumes for pod &quot;sensu-backend-0_sensu-system(bab5a69a-f8af-43f1-a3ae-642de8daa05d)&quot;: unmounted volumes=[sensu-backend-etcd], unattached volumes=[sensu-backend-etcd sensu-asset-server-ca-cert default-token-42kfh]: timed out waiting for the condition; skipping pod
Dez 21 19:28:51 kubernetes-3 kubelet[34828]: E1221 19:28:51.768335   34828 pod_workers.go:191] Error syncing pod bab5a69a-f8af-43f1-a3ae-642de8daa05d (&quot;sensu-backend-0_sensu-system(bab5a69a-f8af-43f1-a3ae-642de8daa05d)&quot;), skipping: unmounted volumes=[sensu-backend-etcd], unattached volumes=[sensu-backend-etcd sensu-asset-server-ca-cert default-token-42kfh]: timed out waiting for the condition
Dez 21 19:29:00 kubernetes-3 kubelet[34828]: I1221 19:29:00.103881   34828 reconciler.go:224] operationExecutor.VerifyControllerAttachedVolume started for volume &quot;sensu-backend-etcd&quot; (UniqueName: &quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd&quot;) pod &quot;sensu-backend-0&quot; (UID: &quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d&quot;)
Dez 21 19:29:00 kubernetes-3 kubelet[34828]: E1221 19:29:00.108069   34828 nestedpendingoperations.go:301] Operation for &quot;{volumeName:kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd podName: nodeName:}&quot; failed. No retries permitted until 2020-12-21 19:31:02.108044076 +0000 UTC m=+3730.783715065 (durationBeforeRetry 2m2s). Error: &quot;Volume not attached according to node status for volume \&quot;sensu-backend-etcd\&quot; (UniqueName: \&quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd\&quot;) pod \&quot;sensu-backend-0\&quot; (UID: \&quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d\&quot;) &quot;
Dez 21 19:31:02 kubernetes-3 kubelet[34828]: I1221 19:31:02.169246   34828 reconciler.go:224] operationExecutor.VerifyControllerAttachedVolume started for volume &quot;sensu-backend-etcd&quot; (UniqueName: &quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd&quot;) pod &quot;sensu-backend-0&quot; (UID: &quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d&quot;)
Dez 21 19:31:02 kubernetes-3 kubelet[34828]: E1221 19:31:02.172474   34828 nestedpendingoperations.go:301] Operation for &quot;{volumeName:kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd podName: nodeName:}&quot; failed. No retries permitted until 2020-12-21 19:33:04.172432877 +0000 UTC m=+3852.848103766 (durationBeforeRetry 2m2s). Error: &quot;Volume not attached according to node status for volume \&quot;sensu-backend-etcd\&quot; (UniqueName: \&quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd\&quot;) pod \&quot;sensu-backend-0\&quot; (UID: \&quot;bab5a69a-f8af-43f1-a3ae-642de8daa05d\&quot;) &quot;
Dez 21 19:31:09 kubernetes-3 kubelet[34828]: E1221 19:31:09.766084   34828 kubelet.go:1594] Unable to attach or mount volumes for pod &quot;sensu-backend-0_sensu-system(bab5a69a-f8af-43f1-a3ae-642de8daa05d)&quot;: unmounted volumes=[sensu-backend-etcd], unattached volumes=[default-token-42kfh sensu-backend-etcd sensu-asset-server-ca-cert]: timed out waiting for the condition; skipping pod
</code></pre>
<p>In the kube-controller-manager pod I get:</p>
<pre><code>E1221 20:21:34.069309       1 csi_attacher.go:500] kubernetes.io/csi: attachdetacher.WaitForDetach timeout after 2m0s [volume=sensu-backend-etcd; attachment.ID=csi-9a83de4bef35f5d01e10e3a7d598204c459cac705371256e818e3a35b4b29e4e]
E1221 20:21:34.069453       1 nestedpendingoperations.go:301] Operation for &quot;{volumeName:kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd podName: nodeName:kubernetes-3}&quot; failed. No retries permitted until 2020-12-21 20:21:34.569430175 +0000 UTC m=+6862.322990347 (durationBeforeRetry 500ms). Error: &quot;AttachVolume.Attach failed for volume \&quot;sensu-backend-etcd\&quot; (UniqueName: \&quot;kubernetes.io/csi/file.csi.azure.com^sensu-backend-etcd\&quot;) from node \&quot;kubernetes-3\&quot; : attachdetachment timeout for volume sensu-backend-etcd&quot;
I1221 20:21:34.069757       1 event.go:291] &quot;Event occurred&quot; object=&quot;sensu-system/sensu-backend-0&quot; kind=&quot;Pod&quot; apiVersion=&quot;v1&quot; type=&quot;Warning&quot; reason=&quot;FailedAttachVolume&quot; message=&quot;AttachVolume.Attach failed for volume \&quot;sensu-backend-etcd\&quot; : attachdetachment timeout for volume sensu-backend-etcd&quot;
</code></pre>
<p>Anyone who knows this error and how to mitigate it?</p>
<p>Thanks in advance.</p>
<p>Best regards,
rforberger</p>

Ronny Forberger
<p>I fixed it.</p>
<p>I switched to the disk.csi.azure.com provisioner and I had to use a volume name as a resource link to Azure like</p>
<pre><code> volumeHandle: /subscriptions/XXXXXXXXXXXXXXXXXXXXXX/resourcegroups/kubernetes-resource-group/providers/Microsoft.Compute/disks/sensu-backend-etcd
</code></pre>
<p>in the PV.</p>
<p>Also, I had some mount options in the PV, which did not work with the Azure disk provisioner.</p>
