Validate port sets

Allocate ports, both statically specified and dynamically allocated, in discrete sets.  If any individual allocation fails then the entire allocation fails without any effects. 

This addresses issue #57 and issue #59.  It also fixes potential race/deadlock issues with container allocation related to port allocation.

Because it gains us nothing right now and it complicates the logic.  If
someone needs that functionality later they can add it later.


On Tue, Oct 14, 2014 at 6:42 PM, Peter Bourgon <notifications@github.com>
wrote:

> In harpoon-agent/ports.go:
>
> > @@ -130,13 +275,32 @@ func (pr *portRange) isPortInUse(port uint16) bool {
> >  	return false
> >  }
> >
> > -// nextPort returns the next available port and then calculates and records its successor.
> > -func (pr *portRange) nextPort() uint16 {
> > -	nextPort := pr.port
> > -	port := pr.port + 1
> > -	if port > pr.endPort {
> > -		port = pr.startPort
> > +// areSetsIntersecting returns true if b intersects with a.
> > +//
> > +// Set b is assumed to be smaller, so is used to check.
>
> Okay... but I don't really understand why you'd impose artificial
> restrictions into a simple and general-purpose function like that.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/soundcloud/harpoon/pull/89/files#r18840988>.
>



-- 
- Jeff Younker - jmy@soundcloud.com - +49 (0) 171 5641365 -