Fix vlan plugin returning error when device is already removed
DEL can be called multiple times, a plugin should return no error if the device is already removed, and other errors should be returned. It was the opposite for vlan plugin. This PR fixes it. Signed-off-by: Quan Tian <qtian@vmware.com>
This commit is contained in:
parent
62b36d2fbc
commit
db7e6cfabf
@ -207,7 +207,7 @@ func cmdDel(args *skel.CmdArgs) error {
|
||||
|
||||
err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error {
|
||||
err = ip.DelLinkByName(args.IfName)
|
||||
if err != nil && err != ip.ErrLinkNotFound {
|
||||
if err != nil && err == ip.ErrLinkNotFound {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
@ -292,6 +292,19 @@ var _ = Describe("vlan Operations", func() {
|
||||
return nil
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
// DEL can be called multiple times, make sure no error is returned
|
||||
// if the device is already removed.
|
||||
err = originalNS.Do(func(ns.NetNS) error {
|
||||
defer GinkgoRecover()
|
||||
|
||||
err = testutils.CmdDelWithArgs(args, func() error {
|
||||
return cmdDel(args)
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
return nil
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("configures and deconfigures an CNI V4 vlan link with ADD/CHECK/DEL", func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user