Commit 38a884aa authored by xiangqian's avatar xiangqian

using storage class provisioner instead of annotation of a pv for external provisioner

minor updates
parent 96885115
...@@ -1733,26 +1733,27 @@ func (ctrl *PersistentVolumeController) getProvisionerNameFromVolume(volume *v1. ...@@ -1733,26 +1733,27 @@ func (ctrl *PersistentVolumeController) getProvisionerNameFromVolume(volume *v1.
if err != nil { if err != nil {
return "N/A" return "N/A"
} }
// if external provisioner was used for provisioning, if plugin != nil && !plugin.IsMigratedToCSI() {
// the volume MUST have annotation of AnnDynamicallyProvisioned, use the value return plugin.GetPluginName()
// as the provisioner name }
if plugin == nil { // If reached here, Either an external provisioner was used for provisioning
return volume.Annotations[pvutil.AnnDynamicallyProvisioned] // or a plugin has been migrated to CSI.
} else if plugin.IsMigratedToCSI() { // If an external provisioner was used, i.e., plugin == nil, instead of using
// in case where a plugin has been migrated to CSI, // the AnnDynamicallyProvisioned annotation value, use the storageClass's Provisioner
// use the CSI name instead of in-tree name // field to avoid explosion of the metric in the cases like local storage provisioner
storageClass := v1helper.GetPersistentVolumeClass(volume) // tagging a volume with arbitrary provisioner names
class, err := ctrl.classLister.Get(storageClass) storageClass := v1helper.GetPersistentVolumeClass(volume)
if err != nil { class, err := ctrl.classLister.Get(storageClass)
return "N/A" if err != nil {
} return "N/A"
}
if plugin != nil {
provisionerName, err := ctrl.getCSINameFromIntreeName(class.Provisioner) provisionerName, err := ctrl.getCSINameFromIntreeName(class.Provisioner)
if err != nil { if err == nil {
return "N/A" return provisionerName
} }
return provisionerName
} }
return plugin.GetPluginName() return class.Provisioner
} }
// obtain plugin/external provisioner name from plugin and storage class // obtain plugin/external provisioner name from plugin and storage class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment