Commit f7384827 authored by Jan Safranek's avatar Jan Safranek

Fixed error handling of cloud init.

Avoid creating a new 'err' variable in the 'if'-branch, shadowing the one in the outer scope. Any error from subsequent 'cloud, err = GetCloudProvider()' was not propagated to 'err' variable in the outer scope and thus errors were never returned from this function. This is hard to debug error on OpenStack, when content of --cloud-config= file is wrong or connection to OpenStack fails. Such error is never logged and Kubernetes thinks everything is OK.
parent 196f58b9
...@@ -65,15 +65,16 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) { ...@@ -65,15 +65,16 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) {
// InitCloudProvider creates an instance of the named cloud provider. // InitCloudProvider creates an instance of the named cloud provider.
func InitCloudProvider(name string, configFilePath string) (Interface, error) { func InitCloudProvider(name string, configFilePath string) (Interface, error) {
var cloud Interface var cloud Interface
var err error
if name == "" { if name == "" {
glog.Info("No cloud provider specified.") glog.Info("No cloud provider specified.")
return nil, nil return nil, nil
} }
var err error
if configFilePath != "" { if configFilePath != "" {
config, err := os.Open(configFilePath) var config *os.File
config, err = os.Open(configFilePath)
if err != nil { if err != nil {
glog.Fatalf("Couldn't open cloud provider configuration %s: %#v", glog.Fatalf("Couldn't open cloud provider configuration %s: %#v",
configFilePath, err) configFilePath, err)
......
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