summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go4
-rw-r--r--libpod/container_internal.go5
-rw-r--r--libpod/events.go13
-rw-r--r--libpod/events/events.go2
-rw-r--r--libpod/networking_linux.go4
-rw-r--r--libpod/oci.go2
-rw-r--r--libpod/runtime_volume_unsupported.go2
7 files changed, 25 insertions, 7 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 3698a15ec..96435c2ff 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -14,7 +14,7 @@ import (
"github.com/containers/libpod/pkg/inspect"
"github.com/containers/libpod/pkg/lookup"
"github.com/containers/storage/pkg/stringid"
- "github.com/docker/docker/daemon/caps"
+ "github.com/docker/docker/oci/caps"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -89,7 +89,6 @@ func (c *Container) Start(ctx context.Context, recursive bool) (err error) {
}
// Start the container
- defer c.newContainerEvent(events.Start)
return c.start()
}
@@ -127,7 +126,6 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *AttachStreams,
}
close(attachChan)
}()
- c.newContainerEvent(events.Start)
c.newContainerEvent(events.Attach)
return attachChan, nil
}
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 330745314..bea7acd69 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -211,6 +211,9 @@ func (c *Container) handleExitFile(exitFile string, fi os.FileInfo) error {
c.state.Exited = true
+ // Write an event for the container's death
+ c.newContainerExitedEvent(c.state.ExitCode)
+
return nil
}
@@ -948,6 +951,8 @@ func (c *Container) start() error {
c.state.State = ContainerStateRunning
+ defer c.newContainerEvent(events.Start)
+
return c.save()
}
diff --git a/libpod/events.go b/libpod/events.go
index 9806c117b..879aeb6c5 100644
--- a/libpod/events.go
+++ b/libpod/events.go
@@ -19,6 +19,19 @@ func (c *Container) newContainerEvent(status events.Status) {
}
}
+// newContainerExitedEvent creates a new event for a container's death
+func (c *Container) newContainerExitedEvent(exitCode int32) {
+ e := events.NewEvent(events.Exited)
+ e.ID = c.ID()
+ e.Name = c.Name()
+ e.Image = c.config.RootfsImageName
+ e.Type = events.Container
+ e.ContainerExitCode = int(exitCode)
+ if err := e.Write(c.runtime.config.EventsLogFilePath); err != nil {
+ logrus.Errorf("unable to write event to %s", c.runtime.config.EventsLogFilePath)
+ }
+}
+
// newPodEvent creates a new event for a libpod pod
func (p *Pod) newPodEvent(status events.Status) {
e := events.NewEvent(status)
diff --git a/libpod/events/events.go b/libpod/events/events.go
index 186790500..48bbbb00e 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -60,6 +60,8 @@ const (
Create Status = "create"
// Exec ...
Exec Status = "exec"
+ // Exited indicates that a container's process died
+ Exited Status = "died"
// Export ...
Export Status = "export"
// History ...
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 80d7d8213..809584804 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -162,9 +162,9 @@ func (r *Runtime) setupRootlessNetNS(ctr *Container) (err error) {
var cmd *exec.Cmd
if havePortMapping {
// if we need ports to be mapped from the host, create a API socket to use for communicating with slirp4netns.
- cmd = exec.Command(path, "-c", "-e", "3", "-r", "4", "--api-socket", apiSocket, fmt.Sprintf("%d", ctr.state.PID), "tap0")
+ cmd = exec.Command(path, "--disable-host-loopback", "--mtu", "65520", "-c", "-e", "3", "-r", "4", "--api-socket", apiSocket, fmt.Sprintf("%d", ctr.state.PID), "tap0")
} else {
- cmd = exec.Command(path, "-c", "-e", "3", "-r", "4", fmt.Sprintf("%d", ctr.state.PID), "tap0")
+ cmd = exec.Command(path, "--disable-host-loopback", "--mtu", "65520", "-c", "-e", "3", "-r", "4", fmt.Sprintf("%d", ctr.state.PID), "tap0")
}
cmd.SysProcAttr = &syscall.SysProcAttr{
diff --git a/libpod/oci.go b/libpod/oci.go
index c3b5f9af2..30360d289 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -477,7 +477,7 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container, useRunc bool) error {
// If not using runc, we don't need to do most of this.
if !useRunc {
// If the container's not running, nothing to do.
- if ctr.state.State != ContainerStateRunning {
+ if ctr.state.State != ContainerStateRunning && ctr.state.State != ContainerStatePaused {
return nil
}
diff --git a/libpod/runtime_volume_unsupported.go b/libpod/runtime_volume_unsupported.go
index d87459759..5fe487114 100644
--- a/libpod/runtime_volume_unsupported.go
+++ b/libpod/runtime_volume_unsupported.go
@@ -6,7 +6,7 @@ import (
"context"
)
-func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force, prune bool) error {
+func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool) error {
return ErrNotImplemented
}