pkg/ns: consider PROCFS during NS verification

This is an attempt to bring compatibility with Kernel <3.19, where NSFS
where PROCFS was used for network namespaces.
This commit is contained in:
Stefan Junker
2016-05-25 23:49:25 +02:00
parent 6fb30a6700
commit 3bab8a2805
2 changed files with 50 additions and 26 deletions

View File

@ -180,7 +180,9 @@ var _ = Describe("Linux namespace operations", func() {
defer os.Remove(nspath)
_, err = ns.GetNS(nspath)
Expect(err).To(MatchError(fmt.Sprintf("%v is not of type NSFS", nspath)))
Expect(err).To(HaveOccurred())
errString := fmt.Sprintf("%v", err)
Expect(errString).To(HavePrefix("no network namespace detected on %s", nspath))
})
})
@ -212,11 +214,12 @@ var _ = Describe("Linux namespace operations", func() {
})
})
Describe("IsNSFS", func() {
Describe("IsNS", func() {
It("should detect a namespace", func() {
createdNetNS, err := ns.NewNS()
isNSFS, err := ns.IsNSFS(createdNetNS.Path())
isNSFS, msg, err := ns.IsNS(createdNetNS.Path())
Expect(err).NotTo(HaveOccurred())
Expect(msg).To(Equal(""))
Expect(isNSFS).To(Equal(true))
})
@ -228,7 +231,7 @@ var _ = Describe("Linux namespace operations", func() {
nspath := tempFile.Name()
defer os.Remove(nspath)
isNSFS, err := ns.IsNSFS(nspath)
isNSFS, _, err := ns.IsNS(nspath)
Expect(err).NotTo(HaveOccurred())
Expect(isNSFS).To(Equal(false))
})