Comment 6 for bug 1664294

Revision history for this message
Kevin Benton (kevinbenton) wrote :

@tuhv,

Can we add a context manager that does the following?

On entrance, set the namespace to whatever it needs to be.
On exit, set the namespace back to root with pyroute2.netns.setns('/proc/1/ns/net')
If it fails to set the namespace back to root, completely kill the process with an ugly error.

Then anything that needs to be performed in a namespace will be executed inside a context manager. That will let us easily reason about when a process is in a particular namespace.