moby / moby/libnetwork

bitseq: Unselected() does not check datastore

Open
#1,933 5 comments 0 reactions 1 assignee View on GitHub

@abhi is already working on this.

Since Sep 5, 2017.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

The problem

When calling RequestAddress on an IPAM, the ErrNoAvailableIPs error can be raised even if there are remaining addresses when some conditions are met.

This comes from the h.Unselected() <= 0 condition beeing checked on the bitmask without synchronizing it with the datastore first (ipam/allocator.go:534).

How to reproduce

The bug was found when using a swarm legacy cluster with a consul datastore (Docker version 17.05.0-ce).

  • Create an overlay network small with a small enough IP range.
  • On a first node, start as much containers as the network allows it.
  • On a second node, try to start a container on this network => "no available IPv4 addresses". Now the local bitseq is synchronised with consul. The IPAM's Alllocator is such that a.addresses[k].Unselected() == 0, k beeing the network subnet
  • On node n°1, stop one (or more) of the containers. The bitmask in the consul datastore is now correctly updated, but node n°2 was not notified of this in any way.
  • On node n °2, try to start a container again => same error message. We still have a.addresses[k].Unselected() == 0 and no call to consul is made to refresh the bitmask. From this point this is impossible to start any container on the network using this node. Restarting the docker daemon fixes the problem.

I'll submit a (naive) patch to handle this problem soon.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.