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

Adding ipam options to ipam driver requests #2324

Merged
merged 2 commits into from
Oct 4, 2017
Merged

Conversation

abhi
Copy link
Contributor

@abhi abhi commented Jul 20, 2017

  1. Currently ipam options doesnt seem to be passed to remote ipam drivers. Remote ipam drivers that depend on any driver specific options will not work if ipam options are not included in the
    RequestAddress from the swarm manager to allocate IPs. This is a minor fix to pass the ipam options to ipam drivers.

  2. This also ensures that the IP and port allocation done by the libnetwork allocator is done in serial manner (next available) as opposed to first available. This helps mitigate some of the issue we see due to immediate resource release on the swarm side.

Signed-off-by: Abhinandan Prativadi [email protected]

@@ -553,6 +553,8 @@ func (na *cnmNetworkAllocator) releaseEndpoints(networks []*api.NetworkAttachmen

// allocate virtual IP for a single endpoint attachment of the service.
func (na *cnmNetworkAllocator) allocateVIP(vip *api.Endpoint_VirtualIP) error {

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be delete the empty line

@yuexiao-wang
Copy link
Contributor

CI fails :

  • inconsistent dependencies! what you have in vendor.conf does not match with what you have in vendor
    make: *** [dep-validate] Error 1

.vendor.bak/golang.org/x/text/unicode/norm/maketables.go
👹 please format Go code with 'gofmt -s -w'
make: *** [fmt] Error 1

@abhi abhi force-pushed the ipam branch 2 times, most recently from 92d66d1 to a5797af Compare July 21, 2017 03:59
@codecov
Copy link

codecov bot commented Jul 21, 2017

Codecov Report

Merging #2324 into master will decrease coverage by 0.1%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2324      +/-   ##
==========================================
- Coverage   60.56%   60.45%   -0.11%     
==========================================
  Files         128      128              
  Lines       26277    26303      +26     
==========================================
- Hits        15915    15902      -13     
- Misses       8966     8993      +27     
- Partials     1396     1408      +12

@aaronlehmann
Copy link
Collaborator

CI fails :

  • inconsistent dependencies! what you have in vendor.conf does not match with what you have in vendor
    make: *** [dep-validate] Error 1

Rebasing on the lastest swarmkit master should fix this. It looks like the branch is based on an old version.

@abhi
Copy link
Contributor Author

abhi commented Aug 9, 2017

ping @aluzzardi @mavenugo

Currently ipam options doesnt seem to be passed to remote ipam
drivers. Remote ipam drivers that depend on any driver specific
options will not work if ipam options are not included in the
RequestAddress fromthe swarm manager to allocate IPs.
This is minor fix to pass the ipam options to ipam drivers.

Signed-off-by: Abhinandan Prativadi <[email protected]>
@abhi abhi force-pushed the ipam branch 4 times, most recently from 0a6e4f1 to 7d27468 Compare October 3, 2017 21:22
@abhi
Copy link
Contributor Author

abhi commented Oct 3, 2017

@nishanttotla This change is needed for the release. libnetwork part of the change is merged.

@abhi abhi force-pushed the ipam branch 2 times, most recently from ef820cc to 7d27468 Compare October 3, 2017 23:02
@marcusmartins
Copy link

cc @nishanttotla @dperny @anshulpundir for review.

@nishanttotla
Copy link
Contributor

Vendoring issue seems fixed now.

@nishanttotla
Copy link
Contributor

I'm not very well aware of this part of the codebase, but after reading the initial description and going through the code, it looks fine.

@@ -603,9 +604,16 @@ func (na *cnmNetworkAllocator) allocateVIP(vip *api.Endpoint_VirtualIP) error {
return err
}
}
if localNet.nw.IPAM != nil && localNet.nw.IPAM.Driver != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I request you to please add comments in the source ? Its probably obvious to those familiar with the code, but not so much for first time readers. Same comment for other changes also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

if opts == nil {
opts = make(map[string]string)
}
opts[ipamapi.AllocSerialPrefix] = "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check for the presence of this key and not override it if the user explicitly set it to false ?
Also, can you pls set this flag only for default ipam driver ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does apply to default ipam driver because of namespaced labels. I can add a check.

if opts == nil {
opts = make(map[string]string)
}
opts[ipamapi.AllocSerialPrefix] = "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above. optimize it into a function to avoid duplicated code ?

dOptions = make(map[string]string)
}
dOptions[ipamapi.RequestAddressType] = netlabel.Gateway
dOptions[ipamapi.AllocSerialPrefix] = "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment

@abhi abhi force-pushed the ipam branch 2 times, most recently from d53074a to d922486 Compare October 4, 2017 01:57
if opts == nil {
opts = make(map[string]string)
}
if _, ok := opts[ipamapi.AllocSerialPrefix]; !ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if the value in the map is set to "false"? Should we rename the function to make clear that it only sets serial allocation if no setting was already in place?

Also, IPAM in the funtion name should be IPAM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally I should have added a setter api in ipam libnetwork library. I missed that train. I can probably come back and make this better.

This commit contains fix to serialize IPAM and Port allocation.
This would fix transient issues seen due to immediate resource
release.

Signed-off-by: Abhinandan Prativadi <[email protected]>
@abhi
Copy link
Contributor Author

abhi commented Oct 4, 2017

Addressed comments. @nishanttotla @anshulpundir @marcusmartins @mavenugo PTAL.

Copy link
Contributor

@mavenugo mavenugo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@nishanttotla nishanttotla left a comment

Choose a reason for hiding this comment

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

LGTM

@nishanttotla nishanttotla merged commit 872861d into moby:master Oct 4, 2017
abhi added a commit to abhi/swarmkit that referenced this pull request Oct 4, 2017
Signed-off-by: Abhinandan Prativadi <[email protected]>
abhi added a commit to abhi/swarmkit that referenced this pull request Oct 4, 2017
Signed-off-by: Abhinandan Prativadi <[email protected]>
abhi added a commit to abhi/swarmkit that referenced this pull request Oct 5, 2017
Signed-off-by: Abhinandan Prativadi <[email protected]>
dperny added a commit that referenced this pull request Oct 5, 2017
Backport Adding ipam options to ipam driver requests #2324
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.

7 participants