fix azure file migration panic

This commit is contained in:
andyzhangx 2020-09-17 13:19:13 +00:00
parent 3eb90c19d0
commit 0d47999645

View File

@ -119,9 +119,11 @@ func (t *azureFileCSITranslator) TranslateInTreePVToCSI(pv *v1.PersistentVolume)
accountName = azureSource.SecretName
}
resourceGroup := ""
if pv.ObjectMeta.Annotations != nil {
if v, ok := pv.ObjectMeta.Annotations[resourceGroupAnnotation]; ok {
resourceGroup = v
}
}
volumeID := fmt.Sprintf(volumeIDTemplate, resourceGroup, accountName, azureSource.ShareName, "")
var (
@ -183,6 +185,9 @@ func (t *azureFileCSITranslator) TranslateCSIPVToInTree(pv *v1.PersistentVolume)
pv.Spec.CSI = nil
pv.Spec.AzureFile = azureSource
if resourceGroup != "" {
if pv.ObjectMeta.Annotations == nil {
pv.ObjectMeta.Annotations = map[string]string{}
}
pv.ObjectMeta.Annotations[resourceGroupAnnotation] = resourceGroup
}