Skip to content

bitseq: Unselected() does not check datastore #1933

@jlacoline

Description

@jlacoline

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions