Commit d8bb4552 authored by Clayton Coleman's avatar Clayton Coleman

Cloud provider should return an error

Not fatal - makes cloud provider useful in methods that can return error.
parent 7689391c
......@@ -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 {
......
......@@ -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)),
......
......@@ -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, ","))
......
......@@ -115,7 +115,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)),
......
......@@ -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
}
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