Don't swallow errors in the docker client.

This commit is contained in:
Tom Wilkie committed 2015-07-17 12:35:12 +00:00
1 parent e03a4bb176
commit 25c9180fdf
4 files changed
+13 -11

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ import (
// An observer for container events
type ContainerObserver interface {
ContainerDied(ident string) error
ContainerDied(ident string)
}
type Client struct {
+2 -4
View File
@@ -223,12 +223,10 @@ func (alloc *Allocator) Claim(ident string, addr address.Address) error {
}
// ContainerDied is provided to satisfy the updater interface; does a 'Delete' underneath. Sync.
func (alloc *Allocator) ContainerDied(ident string) error {
err := alloc.Delete(ident)
if err == nil {
func (alloc *Allocator) ContainerDied(ident string) {
if err := alloc.Delete(ident); err == nil {
alloc.debugln("Container", ident, "died; released addresses")
}
return err
}
// Delete (Sync) - release all IP addresses for container with given name
+9 -4
View File
@@ -120,7 +120,7 @@ func (n *Nameserver) ReverseLookup(ip address.Address) (string, error) {
return match.Hostname, nil
}
func (n *Nameserver) ContainerDied(ident string) error {
func (n *Nameserver) ContainerDied(ident string) {
n.Lock()
entries := n.entries.tombstone(n.ourName, func(e *Entry) bool {
if e.ContainerID == ident {
@@ -130,10 +130,12 @@ func (n *Nameserver) ContainerDied(ident string) error {
return false
})
n.Unlock()
if n.gossip != nil {
return n.gossip.GossipBroadcast(entries)
if n.gossip != nil && len(*entries) > 0 {
err := n.gossip.GossipBroadcast(entries)
if err != nil {
n.errorf("Failed to broadcast container '%s' death: %v", ident, err)
}
}
return nil
}
func (n *Nameserver) PeerGone(peer *router.Peer) {
@@ -253,3 +255,6 @@ func (n *Nameserver) infof(fmt string, args ...interface{}) {
func (n *Nameserver) debugf(fmt string, args ...interface{}) {
Log.Debugf("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
}
func (n *Nameserver) errorf(fmt string, args ...interface{}) {
Log.Errorf("[nameserver %s] "+fmt, append([]interface{}{n.ourName}, args...)...)
}
+1 -2
View File
@@ -205,8 +205,7 @@ func TestContainerAndPeerDeath(t *testing.T) {
require.Nil(t, err)
require.Equal(t, []address.Address{0}, nameserver.Lookup("hostname"))
err = nameserver.ContainerDied("containerid")
require.Nil(t, err)
nameserver.ContainerDied("containerid")
require.Equal(t, []address.Address{}, nameserver.Lookup("hostname"))
err = nameserver.AddEntry("hostname", "containerid", peername, address.Address(0))