Merge pull request #91539 from andrewsykim/fix-cloud-provider-deprecation

only log cloud provider deprecation warning for in-tree components
This commit is contained in:
Kubernetes Prow Robot 2020-07-10 00:59:48 -07:00 committed by GitHub
commit 2d327ac455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 12 deletions

View File

@ -242,6 +242,8 @@ func CreateNodeDialer(s completedServerRunOptions) (tunneler.Tunneler, *http.Tra
if len(s.SSHUser) > 0 {
// Get ssh key distribution func, if supported
var installSSHKey tunneler.InstallSSHKey
cloudprovider.DeprecationWarningForProvider(s.CloudProvider.CloudProvider)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider.CloudProvider, s.CloudProvider.CloudConfigFile)
if err != nil {
return nil, nil, fmt.Errorf("cloud provider could not be initialized: %v", err)

View File

@ -41,6 +41,8 @@ func createCloudProvider(cloudProvider string, externalCloudVolumePlugin string,
}
cloud, err = cloudprovider.InitCloudProvider(externalCloudVolumePlugin, cloudConfigFile)
} else {
cloudprovider.DeprecationWarningForProvider(cloudProvider)
loopMode = IncludeCloudLoops
cloud, err = cloudprovider.InitCloudProvider(cloudProvider, cloudConfigFile)
}

View File

@ -523,6 +523,7 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
if kubeDeps.Cloud == nil {
if !cloudprovider.IsExternal(s.CloudProvider) {
cloudprovider.DeprecationWarningForProvider(s.CloudProvider)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil {
return err

View File

@ -91,6 +91,22 @@ func IsExternal(name string) bool {
return name == externalCloudProvider
}
func DeprecationWarningForProvider(providerName string) {
for _, provider := range deprecatedCloudProviders {
if provider.name != providerName {
continue
}
detail := provider.detail
if provider.external {
detail = fmt.Sprintf("Please use 'external' cloud provider for %s: %s", providerName, provider.detail)
}
klog.Warningf("WARNING: %s built-in cloud provider is now deprecated. %s", providerName, detail)
break
}
}
// InitCloudProvider creates an instance of the named cloud provider.
func InitCloudProvider(name string, configFilePath string) (Interface, error) {
var cloud Interface
@ -105,18 +121,6 @@ func InitCloudProvider(name string, configFilePath string) (Interface, error) {
return nil, nil
}
for _, provider := range deprecatedCloudProviders {
if provider.name == name {
detail := provider.detail
if provider.external {
detail = fmt.Sprintf("Please use 'external' cloud provider for %s: %s", name, provider.detail)
}
klog.Warningf("WARNING: %s built-in cloud provider is now deprecated. %s", name, detail)
break
}
}
if configFilePath != "" {
var config *os.File
config, err = os.Open(configFilePath)