Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Default Address Pool feature support #37558

Merged
merged 1 commit into from
Aug 21, 2018
Merged

Conversation

selansen
Copy link
Contributor

This feature allows user to specify list of subnets for global
default address pool. User can configure subnet list using
'swarm init' command. Daemon passes the information to swarmkit.
We validate the information in swarmkit, then store it in cluster
object. when IPAM init is called, we pass subnet list to IPAM driver.

Signed-off-by: selansen elango.siva@docker.com

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@codecov
Copy link

codecov bot commented Jul 30, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@9916827). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37558   +/-   ##
=========================================
  Coverage          ?   36.12%           
=========================================
  Files             ?      610           
  Lines             ?    45064           
  Branches          ?        0           
=========================================
  Hits              ?    16280           
  Misses            ?    26538           
  Partials          ?     2246

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "master" git@github.com:selansen/moby.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Aug 10, 2018
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Aug 10, 2018
@selansen selansen force-pushed the master branch 3 times, most recently from 890f88d to d1be4ae Compare August 10, 2018 20:26
@selansen
Copy link
Contributor Author

Below are the PRs, need to be picked up along with this PR.

Libnetwork: moby/libnetwork#2241

CLI : docker/cli#1233

SwarmKit : moby/swarmkit#2714

@selansen
Copy link
Contributor Author

Below failure doesn't look like related to my changes. AIL: docker_cli_swarm_test.go:1376: DockerSwarmSuite.TestSwarmClusterRotateUnlockKey
22:04:47
22:04:47 [d8a8c429e1029] waiting for daemon to start
22:04:47 [d8a8c429e1029] daemon started
22:04:47
22:04:47 [d5a76b606666e] waiting for daemon to start
22:04:47 [d5a76b606666e] daemon started
22:04:47
22:04:47 [d82090c38b68e] waiting for daemon to start
22:04:47 [d82090c38b68e] daemon started
22:04:47
22:04:47 [d5a76b606666e] exiting daemon
22:04:47 [d5a76b606666e] waiting for daemon to start
22:04:47 [d5a76b606666e] daemon started
22:04:47
22:04:47 [d82090c38b68e] exiting daemon
22:04:47 [d82090c38b68e] waiting for daemon to start
22:04:47 [d82090c38b68e] daemon started
22:04:47
22:04:47 [d5a76b606666e] exiting daemon
22:04:47 [d5a76b606666e] waiting for daemon to start
22:04:47 [d5a76b606666e] daemon started
22:04:47
22:04:47 [d82090c38b68e] exiting daemon
22:04:47 [d82090c38b68e] waiting for daemon to start
22:04:47 [d82090c38b68e] daemon started
22:04:47
22:04:47 docker_cli_swarm_test.go:1454:
22:04:47 c.Assert(err, checker.IsNil)
22:04:47 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc421e899c0), Stderr:[]uint8(nil)} ("exit status 1")
22:04:47
22:04:47 [d8a8c429e1029] exiting daemon
22:04:47 [d5a76b606666e] exiting daemon
22:04:47 [d82090c38b68e] exiting daemon

@selansen selansen force-pushed the master branch 3 times, most recently from 2cf041f to fef644c Compare August 17, 2018 03:15
@selansen
Copy link
Contributor Author

Added extra integration test :)

@selansen
Copy link
Contributor Author

@thaJeztah , PTAL and let me know if you still have any comments.

@selansen selansen force-pushed the master branch 2 times, most recently from 483cc86 to 2d7160c Compare August 20, 2018 12:12
api/swagger.yaml Outdated
This flag specifies default subnet pools for global scope networks. If subnet size is not
specified then default value 24 will be used.
If unspecified, Docker will use the predefined subnets as it works on older releases.
type: "string"
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the actual API, which uses an array of net.IPNet for DefaultAddrPool, and a separate SubnetSize field for the size.

