-
Notifications
You must be signed in to change notification settings - Fork 621
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
Conversation
@@ -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 { | |||
|
There was a problem hiding this comment.
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
CI fails :
.vendor.bak/golang.org/x/text/unicode/norm/maketables.go |
92d66d1
to
a5797af
Compare
Codecov Report
@@ 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 |
Rebasing on the lastest swarmkit master should fix this. It looks like the branch is based on an old version. |
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 <abhi@docker.com>
0a6e4f1
to
7d27468
Compare
@nishanttotla This change is needed for the release. libnetwork part of the change is merged. |
ef820cc
to
7d27468
Compare
cc @nishanttotla @dperny @anshulpundir for review. |
Vendoring issue seems fixed now. |
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment
d53074a
to
d922486
Compare
if opts == nil { | ||
opts = make(map[string]string) | ||
} | ||
if _, ok := opts[ipamapi.AllocSerialPrefix]; !ok { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 <abhi@docker.com>
Addressed comments. @nishanttotla @anshulpundir @marcusmartins @mavenugo PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
Backport Adding ipam options to ipam driver requests #2324
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.
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 abhi@docker.com