mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #96751 from jsafrane/deprecation-log
Lower the frequency of volume plugin deprecation warning
This commit is contained in:
commit
d5430313bf
@ -29,6 +29,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||||
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/mount-utils"
|
"k8s.io/mount-utils"
|
||||||
"k8s.io/utils/exec"
|
"k8s.io/utils/exec"
|
||||||
@ -462,6 +463,7 @@ type VolumePluginMgr struct {
|
|||||||
plugins map[string]VolumePlugin
|
plugins map[string]VolumePlugin
|
||||||
prober DynamicPluginProber
|
prober DynamicPluginProber
|
||||||
probedPlugins map[string]VolumePlugin
|
probedPlugins map[string]VolumePlugin
|
||||||
|
loggedDeprecationWarnings sets.String
|
||||||
Host VolumeHost
|
Host VolumeHost
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,6 +595,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, prober DynamicPlu
|
|||||||
defer pm.mutex.Unlock()
|
defer pm.mutex.Unlock()
|
||||||
|
|
||||||
pm.Host = host
|
pm.Host = host
|
||||||
|
pm.loggedDeprecationWarnings = sets.NewString()
|
||||||
|
|
||||||
if prober == nil {
|
if prober == nil {
|
||||||
// Use a dummy prober to prevent nil deference.
|
// Use a dummy prober to prevent nil deference.
|
||||||
@ -689,9 +692,7 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Issue warning if the matched provider is deprecated
|
// Issue warning if the matched provider is deprecated
|
||||||
if detail, ok := deprecatedVolumeProviders[matches[0].GetPluginName()]; ok {
|
pm.logDeprecation(matches[0].GetPluginName())
|
||||||
klog.Warningf("WARNING: %s built-in volume provider is now deprecated. %s", matches[0].GetPluginName(), detail)
|
|
||||||
}
|
|
||||||
return matches[0], nil
|
return matches[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,12 +725,20 @@ func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Issue warning if the matched provider is deprecated
|
// Issue warning if the matched provider is deprecated
|
||||||
if detail, ok := deprecatedVolumeProviders[matches[0].GetPluginName()]; ok {
|
pm.logDeprecation(matches[0].GetPluginName())
|
||||||
klog.Warningf("WARNING: %s built-in volume provider is now deprecated. %s", matches[0].GetPluginName(), detail)
|
|
||||||
}
|
|
||||||
return matches[0], nil
|
return matches[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logDeprecation logs warning when a deprecated plugin is used.
|
||||||
|
func (pm *VolumePluginMgr) logDeprecation(plugin string) {
|
||||||
|
if detail, ok := deprecatedVolumeProviders[plugin]; ok && !pm.loggedDeprecationWarnings.Has(plugin) {
|
||||||
|
klog.Warningf("WARNING: %s built-in volume provider is now deprecated. %s", plugin, detail)
|
||||||
|
// Make sure the message is logged only once. It has Warning severity
|
||||||
|
// and we don't want to spam the log too much.
|
||||||
|
pm.loggedDeprecationWarnings.Insert(plugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if probedPlugin cache update is required.
|
// Check if probedPlugin cache update is required.
|
||||||
// If it is, initialize all probed plugins and replace the cache with them.
|
// If it is, initialize all probed plugins and replace the cache with them.
|
||||||
func (pm *VolumePluginMgr) refreshProbedPlugins() {
|
func (pm *VolumePluginMgr) refreshProbedPlugins() {
|
||||||
|
Loading…
Reference in New Issue
Block a user