feat(network): support --aux-address on network create#5041
feat(network): support --aux-address on network create#5041mayur-tolexo wants to merge 1 commit into
Conversation
08a26ea to
d6ab811
Compare
|
Checked Docker: nerdctl with this PR: host-local has no exclude list, so the reservation is enforced by splitting the range around each reserved IP; those addresses are then never handed out. With |
96aef29 to
8400fe2
Compare
|
cc @AkihiroSuda — rebased on latest main and green, could you take a look when you get a chance? |
| // host-local does not read it (reservation is done by splitting the range | ||
| // around each IP); it is nerdctl bookkeeping so `network inspect` can | ||
| // report AuxiliaryAddresses the way Docker does. | ||
| AuxiliaryAddresses map[string]string `json:"auxiliaryAddresses,omitempty"` |
There was a problem hiding this comment.
Doesn't seem implemented in CNI
https://github.com/containernetworking/plugins/blob/v1.9.1/plugins/ipam/host-local/backend/allocator/config.go#L68
nerdctl-specific information could be stored in NerdctlLabels
https://github.com/search?q=repo%3Acontainerd%2Fnerdctl+NerdctlLabels&type=code
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks, that makes sense — I will move it out of the ipam range entirely.
Plan before I rework the PR: keep the reservation exactly as is (host-local still enforced by splitting the range around each reserved IP), and store only the name→IP pairs in a nerdctl label instead of the CNI config. Concretely a single nerdctl/network-aux-addresses label holding a JSON {subnet: {name: ip}} map, so dual-stack keeps each aux on the right subnet. network inspect decodes that label to populate AuxiliaryAddresses as before, and I would hide the internal label from the user-facing Labels so it does not surface as a user label.
Does that match what you had in mind with NerdctlLabels? And do you prefer one grouped label like above, or a flatter key?
Separately, I will send the ipRange case (#5068) as its own PR since it is derivable from rangeStart/rangeEnd and needs no storage.
There was a problem hiding this comment.
Thanks, JSON label sounds good (unless it grows too much to hit the length limit)
There was a problem hiding this comment.
Went ahead and pushed the rework along these lines. auxiliaryAddresses is gone from the ipam range entirely — the reserved pairs now live in a nerdctl/network-aux-addresses label as {subnet: {name: ip}}, and network inspect decodes that to populate AuxiliaryAddresses (and keeps the internal label out of the user-facing Labels). The reservation itself is unchanged, still done by splitting the host-local range around each reserved IP.
Happy to switch to a flatter key or rename if you would prefer something else.
Docker's network create reserves auxiliary addresses so IPAM never hands them out to containers. nerdctl had no equivalent. host-local has no exclude list, but it allocates across every range in a set, so each reserved IP is carved out by splitting the subnet range around it. The reserved name=IP pairs are matched to the subnet that contains them (so dual-stack picks the right family), rejected when they hit the network or gateway address or fall outside every subnet, and recorded so network inspect reports AuxiliaryAddresses the same way Docker does. Signed-off-by: Mayur Das <mayur.das@neevcloud.com>
8400fe2 to
cf8dd79
Compare
|
Built this branch and ran it end to end against Docker 29.4.0 (nerdctl on containerd 1.7.24). Nothing nerdctl-specific ends up in the CNI config anymore — the reserved pairs are in a nerdctl label and the ranges only carry host-local's own fields: (host1=.5 and host2=.6 both carved out — the range gaps at .5/.6.)
Docker 29.4.0 for the same thing: The reservation still holds — requesting a reserved address fails at IPAM: Dual-stack keeps each family on its own subnet, in both the inspect output and the label: vs docker: And the rejections still line up with docker: |
Part of #5012.
Docker's network create reserves auxiliary addresses so IPAM never hands them out to containers. nerdctl had no equivalent.
host-local has no exclude list, but it allocates across every range in a set, so each reserved IP is carved out by splitting the subnet range around it. The reserved name=IP pairs are matched to the subnet that contains them (so dual-stack picks the right family), rejected when they hit the network or gateway address or fall outside every subnet, and recorded so network inspect reports AuxiliaryAddresses the same way Docker does.