Merge pull request #407 from aaronlevy/del-err
plugins/meta/flannel: If net config is missing do not return err on DEL
This commit is contained in:
commit
699380d687
@ -142,6 +142,7 @@ func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {
|
|||||||
|
|
||||||
func consumeScratchNetConf(containerID, dataDir string) ([]byte, error) {
|
func consumeScratchNetConf(containerID, dataDir string) ([]byte, error) {
|
||||||
path := filepath.Join(dataDir, containerID)
|
path := filepath.Join(dataDir, containerID)
|
||||||
|
// Ignore errors when removing - Per spec safe to continue during DEL
|
||||||
defer os.Remove(path)
|
defer os.Remove(path)
|
||||||
|
|
||||||
return ioutil.ReadFile(path)
|
return ioutil.ReadFile(path)
|
||||||
@ -245,6 +246,10 @@ func cmdDel(args *skel.CmdArgs) error {
|
|||||||
|
|
||||||
netconfBytes, err := consumeScratchNetConf(args.ContainerID, nc.DataDir)
|
netconfBytes, err := consumeScratchNetConf(args.ContainerID, nc.DataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// Per spec should ignore error if resources are missing / already removed
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,14 @@ FLANNEL_IPMASQ=true
|
|||||||
|
|
||||||
By("check that plugin removes net config from state dir")
|
By("check that plugin removes net config from state dir")
|
||||||
Expect(path).ShouldNot(BeAnExistingFile())
|
Expect(path).ShouldNot(BeAnExistingFile())
|
||||||
|
|
||||||
|
By("calling DEL again")
|
||||||
|
err = testutils.CmdDelWithResult(targetNs.Path(), IFNAME, func() error {
|
||||||
|
return cmdDel(args)
|
||||||
|
})
|
||||||
|
By("check that plugin does not fail due to missing net config")
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user