@@ -249,15 +249,23 @@ func processPersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim) (string, ma
249
249
}
250
250
251
251
var volumeID string
252
- if pvc .GetAnnotations ()["volume.beta.kubernetes.io/storage-provisioner" ] == "ebs.csi.aws.com" {
252
+ annotations := pvc .GetAnnotations ()
253
+ if annotations == nil {
254
+ log .Errorf ("cannot get PVC annotations" )
255
+ return "" , nil , errors .New ("cannot get PVC annotations" )
256
+ }
257
+ if provisionedBy , ok := annotations ["volume.beta.kubernetes.io/storage-provisioner" ]; ! ok {
258
+ log .Errorf ("cannot get volume.beta.kubernetes.io/storage-provisioner annotation" )
259
+ return "" , nil , errors .New ("cannot get volume.beta.kubernetes.io/storage-provisioner annotation" )
260
+ } else if provisionedBy == "ebs.csi.aws.com" {
253
261
volumeID = pv .Spec .CSI .VolumeHandle
254
- } else if pvc . GetAnnotations ()[ "volume.beta.kubernetes.io/storage-provisioner" ] == "kubernetes.io/aws-ebs" {
262
+ } else if provisionedBy == "kubernetes.io/aws-ebs" {
255
263
volumeID = parseAWSVolumeID (pv .Spec .PersistentVolumeSource .AWSElasticBlockStore .VolumeID )
256
264
}
257
265
log .WithFields (log.Fields {"namespace" : pvc .GetNamespace (), "pvc" : pvc .GetName (), "volumeID" : volumeID }).Debugln ("parsed volumeID:" , volumeID )
258
266
if len (volumeID ) == 0 {
259
267
log .Errorf ("Cannot parse VolumeID" )
260
- return "" , nil , errors .New ("Cannot parse VolumeID" )
268
+ return "" , nil , errors .New ("cannot parse VolumeID" )
261
269
}
262
270
263
271
return volumeID , tags , nil
0 commit comments