Merge pull request #1916 from weaveworks/issues/1734-fixed-ip

Support requesting a specific IP from the plugin
This commit is contained in:
Adam Harrison committed 2016-01-29 14:22:23 +00:00
commit 4f97b3ac85
4 files changed
+27 -7

No files matched your search

+6
View File
@@ -75,6 +75,9 @@ func (c *claim) Try(alloc *Allocator) bool {
case "":
if err := alloc.space.Claim(c.addr); err == nil {
alloc.debugln("Claimed", c.addr, "for", c.ident)
if c.ident == "_" { // Special "I don't have a unique ID" identifier
c.ident = c.addr.String()
}
alloc.addOwned(c.ident, c.addr)
c.sendResult(nil)
} else {
@@ -84,6 +87,9 @@ func (c *claim) Try(alloc *Allocator) bool {
// same identifier is claiming same address; that's OK
alloc.debugln("Re-Claimed", c.addr, "for", c.ident)
c.sendResult(nil)
case c.addr.String():
// Address already allocated via "_" name
c.sendResult(fmt.Errorf("address %s already in use", c.addr))
default:
// Addr already owned by container on this machine
c.sendResult(fmt.Errorf("address %s is already owned by %s", c.addr.String(), existingIdent))