Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Commit

Permalink
Fix IPAM cache initialization
Browse files Browse the repository at this point in the history
IPAM pools are not at the CALICO_IPAM level but we must descend
into Nodes to find pools.
  • Loading branch information
toshiiw committed Jul 21, 2017
1 parent d29be69 commit 93d37c3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ func (c *ipamCache) update(node *etcd.Node, del bool) error {
return nil
}

func (c *ipamCache) syncsubr(n *etcd.Node) error {
for _, node := range n.Nodes {
if node.Dir {
if err := c.syncsubr(node); err != nil {
return err
}
} else {
if err := c.update(node, false); err != nil {
return err
}
}
}
return nil
}

// sync synchronizes the contents under /calico/v1/ipam
func (c *ipamCache) sync() error {
res, err := c.etcdAPI.Get(context.Background(), CALICO_IPAM, &etcd.GetOptions{Recursive: true})
Expand All @@ -115,7 +130,7 @@ func (c *ipamCache) sync() error {
if node.ModifiedIndex > index {
index = node.ModifiedIndex
}
if err = c.update(node, false); err != nil {
if err = c.syncsubr(node); err != nil {
return err
}
}
Expand Down

0 comments on commit 93d37c3

Please sign in to comment.