Skip to content

Commit f688944

Browse files
author
Erik Hollensbe
authored
Merge pull request #623 from erikh/fix-etcd-svcplugin
netplugin/svcplugin: check etcd connection errors.
2 parents 673af03 + 7b7d64b commit f688944

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

netplugin/svcplugin/bridge/bridge.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ func New(adapterURI string, config Config) (*Bridge, error) {
4242
}
4343

4444
log.Infof("Using", uri.Scheme, "service adapter:", uri)
45+
reg, err := factory.New(uri)
46+
if err != nil {
47+
return nil, err
48+
}
49+
4550
return &Bridge{
4651
config: config,
47-
registry: factory.New(uri),
52+
registry: reg,
4853
services: make(map[string][]*Service),
4954
}, nil
5055
}

netplugin/svcplugin/bridge/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// AdapterFactory implements the ServiceRegistrator
1010
type AdapterFactory interface {
11-
New(uri *url.URL) RegistryAdapter
11+
New(uri *url.URL) (RegistryAdapter, error)
1212
}
1313

1414
// RegistryAdapter defines the interface that ServiceRegistrators must implement

netplugin/svcplugin/skydns2extension/skydns2.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func init() {
2121
type Factory struct{}
2222

2323
// New function to register Skydns2Adapter
24-
func (f *Factory) New(uri *url.URL) bridge.RegistryAdapter {
24+
func (f *Factory) New(uri *url.URL) (bridge.RegistryAdapter, error) {
2525
if uri.Host == "" {
2626
uri.Host = "localhost:2379"
2727
}
@@ -33,9 +33,10 @@ func (f *Factory) New(uri *url.URL) bridge.RegistryAdapter {
3333
etcdClient, err := client.New(etcdConfig)
3434
if err != nil {
3535
log.Fatalf("Error creating etcd client. Err: %v", err)
36+
return nil, err
3637
}
3738

38-
return &Skydns2Adapter{client: client.NewKeysAPI(etcdClient)}
39+
return &Skydns2Adapter{client: client.NewKeysAPI(etcdClient)}, nil
3940
}
4041

4142
// Skydns2Adapter implements skydns2 client interface

0 commit comments

Comments
 (0)