Skip to content

Commit 0d47999

Browse files
committed
fix azure file migration panic
1 parent 3eb90c1 commit 0d47999

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

staging/src/k8s.io/csi-translation-lib/plugins/azure_file.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ func (t *azureFileCSITranslator) TranslateInTreePVToCSI(pv *v1.PersistentVolume)
119119
accountName = azureSource.SecretName
120120
}
121121
resourceGroup := ""
122-
if v, ok := pv.ObjectMeta.Annotations[resourceGroupAnnotation]; ok {
123-
resourceGroup = v
122+
if pv.ObjectMeta.Annotations != nil {
123+
if v, ok := pv.ObjectMeta.Annotations[resourceGroupAnnotation]; ok {
124+
resourceGroup = v
125+
}
124126
}
125127
volumeID := fmt.Sprintf(volumeIDTemplate, resourceGroup, accountName, azureSource.ShareName, "")
126128

@@ -183,6 +185,9 @@ func (t *azureFileCSITranslator) TranslateCSIPVToInTree(pv *v1.PersistentVolume)
183185
pv.Spec.CSI = nil
184186
pv.Spec.AzureFile = azureSource
185187
if resourceGroup != "" {
188+
if pv.ObjectMeta.Annotations == nil {
189+
pv.ObjectMeta.Annotations = map[string]string{}
190+
}
186191
pv.ObjectMeta.Annotations[resourceGroupAnnotation] = resourceGroup
187192
}
188193

0 commit comments

Comments
 (0)