mirror of https://github.com/containers/podman.git
Change container.locked to batched
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com> Closes: #619 Approved by: mheon
This commit is contained in:
parent
fa8442e4a0
commit
6c5ebb0315
|
|
@ -96,10 +96,10 @@ type Container struct {
|
||||||
|
|
||||||
state *containerState
|
state *containerState
|
||||||
|
|
||||||
// Locked indicates that a container has been locked as part of a
|
// Batched indicates that a container has been locked as part of a
|
||||||
// Batch() operation
|
// Batch() operation
|
||||||
// Functions called on a locked container will not lock or sync
|
// Functions called on a batched container will not lock or sync
|
||||||
locked bool
|
batched bool
|
||||||
|
|
||||||
valid bool
|
valid bool
|
||||||
lock storage.Locker
|
lock storage.Locker
|
||||||
|
|
@ -521,7 +521,7 @@ func (c *Container) Hostname() string {
|
||||||
|
|
||||||
// State returns the current state of the container
|
// State returns the current state of the container
|
||||||
func (c *Container) State() (ContainerStatus, error) {
|
func (c *Container) State() (ContainerStatus, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -535,7 +535,7 @@ func (c *Container) State() (ContainerStatus, error) {
|
||||||
// Mounted returns a bool as to if the container's storage
|
// Mounted returns a bool as to if the container's storage
|
||||||
// is mounted
|
// is mounted
|
||||||
func (c *Container) Mounted() (bool, error) {
|
func (c *Container) Mounted() (bool, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -549,7 +549,7 @@ func (c *Container) Mounted() (bool, error) {
|
||||||
// If the container is not mounted, no error is returned, but the mountpoint
|
// If the container is not mounted, no error is returned, but the mountpoint
|
||||||
// will be ""
|
// will be ""
|
||||||
func (c *Container) Mountpoint() (string, error) {
|
func (c *Container) Mountpoint() (string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -561,7 +561,7 @@ func (c *Container) Mountpoint() (string, error) {
|
||||||
|
|
||||||
// StartedTime is the time the container was started
|
// StartedTime is the time the container was started
|
||||||
func (c *Container) StartedTime() (time.Time, error) {
|
func (c *Container) StartedTime() (time.Time, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -573,7 +573,7 @@ func (c *Container) StartedTime() (time.Time, error) {
|
||||||
|
|
||||||
// FinishedTime is the time the container was stopped
|
// FinishedTime is the time the container was stopped
|
||||||
func (c *Container) FinishedTime() (time.Time, error) {
|
func (c *Container) FinishedTime() (time.Time, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -586,7 +586,7 @@ func (c *Container) FinishedTime() (time.Time, error) {
|
||||||
// ExitCode returns the exit code of the container as
|
// ExitCode returns the exit code of the container as
|
||||||
// an int32
|
// an int32
|
||||||
func (c *Container) ExitCode() (int32, error) {
|
func (c *Container) ExitCode() (int32, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -598,7 +598,7 @@ func (c *Container) ExitCode() (int32, error) {
|
||||||
|
|
||||||
// OOMKilled returns whether the container was killed by an OOM condition
|
// OOMKilled returns whether the container was killed by an OOM condition
|
||||||
func (c *Container) OOMKilled() (bool, error) {
|
func (c *Container) OOMKilled() (bool, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -612,7 +612,7 @@ func (c *Container) OOMKilled() (bool, error) {
|
||||||
// If the container is not running, a pid of 0 will be returned. No error will
|
// If the container is not running, a pid of 0 will be returned. No error will
|
||||||
// occur.
|
// occur.
|
||||||
func (c *Container) PID() (int, error) {
|
func (c *Container) PID() (int, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -626,7 +626,7 @@ func (c *Container) PID() (int, error) {
|
||||||
|
|
||||||
// ExecSessions retrieves active exec sessions running in the container
|
// ExecSessions retrieves active exec sessions running in the container
|
||||||
func (c *Container) ExecSessions() ([]string, error) {
|
func (c *Container) ExecSessions() ([]string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -646,7 +646,7 @@ func (c *Container) ExecSessions() ([]string, error) {
|
||||||
// ExecSession retrieves detailed information on a single active exec session in
|
// ExecSession retrieves detailed information on a single active exec session in
|
||||||
// a container
|
// a container
|
||||||
func (c *Container) ExecSession(id string) (*ExecSession, error) {
|
func (c *Container) ExecSession(id string) (*ExecSession, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -672,7 +672,7 @@ func (c *Container) ExecSession(id string) (*ExecSession, error) {
|
||||||
// This will only be populated if the container is configured to created a new
|
// This will only be populated if the container is configured to created a new
|
||||||
// network namespace, and that namespace is presently active
|
// network namespace, and that namespace is presently active
|
||||||
func (c *Container) IPs() ([]net.IPNet, error) {
|
func (c *Container) IPs() ([]net.IPNet, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -698,7 +698,7 @@ func (c *Container) IPs() ([]net.IPNet, error) {
|
||||||
// This will only be populated if the container is configured to created a new
|
// This will only be populated if the container is configured to created a new
|
||||||
// network namespace, and that namespace is presently active
|
// network namespace, and that namespace is presently active
|
||||||
func (c *Container) Routes() ([]types.Route, error) {
|
func (c *Container) Routes() ([]types.Route, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -736,7 +736,7 @@ func (c *Container) Routes() ([]types.Route, error) {
|
||||||
// If the container has not been started yet, an empty map will be returned, as
|
// If the container has not been started yet, an empty map will be returned, as
|
||||||
// the files in question are only created when the container is started.
|
// the files in question are only created when the container is started.
|
||||||
func (c *Container) BindMounts() (map[string]string, error) {
|
func (c *Container) BindMounts() (map[string]string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -760,7 +760,7 @@ func (c *Container) BindMounts() (map[string]string, error) {
|
||||||
// NamespacePath returns the path of one of the container's namespaces
|
// NamespacePath returns the path of one of the container's namespaces
|
||||||
// If the container is not running, an error will be returned
|
// If the container is not running, an error will be returned
|
||||||
func (c *Container) NamespacePath(ns LinuxNS) (string, error) {
|
func (c *Container) NamespacePath(ns LinuxNS) (string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -786,7 +786,7 @@ func (c *Container) CGroupPath() cgroups.Path {
|
||||||
|
|
||||||
// RootFsSize returns the root FS size of the container
|
// RootFsSize returns the root FS size of the container
|
||||||
func (c *Container) RootFsSize() (int64, error) {
|
func (c *Container) RootFsSize() (int64, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -798,7 +798,7 @@ func (c *Container) RootFsSize() (int64, error) {
|
||||||
|
|
||||||
// RWSize returns the rw size of the container
|
// RWSize returns the rw size of the container
|
||||||
func (c *Container) RWSize() (int64, error) {
|
func (c *Container) RWSize() (int64, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
// Init creates a container in the OCI runtime
|
// Init creates a container in the OCI runtime
|
||||||
func (c *Container) Init() (err error) {
|
func (c *Container) Init() (err error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (c *Container) Init() (err error) {
|
||||||
// Stopped containers will be deleted and re-created in runc, undergoing a fresh
|
// Stopped containers will be deleted and re-created in runc, undergoing a fresh
|
||||||
// Init()
|
// Init()
|
||||||
func (c *Container) Start() (err error) {
|
func (c *Container) Start() (err error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ func (c *Container) Start() (err error) {
|
||||||
// The channel will be closed automatically after the result of attach has been
|
// The channel will be closed automatically after the result of attach has been
|
||||||
// sent
|
// sent
|
||||||
func (c *Container) StartAndAttach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) (attachResChan <-chan error, err error) {
|
func (c *Container) StartAndAttach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) (attachResChan <-chan error, err error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ func (c *Container) StartAndAttach(streams *AttachStreams, keys string, resize <
|
||||||
// Default stop timeout is 10 seconds, but can be overridden when the container
|
// Default stop timeout is 10 seconds, but can be overridden when the container
|
||||||
// is created
|
// is created
|
||||||
func (c *Container) Stop() error {
|
func (c *Container) Stop() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -224,7 +224,7 @@ func (c *Container) Stop() error {
|
||||||
// manually. If timeout is 0, SIGKILL will be used immediately to kill the
|
// manually. If timeout is 0, SIGKILL will be used immediately to kill the
|
||||||
// container.
|
// container.
|
||||||
func (c *Container) StopWithTimeout(timeout uint) error {
|
func (c *Container) StopWithTimeout(timeout uint) error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ func (c *Container) StopWithTimeout(timeout uint) error {
|
||||||
|
|
||||||
// Kill sends a signal to a container
|
// Kill sends a signal to a container
|
||||||
func (c *Container) Kill(signal uint) error {
|
func (c *Container) Kill(signal uint) error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -271,7 +271,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
var capList []string
|
var capList []string
|
||||||
|
|
||||||
locked := false
|
locked := false
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
locked = true
|
locked = true
|
||||||
|
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
|
|
@ -377,7 +377,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
logrus.Debugf("Successfully started exec session %s in container %s", sessionID, c.ID())
|
logrus.Debugf("Successfully started exec session %s in container %s", sessionID, c.ID())
|
||||||
|
|
||||||
// Unlock so other processes can use the container
|
// Unlock so other processes can use the container
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
locked = false
|
locked = false
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
waitErr := execCmd.Wait()
|
waitErr := execCmd.Wait()
|
||||||
|
|
||||||
// Lock again
|
// Lock again
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
locked = true
|
locked = true
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
}
|
}
|
||||||
|
|
@ -406,7 +406,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
|
|
||||||
// Attach attaches to a container
|
// Attach attaches to a container
|
||||||
func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) error {
|
func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
|
|
@ -426,7 +426,7 @@ func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan re
|
||||||
// Mount mounts a container's filesystem on the host
|
// Mount mounts a container's filesystem on the host
|
||||||
// The path where the container has been mounted is returned
|
// The path where the container has been mounted is returned
|
||||||
func (c *Container) Mount() (string, error) {
|
func (c *Container) Mount() (string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -444,7 +444,7 @@ func (c *Container) Mount() (string, error) {
|
||||||
|
|
||||||
// Unmount unmounts a container's filesystem on the host
|
// Unmount unmounts a container's filesystem on the host
|
||||||
func (c *Container) Unmount() error {
|
func (c *Container) Unmount() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -467,7 +467,7 @@ func (c *Container) Unmount() error {
|
||||||
|
|
||||||
// Pause pauses a container
|
// Pause pauses a container
|
||||||
func (c *Container) Pause() error {
|
func (c *Container) Pause() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ func (c *Container) Pause() error {
|
||||||
|
|
||||||
// Unpause unpauses a container
|
// Unpause unpauses a container
|
||||||
func (c *Container) Unpause() error {
|
func (c *Container) Unpause() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -521,7 +521,7 @@ func (c *Container) Unpause() error {
|
||||||
// Export exports a container's root filesystem as a tar archive
|
// Export exports a container's root filesystem as a tar archive
|
||||||
// The archive will be saved as a file at the given path
|
// The archive will be saved as a file at the given path
|
||||||
func (c *Container) Export(path string) error {
|
func (c *Container) Export(path string) error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -562,7 +562,7 @@ func (c *Container) RemoveArtifact(name string) error {
|
||||||
|
|
||||||
// Inspect a container for low-level information
|
// Inspect a container for low-level information
|
||||||
func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) {
|
func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
@ -615,7 +615,7 @@ func (c *Container) Wait() (int32, error) {
|
||||||
// Cleanup unmounts all mount points in container and cleans up container storage
|
// Cleanup unmounts all mount points in container and cleans up container storage
|
||||||
// It also cleans up the network stack
|
// It also cleans up the network stack
|
||||||
func (c *Container) Cleanup() error {
|
func (c *Container) Cleanup() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -664,13 +664,13 @@ func (c *Container) Batch(batchFunc func(*Container) error) error {
|
||||||
newCtr.lock = c.lock
|
newCtr.lock = c.lock
|
||||||
newCtr.valid = true
|
newCtr.valid = true
|
||||||
|
|
||||||
newCtr.locked = true
|
newCtr.batched = true
|
||||||
|
|
||||||
if err := batchFunc(newCtr); err != nil {
|
if err := batchFunc(newCtr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newCtr.locked = false
|
newCtr.batched = false
|
||||||
|
|
||||||
return c.save()
|
return c.save()
|
||||||
}
|
}
|
||||||
|
|
@ -681,7 +681,7 @@ func (c *Container) Batch(batchFunc func(*Container) error) error {
|
||||||
// automatically.
|
// automatically.
|
||||||
// When called outside Batch(), Sync() is a no-op
|
// When called outside Batch(), Sync() is a no-op
|
||||||
func (c *Container) Sync() error {
|
func (c *Container) Sync() error {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ type ContainerCommitOptions struct {
|
||||||
// Commit commits the changes between a container and its image, creating a new
|
// Commit commits the changes between a container and its image, creating a new
|
||||||
// image
|
// image
|
||||||
func (c *Container) Commit(destImage string, options ContainerCommitOptions) (*image.Image, error) {
|
func (c *Container) Commit(destImage string, options ContainerCommitOptions) (*image.Image, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ func (c *Container) getArtifactPath(name string) string {
|
||||||
|
|
||||||
// Used with Wait() to determine if a container has exited
|
// Used with Wait() to determine if a container has exited
|
||||||
func (c *Container) isStopped() (bool, error) {
|
func (c *Container) isStopped() (bool, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
// GetContainerPids reads sysfs to obtain the pids associated with the container's cgroup
|
// GetContainerPids reads sysfs to obtain the pids associated with the container's cgroup
|
||||||
// and uses locking
|
// and uses locking
|
||||||
func (c *Container) GetContainerPids() ([]string, error) {
|
func (c *Container) GetContainerPids() ([]string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
@ -41,7 +41,7 @@ func (c *Container) getContainerPids() ([]string, error) {
|
||||||
// GetContainerPidInformation calls ps with the appropriate options and returns
|
// GetContainerPidInformation calls ps with the appropriate options and returns
|
||||||
// the results as a string and the container's PIDs as a []string
|
// the results as a string and the container's PIDs as a []string
|
||||||
func (c *Container) GetContainerPidInformation(args []string) ([]string, error) {
|
func (c *Container) GetContainerPidInformation(args []string) ([]string, error) {
|
||||||
if !c.locked {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
if err := c.syncContainer(); err != nil {
|
if err := c.syncContainer(); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue