ipvlan: support enslaving an interface returned by ipam

For IP allocation schemes that cannot be interface agnostic, master can be set
to "ipam". In this configuration, the IPAM plugin is required to return a single
interface name for the ipvlan plugin to enslave.
This commit is contained in:
Paul Fisher
2017-11-01 10:14:04 -07:00
parent 7f98c94613
commit 4779f1d2bf
3 changed files with 53 additions and 6 deletions

View File

@ -224,4 +224,40 @@ var _ = Describe("ipvlan Operations", func() {
})
Expect(err).NotTo(HaveOccurred())
})
It("errors if master should originate from ipam but an ipam interface is not returned", func() {
const IFNAME = "ipvl0"
conf := `{
"cniVersion": "0.3.1",
"name": "mynet",
"type": "ipvlan",
"master": "ipam",
"ipam": {
"type": "host-local",
"subnet": "10.1.2.0/24"
}
}`
targetNs, err := ns.NewNS()
Expect(err).NotTo(HaveOccurred())
defer targetNs.Close()
args := &skel.CmdArgs{
ContainerID: "dummy",
Netns: targetNs.Path(),
IfName: IFNAME,
StdinData: []byte(conf),
}
err = originalNS.Do(func(ns.NetNS) error {
defer GinkgoRecover()
_, _, err := testutils.CmdAddWithResult(targetNs.Path(), IFNAME, []byte(conf), func() error {
return cmdAdd(args)
})
Expect(err.Error()).To(Equal("IPAM plugin returned missing master interface"))
return nil
})
Expect(err).NotTo(HaveOccurred())
})
})