Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Claim existing IP addresses at startup with no race condition #2787

Merged
merged 6 commits into from
Feb 13, 2017

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented Feb 9, 2017

Fixes #2784

reclaim.go is a re-implementation of the launch.sh code to claim addresses in Go.
We already had a pendingClaims list in IPAM, so we simply pre-populate this with entries for each existing address. The claims will be processed as soon as the ring is known.

As it stands, this code is only good enough for weave-kube, not for weave launch
The code to find existing IPs works through the process table, and thus we do not have the Docker container ID. To resolve that I propose to add another loop to go through Docker container IDs if we have a Docker API connection.

@bboreham bboreham added this to the 1.9.1 milestone Feb 9, 2017
@bboreham bboreham self-assigned this Feb 9, 2017
Copy link

@chrislovecnm chrislovecnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick question about logging.

@@ -0,0 +1,54 @@
package main

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham bboreham force-pushed the issues/2784-preclaim-addresses branch from 9b56239 to 0831f81 Compare February 10, 2017 14:58
doing it from the script

Note we need to run weaver in the host pid namespace, so it can search
for existing container IPs. Also now we are firing off sub-processes
it's better to not be PID 1 so Linux doesn't expect us to reap zombies.
@bboreham bboreham force-pushed the issues/2784-preclaim-addresses branch 2 times, most recently from 3552773 to 6ebf06e Compare February 10, 2017 17:30
@bboreham bboreham changed the title WIP: Claim existing addresses at startup Claim existing IP addresses at startup with no race condition Feb 10, 2017
@brb brb self-requested a review February 10, 2017 17:51
@brb brb assigned brb and unassigned bboreham Feb 10, 2017
@bboreham bboreham force-pushed the issues/2784-preclaim-addresses branch from 6ebf06e to 43ea755 Compare February 13, 2017 10:01
The intention, per the comments, is that host1 should claim from host2.
But host2 and host3 can carve up the space either way round.  If host1
claims from host3 then there is a race whether anyone finds out about
it.
Adding a 'prime' on host2 ensures the space is all owned by host2 at that point.
@bboreham bboreham force-pushed the issues/2784-preclaim-addresses branch from 43ea755 to 293abd9 Compare February 13, 2017 11:31
@@ -76,13 +76,20 @@ type Allocator struct {
now func() time.Time
}

type PreClaim struct {
Ident string
IsContainer bool

This comment was marked as abuse.

This comment was marked as abuse.

}
preClaims, err := findExistingAddresses(dockerCli, allContainerIDs, weavenet.WeaveBridgeName)

This comment was marked as abuse.

This comment was marked as abuse.

// Now iterate over all containers to see if they have a network
// namespace with an attached interface
if dockerCli != nil {
for _, cid := range containerIDs {

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham bboreham changed the base branch from master to 1.9 February 13, 2017 17:43
@brb brb merged commit 32d44e0 into 1.9 Feb 13, 2017
@brb brb mentioned this pull request Feb 15, 2017
@bboreham bboreham deleted the issues/2784-preclaim-addresses branch February 23, 2017 12:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants