mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
azure_file: try to get secret namespace from ClaimRef
This is the actual fix - attempt to obtain a namespace from ClaimRef. Or fail if namespace could not be found instead of using "default".
This commit is contained in:
parent
a2b0eddc44
commit
507c63c610
@ -129,9 +129,21 @@ func (t *azureFileCSITranslator) TranslateInTreePVToCSI(pv *v1.PersistentVolume)
|
|||||||
resourceGroup = v
|
resourceGroup = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace := defaultSecretNamespace
|
|
||||||
|
// Secret is required when mounting a volume but pod presence cannot be assumed - we should not try to read pod now.
|
||||||
|
namespace := ""
|
||||||
|
// Try to read SecretNamespace from source pv.
|
||||||
if azureSource.SecretNamespace != nil {
|
if azureSource.SecretNamespace != nil {
|
||||||
namespace = *azureSource.SecretNamespace
|
namespace = *azureSource.SecretNamespace
|
||||||
|
} else {
|
||||||
|
// Try to read namespace from ClaimRef which should be always present.
|
||||||
|
if pv.Spec.ClaimRef != nil {
|
||||||
|
namespace = pv.Spec.ClaimRef.Namespace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(namespace) == 0 {
|
||||||
|
return nil, fmt.Errorf("could not find a secret namespace in PersistentVolumeSource or ClaimRef")
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeID := fmt.Sprintf(volumeIDTemplate, resourceGroup, accountName, azureSource.ShareName, pv.ObjectMeta.Name, namespace)
|
volumeID := fmt.Sprintf(volumeIDTemplate, resourceGroup, accountName, azureSource.ShareName, pv.ObjectMeta.Name, namespace)
|
||||||
|
Loading…
Reference in New Issue
Block a user