Skip to content

Commit

Permalink
Merge pull request containers#65 from Luap99/remove-dangling
Browse files Browse the repository at this point in the history
Cleanup dangling config files
  • Loading branch information
openshift-merge-robot authored May 3, 2021
2 parents e9ce42b + 4be2972 commit 43a45e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions plugins/meta/dnsname/dnsname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,14 @@ var _ = Describe("dnsname tests", func() {

Expect(dnsDead).To(BeTrue())

// Cleanup behind ourselves
Expect(cleanup(d)).To(BeNil())
// defer cleanup is case it does not work automatically
defer func() {
_ = cleanup(d)
}()

// Check that the configuration directory is deleted
_, err = ioutil.ReadDir("/run/containers/cni/dnsname/test")
Expect(os.IsNotExist(err)).To(BeTrue())
return nil
})
Expect(err).NotTo(HaveOccurred())
Expand Down
7 changes: 6 additions & 1 deletion plugins/meta/dnsname/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ func cmdDel(args *skel.CmdArgs) error {
if !shouldHUP {
// if there are no hosts, we should just stop the dnsmasq instance to not take
// system resources
return dnsNameConf.stop()
err = dnsNameConf.stop()
if err != nil {
return err
}
// remove the config directory
return os.RemoveAll(domainBaseDir)
}
// Now we need to HUP
return dnsNameConf.hup()
Expand Down

0 comments on commit 43a45e5

Please sign in to comment.