diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-30 09:42:35 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-31 14:19:50 +0000 |
commit | 1db70cce344724e091635bc8c6fa6c207450df68 (patch) | |
tree | ed48df83141568bb949a8bdd5611cd20b3fa42c2 /libpod/container_linux.go | |
parent | cfcd92847684fc65949350b7cdc4769ad1099d46 (diff) | |
download | podman-1db70cce344724e091635bc8c6fa6c207450df68.tar.gz podman-1db70cce344724e091635bc8c6fa6c207450df68.tar.bz2 podman-1db70cce344724e091635bc8c6fa6c207450df68.zip |
Do not fetch pod and ctr State on retrieval in Bolt
It's not necessary to fill in state immediately, as we'll be
overwriting it on any API call accessing it thanks to
syncContainer(). It is also causing races when we fetch it
without holding the container lock (which syncContainer() does).
As such, just don't retrieve the state on initial pull from the
database with Bolt.
Also, refactor some Linux-specific netns handling functions out
of container_internal_linux.go into boltdb_linux.go.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #1186
Approved by: rhatdan
Diffstat (limited to 'libpod/container_linux.go')
-rw-r--r-- | libpod/container_linux.go | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/libpod/container_linux.go b/libpod/container_linux.go index 1b1b3a1d9..c445fb8af 100644 --- a/libpod/container_linux.go +++ b/libpod/container_linux.go @@ -4,52 +4,11 @@ package libpod import ( "github.com/containernetworking/plugins/pkg/ns" - "github.com/sirupsen/logrus" ) type containerPlatformState struct { - // NetNSPath is the path of the container's network namespace // Will only be set if config.CreateNetNS is true, or the container was // told to join another container's network namespace NetNS ns.NetNS `json:"-"` } - -func (ctr *Container) setNamespace(netNSPath string, newState *containerState) error { - if netNSPath != "" { - // Check if the container's old state has a good netns - if ctr.state.NetNS != nil && netNSPath == ctr.state.NetNS.Path() { - newState.NetNS = ctr.state.NetNS - } else { - // Close the existing namespace. - // Whoever removed it from the database already tore it down. - if err := ctr.runtime.closeNetNS(ctr); err != nil { - return err - } - - // Open the new network namespace - ns, err := joinNetNS(netNSPath) - if err == nil { - newState.NetNS = ns - } else { - logrus.Errorf("error joining network namespace for container %s", ctr.ID()) - ctr.valid = false - } - } - } else { - // The container no longer has a network namespace - // Close the old one, whoever removed it from the DB should have - // cleaned it up already. - if err := ctr.runtime.closeNetNS(ctr); err != nil { - return err - } - } - return nil -} - -func (ctr *Container) setNamespaceStatePath() string { - if ctr.state.NetNS != nil { - return ctr.state.NetNS.Path() - } - return "" -} |