Merge pull request #10635 from smarterclayton/cloud_provider_should_err

Cloud provider should return an error
pull/6/head
Vish Kannan 2015-07-23 17:50:45 -07:00
commit 2a5a6b99cb
5 changed files with 22 additions and 9 deletions

View File

@ -260,7 +260,10 @@ func (s *APIServer) Run(_ []string) error {
HostNetworkSources: []string{},
})
cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil {
glog.Fatalf("Cloud provider could not be initialized: %v", err)
}
kubeletClient, err := client.NewKubeletClient(&s.KubeletConfig)
if err != nil {

View File

@ -186,7 +186,10 @@ func (s *CMServer) Run(_ []string) error {
controllerManager := replicationControllerPkg.NewReplicationManager(kubeClient, replicationControllerPkg.BurstReplicas)
go controllerManager.Run(s.ConcurrentRCSyncs, util.NeverStop)
cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil {
glog.Fatalf("Cloud provider could not be initialized: %v", err)
}
nodeController := nodecontroller.NewNodeController(cloud, kubeClient, s.RegisterRetryCount,
s.PodEvictionTimeout, nodecontroller.NewPodEvictor(util.NewTokenBucketRateLimiter(s.DeletingPodsQps, s.DeletingPodsBurst)),

View File

@ -286,7 +286,10 @@ func (s *KubeletServer) Run(_ []string) error {
DockerFreeDiskMB: s.LowDiskSpaceThresholdMB,
RootFreeDiskMB: s.LowDiskSpaceThresholdMB,
}
cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil {
return err
}
glog.V(2).Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
hostNetworkSources, err := kubelet.GetValidatedSources(strings.Split(s.HostNetworkSources, ","))

View File

@ -117,7 +117,10 @@ func (s *CMServer) Run(_ []string) error {
if s.CloudProvider != mesos.ProviderName {
glog.Fatalf("Only provider %v is supported, you specified %v", mesos.ProviderName, s.CloudProvider)
}
cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
if err != nil {
glog.Fatalf("Cloud provider could not be initialized: %v", err)
}
nodeController := nodecontroller.NewNodeController(cloud, kubeClient, s.RegisterRetryCount,
s.PodEvictionTimeout, nodecontroller.NewPodEvictor(util.NewTokenBucketRateLimiter(s.DeletingPodsQps, s.DeletingPodsBurst)),

View File

@ -17,6 +17,7 @@ limitations under the License.
package cloudprovider
import (
"fmt"
"io"
"os"
"sync"
@ -62,12 +63,12 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) {
}
// InitCloudProvider creates an instance of the named cloud provider.
func InitCloudProvider(name string, configFilePath string) Interface {
func InitCloudProvider(name string, configFilePath string) (Interface, error) {
var cloud Interface
if name == "" {
glog.Info("No cloud provider specified.")
return nil
return nil, nil
}
var err error
@ -87,11 +88,11 @@ func InitCloudProvider(name string, configFilePath string) Interface {
}
if err != nil {
glog.Fatalf("Couldn't init cloud provider %q: %v", name, err)
return nil, fmt.Errorf("could not init cloud provider %q: %v", name, err)
}
if cloud == nil {
glog.Fatalf("Unknown cloud provider: %s", name)
return nil, fmt.Errorf("unknown cloud provider %q", name)
}
return cloud
return cloud, nil
}