api/swagger.yaml Outdated
@@ -8765,6 +8765,12 @@ paths:
nodes in order to reach the containers running on this node. Using this parameter it is possible to
separate the container data traffic from the management traffic of the cluster.
type: "string"
DefaultAddrPool:
description: |
This flag specifies default subnet pools for global scope networks. If subnet size is not
Copy link
Member

Choose a reason for hiding this comment

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

Swagger describes the API specification, so should not mention "flag".

"subnet size" is a separate option; you can mention it in the description here, but the default should probably be described as part of the description for SubnetSize.

Would be good to have an example value in the swagger spec as well, so that it's clear how what format is expected.

@@ -12,6 +13,14 @@ import (

// SwarmFromGRPC converts a grpc Cluster to a Swarm.
func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
var defaultAddrPool []*net.IPNet
for _, address := range c.DefaultAddressPool {
_, b, err := net.ParseCIDR(address)
Copy link
Member

Choose a reason for hiding this comment

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

The change I proposed wouldn't change that logic; the only difference is that it would scope the b variable to the if (and it being a more idiomatic code-style); it's just a nit though, so not a blocker

@@ -153,6 +158,8 @@ type InitRequest struct {
Spec Spec
AutoLockManagers bool
Availability NodeAvailability
DefaultAddrPool []*net.IPNet
Copy link
Member

Choose a reason for hiding this comment

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

Although I suggested to use IPNet for as internal type (mainly for the CLI-side); for the over-the-wire format for this is rather awkward; the string representation (without converting individual entries to a string when marshalling);

For example, the request now needs to look like;

{"DefaultAddrPool":[{"IP":"192.0.2.0","Mask":"////AA=="}]}

Whereas individually encoding IPNet to a string would look like

{"DefaultAddrPool":["192.0.2.0/24"]}

Copy link
Member

Choose a reason for hiding this comment

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

Completely agree with @thaJeztah, we shouldn't leak implementation detail in our API and have our own type here (if we need something complex). Here it seems just a slice of string would work.

@@ -153,6 +158,8 @@ type InitRequest struct {
Spec Spec
AutoLockManagers bool
Availability NodeAvailability
DefaultAddrPool []*net.IPNet
Copy link
Member

Choose a reason for hiding this comment

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

Completely agree with @thaJeztah, we shouldn't leak implementation detail in our API and have our own type here (if we need something complex). Here it seems just a slice of string would work.

@@ -12,6 +13,14 @@ import (

// SwarmFromGRPC converts a grpc Cluster to a Swarm.
func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
var defaultAddrPool []*net.IPNet
for _, address := range c.DefaultAddressPool {
_, b, err := net.ParseCIDR(address)
Copy link
Member

Choose a reason for hiding this comment

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

We are adding into slice only if b is not null.

Wrong, you're adding it to the slice only if err == nil, there is no check on b. I do agree with @thaJeztah and the proposed change 👼

@@ -59,6 +59,18 @@ func NewSwarm(t *testing.T, testEnv *environment.Execution, ops ...func(*daemon.
return d
}

// NewSwarmWithOption creates a swarm daemon for testing with init option we specify
func NewSwarmWithOption(t *testing.T, initReq swarmtypes.InitRequest, testEnv *environment.Execution, ops ...func(*daemon.Daemon)) *daemon.Daemon {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is required… We should update the NewSwarm function instead, with a WithInitOption operation.

@@ -28,6 +28,18 @@ func (d *Daemon) StartAndSwarmInit(t testingT) {
d.SwarmInit(t, swarm.InitRequest{})
}

// StartAndSwarmInitWithOption starts the daemon (with busybox) and init the swarm with params
func (d *Daemon) StartAndSwarmInitWithOption(t testingT, initReq swarm.InitRequest) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, we could update StartAndSwarmInit to take *operationswith one forInitRequest`

func (d *Daemon) StartAndSwarmInit(t testingT, ops ...func(*swarm.InitRequest{})) {
    initRequest := &swarm.InitRequest{}
    for _, op := range ops { op(initRequest) }
    // …
    d.SwarmInit(t, *initRequest)
}

@selansen
Copy link
Contributor Author

@thaJeztah @vdemeester PTAL. Modified API param from IPNet to String slice.

@selansen selansen force-pushed the master branch 2 times, most recently from 7887345 to 0e185a2 Compare August 20, 2018 17:38
vendor.conf Outdated
@@ -125,7 +125,7 @@ github.com/containerd/ttrpc 94dde388801693c54f88a6596f713b51a8b30b2d
github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef

# cluster
github.com/docker/swarmkit 8852e8840e30d69db0b39a4a3d6447362e17c64f
github.com/docker/swarmkit 324a450ca695fae75b7bd00d6b83debddea18462
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest updating to the latest which is cfa742c @selansen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update now.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Some minor issues in swagger.yml (and some suggestions for follow-ups), but otherwise looks good to me.

api/swagger.yaml Outdated
DefaultAddrPool:
description: |
Default Address Pool specifies default subnet pools for global scope networks.
type: "string"
Copy link
Member

Choose a reason for hiding this comment

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

This should be "array" with "string" as type for the items, e.g. similar to

moby/api/swagger.yaml

Lines 414 to 417 in 896d1b1

type: "array"
items:
type: "string"
example: "c 13:* rwm"

api/swagger.yaml Outdated
Spec:
$ref: "#/definitions/SwarmSpec"
example:
ListenAddr: "0.0.0.0:2377"
AdvertiseAddr: "192.168.1.1:2377"
DefaultAddrPool: "20.20.0.0/16"
Copy link
Member

Choose a reason for hiding this comment

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

DefaultAddrPool is an array, so this should be something like;

DefaultAddrPool: ["10.10.0.0/16", "20.20.0.0/16"]

// Hostname is not set here. Instead, it is obtained from
// the node description that is reported periodically
swarmnodeConfig := swarmnode.Config{
ForceNewCluster: conf.forceNewCluster,
ListenControlAPI: control,
ListenRemoteAPI: conf.ListenAddr,
AdvertiseRemoteAPI: conf.AdvertiseAddr,
DefaultAddrPool: defaultAddrPool,
SubnetSize: int(conf.SubnetSize),
Copy link
Member

@thaJeztah thaJeztah Aug 20, 2018

Choose a reason for hiding this comment

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

Ideally, we'd fix the int / uint32 on swarmkit side as well before GA (for a follow-up before GA)

Copy link
Contributor Author

@selansen selansen Aug 20, 2018

Choose a reason for hiding this comment

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

yes. I am planning to refactor swarmkit code as Anshul wanted to move around code a bit

@@ -110,13 +115,21 @@ func (n *nodeRunner) start(conf nodeStartConfig) error {
joinAddr = conf.RemoteAddr
}

var defaultAddrPool []*net.IPNet
for _, address := range conf.DefaultAddressPool {
if _, b, err := net.ParseCIDR(address); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Could be done in a follow-up, but; I see other validation steps are done in newNodeRunner(); we should consider moving those all to a single place, not partly here, and partly there. We can also return parsing errors there.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member

@selansen vendor check is failing; can you check?

18:50:21 2018/08/20 18:50:21 Running time: 1m34.119400485s
18:50:21 The result of vndr differs
18:50:21 
18:50:21  M vendor/github.com/docker/swarmkit/manager/allocator/network.go
18:50:21 
18:50:21 Please vendor your package with github.com/LK4D4/vndr.

This feature allows user to specify list of subnets for global
default address pool. User can configure subnet list using
'swarm init' command. Daemon passes the information to swarmkit.
We validate the information in swarmkit, then store it in cluster
object. when IPAM init is called, we pass subnet list to IPAM driver.

Signed-off-by: selansen <elango.siva@docker.com>
@thaJeztah
Copy link
Member

PowerPC failure is unrelated; #34988

@selansen
Copy link
Contributor Author

windowsRS1 failure : this doesnt look related to my change
Build timed out (after 200 minutes). Marking the build as failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants