mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2026-01-08 16:21:50 +00:00
fix plugin probe init race causing erroneous volume unmounts
Signed-off-by: Olga Shestopalova <oshestopalova1@gmail.com>
This commit is contained in:
@@ -627,6 +627,7 @@ func (pm *VolumePluginMgr) initProbedPlugin(probedPlugin VolumePlugin) error {
|
||||
// specification. If no plugins can support or more than one plugin can
|
||||
// support it, return error.
|
||||
func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
|
||||
pm.refreshProbedPlugins()
|
||||
pm.mutex.RLock()
|
||||
defer pm.mutex.RUnlock()
|
||||
|
||||
@@ -643,7 +644,6 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
|
||||
}
|
||||
}
|
||||
|
||||
pm.refreshProbedPlugins()
|
||||
for _, plugin := range pm.probedPlugins {
|
||||
if plugin.CanSupport(spec) {
|
||||
match = plugin
|
||||
@@ -663,6 +663,7 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
|
||||
|
||||
// FindPluginByName fetches a plugin by name. If no plugin is found, returns error.
|
||||
func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
|
||||
pm.refreshProbedPlugins()
|
||||
pm.mutex.RLock()
|
||||
defer pm.mutex.RUnlock()
|
||||
|
||||
@@ -671,7 +672,6 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
|
||||
match = v
|
||||
}
|
||||
|
||||
pm.refreshProbedPlugins()
|
||||
if plugin, found := pm.probedPlugins[name]; found {
|
||||
if match != nil {
|
||||
return nil, fmt.Errorf("multiple volume plugins matched: %s and %s", match.GetPluginName(), plugin.GetPluginName())
|
||||
@@ -694,6 +694,12 @@ func (pm *VolumePluginMgr) refreshProbedPlugins() {
|
||||
klog.ErrorS(err, "Error dynamically probing plugins")
|
||||
}
|
||||
|
||||
if len(events) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
pm.mutex.Lock()
|
||||
defer pm.mutex.Unlock()
|
||||
// because the probe function can return a list of valid plugins
|
||||
// even when an error is present we still must add the plugins
|
||||
// or they will be skipped because each event only fires once
|
||||
|
||||
Reference in New Issue
Block a user