diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_exec.go | 10 | ||||
-rw-r--r-- | libpod/networking_linux.go | 33 | ||||
-rw-r--r-- | libpod/oci_conmon_linux.go | 1 | ||||
-rw-r--r-- | libpod/runtime_volume.go | 16 |
4 files changed, 37 insertions, 23 deletions
diff --git a/libpod/container_exec.go b/libpod/container_exec.go index 912c2c226..5469462f8 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -532,7 +532,7 @@ func (c *Container) ExecResize(sessionID string, newSize remotecommand.TerminalS return errors.Wrapf(define.ErrNoSuchExecSession, "container %s has no exec session with ID %s", c.ID(), sessionID) } - logrus.Infof("Removing container %s exec session %s", c.ID(), session.ID()) + logrus.Infof("Resizing container %s exec session %s to %+v", c.ID(), session.ID(), newSize) if session.State != define.ExecStateRunning { return errors.Wrapf(define.ErrExecSessionStateInvalid, "cannot resize container %s exec session %s as it is not running", c.ID(), session.ID()) @@ -549,9 +549,6 @@ func (c *Container) Exec(config *ExecConfig, streams *AttachStreams, resize <-ch if err != nil { return -1, err } - if err := c.ExecStartAndAttach(sessionID, streams); err != nil { - return -1, err - } // Start resizing if we have a resize channel. // This goroutine may likely leak, given that we cannot close it here. @@ -562,6 +559,7 @@ func (c *Container) Exec(config *ExecConfig, streams *AttachStreams, resize <-ch // session. if resize != nil { go func() { + logrus.Debugf("Sending resize events to exec session %s", sessionID) for resizeRequest := range resize { if err := c.ExecResize(sessionID, resizeRequest); err != nil { // Assume the exec session went down. @@ -572,6 +570,10 @@ func (c *Container) Exec(config *ExecConfig, streams *AttachStreams, resize <-ch }() } + if err := c.ExecStartAndAttach(sessionID, streams); err != nil { + return -1, err + } + session, err := c.ExecSession(sessionID) if err != nil { return -1, err diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index f1bf79ce7..a7f501bfe 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -154,13 +154,25 @@ func (r *Runtime) createNetNS(ctr *Container) (n ns.NetNS, q []*cnitypes.Result, return ctrNS, networkStatus, err } -func checkSlirpFlags(path string) (bool, bool, bool, error) { +type slirpFeatures struct { + HasDisableHostLoopback bool + HasMTU bool + HasEnableSandbox bool + HasEnableSeccomp bool +} + +func checkSlirpFlags(path string) (*slirpFeatures, error) { cmd := exec.Command(path, "--help") out, err := cmd.CombinedOutput() if err != nil { - return false, false, false, errors.Wrapf(err, "slirp4netns %q", out) - } - return strings.Contains(string(out), "--disable-host-loopback"), strings.Contains(string(out), "--mtu"), strings.Contains(string(out), "--enable-sandbox"), nil + return nil, errors.Wrapf(err, "slirp4netns %q", out) + } + return &slirpFeatures{ + HasDisableHostLoopback: strings.Contains(string(out), "--disable-host-loopback"), + HasMTU: strings.Contains(string(out), "--mtu"), + HasEnableSandbox: strings.Contains(string(out), "--enable-sandbox"), + HasEnableSeccomp: strings.Contains(string(out), "--enable-seccomp"), + }, nil } // Configure the network namespace for a rootless container @@ -187,19 +199,22 @@ func (r *Runtime) setupRootlessNetNS(ctr *Container) (err error) { logPath := filepath.Join(ctr.runtime.config.TmpDir, fmt.Sprintf("slirp4netns-%s.log", ctr.config.ID)) cmdArgs := []string{} - dhp, mtu, sandbox, err := checkSlirpFlags(path) + slirpFeatures, err := checkSlirpFlags(path) if err != nil { return errors.Wrapf(err, "error checking slirp4netns binary %s: %q", path, err) } - if dhp { + if slirpFeatures.HasDisableHostLoopback { cmdArgs = append(cmdArgs, "--disable-host-loopback") } - if mtu { + if slirpFeatures.HasMTU { cmdArgs = append(cmdArgs, "--mtu", "65520") } - if sandbox { + if slirpFeatures.HasEnableSandbox { cmdArgs = append(cmdArgs, "--enable-sandbox") } + if slirpFeatures.HasEnableSeccomp { + cmdArgs = append(cmdArgs, "--enable-seccomp") + } // the slirp4netns arguments being passed are describes as follows: // from the slirp4netns documentation: https://github.com/rootless-containers/slirp4netns @@ -230,7 +245,7 @@ func (r *Runtime) setupRootlessNetNS(ctr *Container) (err error) { } // workaround for https://github.com/rootless-containers/slirp4netns/pull/153 - if sandbox { + if slirpFeatures.HasEnableSandbox { cmd.SysProcAttr.Cloneflags = syscall.CLONE_NEWNS cmd.SysProcAttr.Unshareflags = syscall.CLONE_NEWNS } diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 82c5d7020..6d9a976cb 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -793,7 +793,6 @@ func (r *ConmonOCIRuntime) ExecAttachResize(ctr *Container, sessionID string, ne } defer controlFile.Close() - logrus.Debugf("Received a resize event for container %s exec session %s: %+v", ctr.ID(), sessionID, newSize) if _, err = fmt.Fprintf(controlFile, "%d %d %d\n", 1, newSize.Height, newSize.Width); err != nil { return errors.Wrapf(err, "failed to write to ctl file to resize terminal") } diff --git a/libpod/runtime_volume.go b/libpod/runtime_volume.go index efc3c5bd9..d522ffb6c 100644 --- a/libpod/runtime_volume.go +++ b/libpod/runtime_volume.go @@ -5,6 +5,7 @@ import ( "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/events" + "github.com/containers/libpod/pkg/domain/entities" "github.com/pkg/errors" ) @@ -35,7 +36,6 @@ func (r *Runtime) RemoveVolume(ctx context.Context, v *Volume, force bool) error return nil } } - return r.removeVolume(ctx, v, force) } @@ -130,26 +130,24 @@ func (r *Runtime) GetAllVolumes() ([]*Volume, error) { } // PruneVolumes removes unused volumes from the system -func (r *Runtime) PruneVolumes(ctx context.Context) ([]string, []error) { +func (r *Runtime) PruneVolumes(ctx context.Context) ([]*entities.VolumePruneReport, error) { var ( - prunedIDs []string - pruneErrors []error + reports []*entities.VolumePruneReport ) vols, err := r.GetAllVolumes() if err != nil { - pruneErrors = append(pruneErrors, err) - return nil, pruneErrors + return nil, err } for _, vol := range vols { if err := r.RemoveVolume(ctx, vol, false); err != nil { if errors.Cause(err) != define.ErrVolumeBeingUsed && errors.Cause(err) != define.ErrVolumeRemoved { - pruneErrors = append(pruneErrors, err) + reports = append(reports, &entities.VolumePruneReport{Id: vol.Name(), Err: err}) } continue } vol.newVolumeEvent(events.Prune) - prunedIDs = append(prunedIDs, vol.Name()) + reports = append(reports, &entities.VolumePruneReport{Id: vol.Name()}) } - return prunedIDs, pruneErrors + return reports, nil } |