safely handle existing net namespace in default network manager #9757
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9750. A similar problem was fixed for the Docker driver in 0.10.0 with #6315 but it looks like we missed the
exec
driver and other non-Docker drivers that support network isolation.When a client restarts, the network_hook's prerun will call
CreateNetwork
. Drivers that don't implement their own network manager willfall back to the default network manager, which doesn't handle the case where
the network namespace is being recreated safely. This results in an error and
the task being restarted for
exec
tasks withnetwork
blocks (this alsoimpacts the community
containerd
and probably other community task drivers).If we get an error when attempting to create the namespace and that error is
because the file already exists and is locked by its process, then we'll
return a
nil
error with thecreated
flag set to false, just as we do withthe
docker
driver.