diff options
33 files changed, 232 insertions, 201 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go index 8ea9e6957..cfeabfb4e 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -53,7 +53,7 @@ func init() { flags.SetInterspersed(false) budFlags := buildahcli.GetBudFlags(&budFlagsValues) - flag := budFlags.Lookup("pull-always") + flag := budFlags.Lookup("pull") flag.Value.Set("true") flag.DefValue = "true" layerFlags := buildahcli.GetLayerFlags(&layerValues) diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go index fd36e77d5..2f9a9cfe2 100644 --- a/cmd/podman/commands.go +++ b/cmd/podman/commands.go @@ -18,7 +18,7 @@ func getMainCommands() []*cobra.Command { _execCommand, _generateCommand, _playCommand, - _psCommand, + &_psCommand, _loginCommand, _logoutCommand, _logsCommand, @@ -54,6 +54,10 @@ func getImageSubCommands() []*cobra.Command { // Commands that the local client implements func getContainerSubCommands() []*cobra.Command { + + var _listSubCommand = _psCommand + _listSubCommand.Use = "list" + return []*cobra.Command{ _attachCommand, _checkpointCommand, @@ -64,8 +68,8 @@ func getContainerSubCommands() []*cobra.Command { _execCommand, _exportCommand, _killCommand, + &_listSubCommand, _logsCommand, - _psCommand, _mountCommand, _pauseCommand, _portCommand, diff --git a/cmd/podman/common.go b/cmd/podman/common.go index f9dfa3759..e980e10f9 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -519,7 +519,6 @@ func scrubServer(server string) string { func UsageTemplate() string { return `Usage:{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} - {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}} Aliases: diff --git a/cmd/podman/container.go b/cmd/podman/container.go index d2450fdd3..338bb005c 100644 --- a/cmd/podman/container.go +++ b/cmd/podman/container.go @@ -18,11 +18,13 @@ var containerCommand = cliconfig.PodmanCommand{ // Commands that are universally implemented. var containerCommands = []*cobra.Command{ _containerExistsCommand, + _inspectCommand, } func init() { containerCommand.AddCommand(containerCommands...) containerCommand.AddCommand(getContainerSubCommands()...) containerCommand.SetUsageTemplate(UsageTemplate()) + rootCmd.AddCommand(containerCommand.Command) } diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go index 032262497..4917fb606 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -105,5 +105,13 @@ func execCmd(c *cliconfig.ExecValues) error { envs = append(envs, fmt.Sprintf("%s=%s", k, v)) } - return ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir) + streams := new(libpod.AttachStreams) + streams.OutputStream = os.Stdout + streams.ErrorStream = os.Stderr + streams.InputStream = os.Stdin + streams.AttachOutput = true + streams.AttachError = true + streams.AttachInput = true + + return ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir, streams) } diff --git a/cmd/podman/image.go b/cmd/podman/image.go index aaa1866c4..b5c1c3ccf 100644 --- a/cmd/podman/image.go +++ b/cmd/podman/image.go @@ -15,6 +15,7 @@ var ( }, } _imagesSubCommand = _imagesCommand + _rmSubCommand = _rmiCommand ) //imageSubCommands are implemented both in local and remote clients @@ -28,7 +29,6 @@ var imageSubCommands = []*cobra.Command{ _pruneImagesCommand, _pullCommand, _pushCommand, - _rmiCommand, _saveCommand, _tagCommand, } @@ -38,7 +38,12 @@ func init() { imageCommand.AddCommand(imageSubCommands...) imageCommand.AddCommand(getImageSubCommands()...) - _imagesSubCommand.Aliases = []string{"ls", "list"} + // Setup of "images" to appear as "list" + _imagesSubCommand.Use = "list" + _imagesSubCommand.Aliases = []string{"ls"} imageCommand.AddCommand(&_imagesSubCommand) + // Setup of "rmi" to appears as "rm" + _rmSubCommand.Use = "rm" + imageCommand.AddCommand(&_rmSubCommand) } diff --git a/cmd/podman/main.go b/cmd/podman/main.go index d36270853..98e2f23ca 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -47,7 +47,7 @@ var mainCommands = []*cobra.Command{ podCommand.Command, _pullCommand, _pushCommand, - _rmiCommand, + &_rmiCommand, _saveCommand, _tagCommand, _versionCommand, diff --git a/cmd/podman/port.go b/cmd/podman/port.go index 1c3086536..ffb5749fb 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -128,9 +128,6 @@ func portCmd(c *cliconfig.PortValues) error { if state, _ := con.State(); state != libpod.ContainerStateRunning { continue } - if c.All { - fmt.Println(con.ID()) - } portmappings, err := con.PortMappings() if err != nil { @@ -143,6 +140,9 @@ func portCmd(c *cliconfig.PortValues) error { if hostIP == "" { hostIP = "0.0.0.0" } + if c.All { + fmt.Printf("%s\t", con.ID()[:12]) + } // If not searching by port or port/proto, then dump what we see if port == "" { fmt.Printf("%d/%s -> %s:%d\n", v.ContainerPort, v.Protocol, hostIP, v.HostPort) diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 3bc4f0b08..fe4173fdd 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -157,7 +157,7 @@ func (a psSortedSize) Less(i, j int) bool { var ( psCommand cliconfig.PsValues psDescription = "Prints out information about the containers" - _psCommand = &cobra.Command{ + _psCommand = cobra.Command{ Use: "ps", Short: "List containers", Long: psDescription, @@ -173,7 +173,7 @@ var ( ) func init() { - psCommand.Command = _psCommand + psCommand.Command = &_psCommand psCommand.SetUsageTemplate(UsageTemplate()) flags := psCommand.Flags() flags.BoolVarP(&psCommand.All, "all", "a", false, "Show all the containers, default is only running containers") diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index 641748452..193be6953 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -26,6 +26,7 @@ var ( ) func init() { + _refreshCommand.Hidden = true refreshCommand.Command = _refreshCommand refreshCommand.SetUsageTemplate(UsageTemplate()) } diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index e5bb9b486..5b8bf1ea3 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -14,7 +14,7 @@ import ( var ( rmiCommand cliconfig.RmiValues rmiDescription = "Removes one or more locally stored images." - _rmiCommand = &cobra.Command{ + _rmiCommand = cobra.Command{ Use: "rmi [flags] IMAGE [IMAGE...]", Short: "Removes one or more images from local storage", Long: rmiDescription, @@ -30,7 +30,7 @@ var ( ) func init() { - rmiCommand.Command = _rmiCommand + rmiCommand.Command = &_rmiCommand rmiCommand.SetUsageTemplate(UsageTemplate()) flags := rmiCommand.Flags() flags.BoolVarP(&rmiCommand.All, "all", "a", false, "Remove all images") diff --git a/docs/podman-container-refresh.1.md b/docs/podman-container-refresh.1.md deleted file mode 100644 index 26552faa6..000000000 --- a/docs/podman-container-refresh.1.md +++ /dev/null @@ -1,25 +0,0 @@ -% podman-container-refresh(1) - -## NAME -podman\-container\-refresh - Refresh all containers - -## SYNOPSIS -**podman container refresh** - -## DESCRIPTION -The refresh command refreshes the state of all containers to pick up database -schema or general configuration changes. It is not necessary during normal -operation, and will typically be invoked by package managers after finishing an -upgrade of the Podman package. - -As part of refresh, all running containers will be restarted. - -## EXAMPLES ## - -``` -$ podman container refresh -[root@localhost /]# -``` - -## SEE ALSO -podman(1), podman-run(1) diff --git a/docs/podman-container.1.md b/docs/podman-container.1.md index 86ffd32c4..1ba957480 100644 --- a/docs/podman-container.1.md +++ b/docs/podman-container.1.md @@ -14,25 +14,22 @@ The container command allows you to manage containers | Command | Man Page | Description | | --------- | --------------------------------------------------- | ---------------------------------------------------------------------------- | | attach | [podman-attach(1)](podman-attach.1.md) | Attach to a running container. | -| checkpoint | [podman-container-checkpoint(1)](podman-container-checkpoint.1.md) | Checkpoints one or more containers. | +| checkpoint | [podman-container-checkpoint(1)](podman-container-checkpoint.1.md) | Checkpoints one or more containers. | | cleanup | [podman-container-cleanup(1)](podman-container-cleanup.1.md) | Cleanup containers network and mountpoints. | | commit | [podman-commit(1)](podman-commit.1.md) | Create new image based on the changed container. | | create | [podman-create(1)](podman-create.1.md) | Create a new container. | | diff | [podman-diff(1)](podman-diff.1.md) | Inspect changes on a container or image's filesystem. | | exec | [podman-exec(1)](podman-exec.1.md) | Execute a command in a running container. | -| exists | [podman-exists(1)](podman-container-exists.1.md) | Check if a container exists in local storage | +| exists | [podman-container-exists(1)](podman-container-exists.1.md) | Check if a container exists in local storage | | export | [podman-export(1)](podman-export.1.md) | Export a container's filesystem contents as a tar archive. | | inspect | [podman-inspect(1)](podman-inspect.1.md) | Display a container or image's configuration. | | kill | [podman-kill(1)](podman-kill.1.md) | Kill the main process in one or more containers. | -| list | [podman-ps(1)](podman-ps.1.md) | List the containers on the system. | +| list | [podman-ps(1)](podman-ps.1.md) | List the containers on the system.(alias ls) | | logs | [podman-logs(1)](podman-logs.1.md) | Display the logs of a container. | -| ls | [podman-ps(1)](podman-ps.1.md) | List the containers on the system. | | mount | [podman-mount(1)](podman-mount.1.md) | Mount a working container's root filesystem. | | pause | [podman-pause(1)](podman-pause.1.md) | Pause one or more containers. | | port | [podman-port(1)](podman-port.1.md) | List port mappings for the container. | | prune | [podman-container-prune(1)](podman-container-prune.1.md)| Remove all stopped containers from local storage. | -| ps | [podman-ps(1)](podman-ps.1.md) | List the containers on the system. | -| refresh | [podman-refresh(1)](podman-container-refresh.1.md) | Refresh the state of all containers | | restart | [podman-restart(1)](podman-restart.1.md) | Restart one or more containers. | | restore | [podman-container-restore(1)](podman-container-restore.1.md) | Restores one or more containers from a checkpoint. | | rm | [podman-rm(1)](podman-rm.1.md) | Remove one or more containers. | @@ -42,8 +39,7 @@ The container command allows you to manage containers | stats | [podman-stats(1)](podman-stats.1.md) | Display a live stream of one or more container's resource usage statistics. | | stop | [podman-stop(1)](podman-stop.1.md) | Stop one or more running containers. | | top | [podman-top(1)](podman-top.1.md) | Display the running processes of a container. | -| umount | [podman-umount(1)](podman-umount.1.md) | Unmount a working container's root filesystem. | -| unmount | [podman-umount(1)](podman-umount.1.md) | Unmount a working container's root filesystem. | +| umount | [podman-umount(1)](podman-umount.1.md) | Unmount a working container's root filesystem.(Alias unmount) | | unpause | [podman-unpause(1)](podman-unpause.1.md) | Unpause one or more containers. | | wait | [podman-wait(1)](podman-wait.1.md) | Wait on one or more containers to stop and print their exit codes. | diff --git a/docs/podman-image.1.md b/docs/podman-image.1.md index 95e8b7e48..b4ae752f6 100644 --- a/docs/podman-image.1.md +++ b/docs/podman-image.1.md @@ -14,17 +14,16 @@ The image command allows you to manage images | Command | Man Page | Description | | -------- | ----------------------------------------------- | --------------------------------------------------------------------------- | | build | [podman-build(1)](podman-build.1.md) | Build a container using a Dockerfile. | -| exists | [podman-exists(1)](podman-image-exists.1.md) | Check if a image exists in local storage. | +| exists | [podman-image-exists(1)](podman-image-exists.1.md) | Check if a image exists in local storage. | | history | [podman-history(1)](podman-history.1.md) | Show the history of an image. | | import | [podman-import(1)](podman-import.1.md) | Import a tarball and save it as a filesystem image. | | inspect | [podman-inspect(1)](podman-inspect.1.md) | Display a image or image's configuration. | -| list | [podman-images(1)](podman-images.1.md) | List the container images on the system. | +| list | [podman-images(1)](podman-images.1.md) | List the container images on the system.(alias ls) | | load | [podman-load(1)](podman-load.1.md) | Load an image from the docker archive. | -| ls | [podman-images(1)](podman-images.1.md) | List the container images on the system. | | prune | [podman-image-prune(1)](podman-image-prune.1.md)| Removed all unused images from the local store. | | pull | [podman-pull(1)](podman-pull.1.md) | Pull an image from a registry. | | push | [podman-push(1)](podman-push.1.md) | Push an image from local storage to elsewhere. | -| rm | [podman-rm(1)](podman-rmi.1.md) | Removes one or more locally stored images. | +| rm | [podman-rmi(1)](podman-rmi.1.md) | Removes one or more locally stored images. | | save | [podman-save(1)](podman-save.1.md) | Save an image to docker-archive or oci. | | sign | [podman-image-sign(1)](podman-image-sign.1.md) | Sign an image. | | tag | [podman-tag(1)](podman-tag.1.md) | Add an additional name to a local image. | diff --git a/docs/podman-system.1.md b/docs/podman-system.1.md index d088d4d9a..6d87648e8 100644 --- a/docs/podman-system.1.md +++ b/docs/podman-system.1.md @@ -13,7 +13,7 @@ The system command allows you to manage the podman systems | Command | Man Page | Description | | ------- | --------------------------------------------------- | ---------------------------------------------------------------------------- | -| info | [podman-system-info(1)](podman-info.1.md) | Displays Podman related system information. | +| info | [podman-info(1)](podman-info.1.md) | Displays Podman related system information. | | prune | [podman-system-prune(1)](podman-system-prune.1.md) | Remove all unused data | | renumber | [podman-system-renumber(1)](podman-system-renumber.1.md)| Migrate lock numbers to handle a change in maximum number of locks. | diff --git a/docs/podman.1.md b/docs/podman.1.md index 43f288fd7..bc03d3c5a 100644 --- a/docs/podman.1.md +++ b/docs/podman.1.md @@ -137,7 +137,6 @@ the exit codes follow the `chroot` standard, see below: | [podman-exec(1)](podman-exec.1.md) | Execute a command in a running container. | | [podman-export(1)](podman-export.1.md) | Export a container's filesystem contents as a tar archive. | | [podman-generate(1)](podman-generate.1.md)| Generate structured data based for a containers and pods. | -| [podman-help(1)](podman-history.1.md) | Show help information on podman. | | [podman-history(1)](podman-history.1.md) | Show the history of an image. | | [podman-image(1)](podman-image.1.md) | Manage Images. | | [podman-images(1)](podman-images.1.md) | List images in local storage. | @@ -157,7 +156,6 @@ the exit codes follow the `chroot` standard, see below: | [podman-ps(1)](podman-ps.1.md) | Prints out information about containers. | | [podman-pull(1)](podman-pull.1.md) | Pull an image from a registry. | | [podman-push(1)](podman-push.1.md) | Push an image from local storage to elsewhere. | -| [podman-refresh(1)](podman-refresh.1.md) | Refresh state of all containers to handle database changes. | | [podman-restart(1)](podman-restart.1.md) | Restart one or more containers. | | [podman-rm(1)](podman-rm.1.md) | Remove one or more containers. | | [podman-rmi(1)](podman-rmi.1.md) | Removes one or more locally stored images. | diff --git a/hack/podman-commands.sh b/hack/podman-commands.sh index e4c63ab59..754f2923d 100755 --- a/hack/podman-commands.sh +++ b/hack/podman-commands.sh @@ -1,40 +1,82 @@ -#!/bin/sh -./bin/podman --help | sed -n -Ee '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman.cmd -man ./docs/podman.1 | sed -n -e '0,/COMMANDS/d' -e '/^FILES/q;p' | grep podman | cut -f2 -d- | cut -f1 -d\( > /tmp/podman.man -echo diff -B -u /tmp/podman.cmd /tmp/podman.man -diff -B -u /tmp/podman.cmd /tmp/podman.man - -./bin/podman image --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-image.cmd -man ./docs/podman-image.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-image.man -echo diff -B -u /tmp/podman-image.cmd /tmp/podman-image.man -diff -B -u /tmp/podman-image.cmd /tmp/podman-image.man - -./bin/podman container --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-container.cmd -man docs/podman-container.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-container.man -echo diff -B -u /tmp/podman-container.cmd /tmp/podman-container.man -diff -B -u /tmp/podman-container.cmd /tmp/podman-container.man - -./bin/podman system --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-system.cmd -man docs/podman-system.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-system.man -echo diff -B -u /tmp/podman-system.cmd /tmp/podman-system.man -diff -B -u /tmp/podman-system.cmd /tmp/podman-system.man - -./bin/podman play --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-play.cmd -man docs/podman-play.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-play.man -echo diff -B -u /tmp/podman-play.cmd /tmp/podman-play.man -diff -B -u /tmp/podman-play.cmd /tmp/podman-play.man - -./bin/podman generate --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-generate.cmd -man docs/podman-generate.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-generate.man -echo diff -B -u /tmp/podman-generate.cmd /tmp/podman-generate.man -diff -B -u /tmp/podman-generate.cmd /tmp/podman-generate.man - -./bin/podman pod --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-pod.cmd -man docs/podman-pod.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-pod.man -echo diff -B -u /tmp/podman-pod.cmd /tmp/podman-pod.man -diff -B -u /tmp/podman-pod.cmd /tmp/podman-pod.man - -./bin/podman volume --help | sed -n -e '0,/Available Commands/d' -e '/^Flags/q;p' | sed '/^$/d' | awk '{ print $1 }' > /tmp/podman-volume.cmd -man docs/podman-volume.1 | sed -n -Ee '0,/COMMANDS/d' -e 's/^[[:space:]]*//' -e '/^SEE ALSO/q;p' | grep podman | cut -f1 -d' ' | sed 's/^.//' > /tmp/podman-volume.man -echo diff -B -u /tmp/podman-volume.cmd /tmp/podman-volume.man -diff -B -u /tmp/podman-volume.cmd /tmp/podman-volume.man +#!/bin/bash +# +# Compare commands listed by 'podman help' against those in 'man podman'. +# Recurse into subcommands as well. +# +# Because we read metadoc files in the `docs` directory, this script +# must run from the top level of a git checkout. FIXME: if necessary, +# it could instead run 'man podman-XX'; my thinking is that this +# script should run early in CI. +# + +# override with, e.g., PODMAN=./bin/podman-remote +PODMAN=${PODMAN:-./bin/podman} + +function die() { + echo "FATAL: $*" >&2 + exit 1 +} + + +# Run 'podman help' (possibly against a subcommand, e.g. 'podman help image') +# and return a list of each first word under 'Available Commands', that is, +# the command name but not its description. +function podman_commands() { + $PODMAN help "$@" |\ + awk '/^Available Commands:/{ok=1;next}/^Flags:/{ok=0}ok { print $1 }' |\ + grep . +} + +# Read a list of subcommands from a command's metadoc +function podman_man() { + if [ "$@" = "podman" ]; then + # podman itself. + # This md file has a table of the form: + # | [podman-cmd(1)\[(podman-cmd.1.md) | Description ... | + # For all such, print the 'cmd' portion (the one in brackets). + sed -ne 's/^|\s\+\[podman-\([a-z]\+\)(1.*/\1/p' <docs/$1.1.md + elif [ "$@" = "podman-image-trust" ]; then + # Special case: set and show aren't actually in a table in the man page + echo set + echo show + else + # podman subcommand. + # Each md file has a table of the form: + # | cmd | [podman-cmd(1)](podman-cmd.1.md) | Description ... | + # For all such we find, with 'podman- in the second column, print the + # first column (with whitespace trimmed) + awk -F\| '$3 ~ /podman-/ { gsub(" ","",$2); print $2 }' < docs/$1.1.md + fi +} + +# The main thing. Compares help and man page; if we find subcommands, recurse. +rc=0 +function compare_help_and_man() { + echo + echo "checking: podman $@" + + # e.g. podman, podman-image, podman-volume + local basename=$(echo podman "$@" | sed -e 's/ /-/g') + + podman_commands "$@" | sort > /tmp/${basename}_help.txt + podman_man $basename | sort > /tmp/${basename}_man.txt + + diff -u /tmp/${basename}_help.txt /tmp/${basename}_man.txt || rc=1 + + # Now look for subcommands, e.g. container, image + for cmd in $(< /tmp/${basename}_help.txt); do + usage=$($PODMAN "$@" $cmd --help | grep -A1 '^Usage:' | tail -1) + + # if string ends in '[command]', recurse into its subcommands + if expr "$usage" : '.*\[command\]$' >/dev/null; then + compare_help_and_man "$@" $cmd + fi + done + + rm -f /tmp/${basename}_{help,man}.txt +} + + +compare_help_and_man + +exit $rc diff --git a/libpod/container_api.go b/libpod/container_api.go index 09d7f220d..6bef3c47d 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -203,9 +203,8 @@ func (c *Container) Kill(signal uint) error { } // Exec starts a new process inside the container -// TODO allow specifying streams to attach to // TODO investigate allowing exec without attaching -func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir string) error { +func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir string, streams *AttachStreams) error { var capList []string locked := false @@ -267,7 +266,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir logrus.Debugf("Creating new exec session in container %s with session id %s", c.ID(), sessionID) - execCmd, err := c.runtime.ociRuntime.execContainer(c, cmd, capList, env, tty, workDir, hostUser, sessionID) + execCmd, err := c.runtime.ociRuntime.execContainer(c, cmd, capList, env, tty, workDir, hostUser, sessionID, streams) if err != nil { return errors.Wrapf(err, "error exec %s", c.ID()) } diff --git a/libpod/oci.go b/libpod/oci.go index 26d2c6ef1..4bf76f619 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -733,7 +733,7 @@ func (r *OCIRuntime) unpauseContainer(ctr *Container) error { // TODO: Add --detach support // TODO: Convert to use conmon // TODO: add --pid-file and use that to generate exec session tracking -func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty bool, cwd, user, sessionID string) (*exec.Cmd, error) { +func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty bool, cwd, user, sessionID string, streams *AttachStreams) (*exec.Cmd, error) { if len(cmd) == 0 { return nil, errors.Wrapf(ErrInvalidArg, "must provide a command to execute") } @@ -789,9 +789,17 @@ func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty logrus.Debugf("Starting runtime %s with following arguments: %v", r.path, args) execCmd := exec.Command(r.path, args...) - execCmd.Stdout = os.Stdout - execCmd.Stderr = os.Stderr - execCmd.Stdin = os.Stdin + + if streams.AttachOutput { + execCmd.Stdout = streams.OutputStream + } + if streams.AttachInput { + execCmd.Stdin = streams.InputStream + } + if streams.AttachError { + execCmd.Stderr = streams.ErrorStream + } + execCmd.Env = append(execCmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir)) if err := execCmd.Start(); err != nil { diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 9a192c0fa..98692707f 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -93,7 +93,8 @@ func tryMappingTool(tool string, pid int, hostID int, mappings []idtools.IDMap) Args: args, } - if err := cmd.Run(); err != nil { + if output, err := cmd.CombinedOutput(); err != nil { + logrus.Debugf("error from %s: %s", tool, output) return errors.Wrapf(err, "cannot setup namespace using %s", tool) } return nil diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index fda6eb085..11332708b 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -30,6 +30,13 @@ var _ = Describe("Podman checkpoint", func() { if !criu.CheckForCriu() { Skip("CRIU is missing or too old.") } + // TODO: Remove the skip when the current CRIU SELinux problem is solved. + // See: https://github.com/containers/libpod/issues/2334 + hostInfo := podmanTest.Host + if hostInfo.Distribution == "fedora" { + Skip("Checkpointing containers on Fedora currently broken.") + } + }) AfterEach(func() { diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index c85810454..571754347 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -59,7 +59,7 @@ var _ = Describe("Podman load", func() { Expect(save.ExitCode()).To(Equal(0)) compress := SystemExec("gzip", []string{outfile}) - compress.WaitWithDefaultTimeout() + Expect(compress.ExitCode()).To(Equal(0)) outfile = outfile + ".gz" rmi := podmanTest.Podman([]string{"rmi", ALPINE}) @@ -174,7 +174,6 @@ var _ = Describe("Podman load", func() { It("podman load localhost registry from scratch", func() { outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz") - setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -255,7 +254,6 @@ var _ = Describe("Podman load", func() { save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) session := SystemExec("xz", []string{outfile}) - session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) rmi := podmanTest.Podman([]string{"rmi", BB}) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index cb2b0e7b0..4717267a1 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -95,7 +95,6 @@ var _ = Describe("Podman pod create", func() { Expect(webserver.ExitCode()).To(Equal(0)) check := SystemExec("nc", []string{"-z", "localhost", "80"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(1)) }) @@ -111,7 +110,6 @@ var _ = Describe("Podman pod create", func() { Expect(webserver.ExitCode()).To(Equal(0)) check := SystemExec("nc", []string{"-z", "localhost", "80"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index faad8202e..d9b9c7213 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -6,10 +6,12 @@ import ( "os" "fmt" + "path/filepath" + "strings" + . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "strings" ) var _ = Describe("Podman pull", func() { @@ -92,58 +94,56 @@ var _ = Describe("Podman pull", func() { }) It("podman pull from docker-archive", func() { - session := podmanTest.Podman([]string{"save", "-o", "/tmp/alp.tar", "alpine"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"save", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "docker-archive:/tmp/alp.tar"}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp.tar"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman pull from oci-archive", func() { - session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", "/tmp/oci-alp.tar", "alpine"}) + tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar") + session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "oci-archive:/tmp/oci-alp.tar"}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/oci-alp.tar"}) - clean.WaitWithDefaultTimeout() }) It("podman pull from local directory", func() { - setup := SystemExec("mkdir", []string{"-p", "/tmp/podmantestdir"}) - setup.WaitWithDefaultTimeout() - session := podmanTest.Podman([]string{"push", "alpine", "dir:/tmp/podmantestdir"}) + dirpath := filepath.Join(podmanTest.TempDir, "alpine") + os.MkdirAll(dirpath, os.ModePerm) + imgPath := fmt.Sprintf("dir:%s", dirpath) + + session := podmanTest.Podman([]string{"push", "alpine", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "dir:/tmp/podmantestdir"}) + session = podmanTest.Podman([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "podmantestdir"}) + session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - - clean := SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"}) - clean.WaitWithDefaultTimeout() }) It("podman pull check quiet", func() { diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 42aefd1f7..fee117783 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -51,13 +51,11 @@ var _ = Describe("Podman push", func() { }) It("podman push to dir", func() { - session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, "dir:/tmp/busybox"}) + bbdir := filepath.Join(podmanTest.TempDir, "busybox") + session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, + fmt.Sprintf("dir:%s", bbdir)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - - clean := SystemExec("rm", []string{"-fr", "/tmp/busybox"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to local registry", func() { @@ -85,20 +83,21 @@ var _ = Describe("Podman push", func() { authPath := filepath.Join(podmanTest.TempDir, "auth") os.Mkdir(authPath, os.ModePerm) os.MkdirAll("/etc/containers/certs.d/localhost:5000", os.ModePerm) - debug := SystemExec("ls", []string{"-l", podmanTest.TempDir}) - debug.WaitWithDefaultTimeout() + defer os.RemoveAll("/etc/containers/certs.d/localhost:5000") cwd, _ := os.Getwd() certPath := filepath.Join(cwd, "../", "certs") if IsCommandAvailable("getenforce") { ge := SystemExec("getenforce", []string{}) - ge.WaitWithDefaultTimeout() + Expect(ge.ExitCode()).To(Equal(0)) if ge.OutputToString() == "Enforcing" { se := SystemExec("setenforce", []string{"0"}) - se.WaitWithDefaultTimeout() - - defer SystemExec("setenforce", []string{"1"}) + Expect(se.ExitCode()).To(Equal(0)) + defer func() { + se2 := SystemExec("setenforce", []string{"1"}) + Expect(se2.ExitCode()).To(Equal(0)) + }() } } podmanTest.RestoreArtifact(registry) @@ -111,8 +110,6 @@ var _ = Describe("Podman push", func() { f.WriteString(session.OutputToString()) f.Sync() - debug = SystemExec("cat", []string{filepath.Join(authPath, "htpasswd")}) - debug.WaitWithDefaultTimeout() session = podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", strings.Join([]string{authPath, "/auth"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", @@ -138,8 +135,7 @@ var _ = Describe("Podman push", func() { Expect(push.ExitCode()).To(Equal(0)) setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), "/etc/containers/certs.d/localhost:5000/ca.crt"}) - setup.WaitWithDefaultTimeout() - defer os.RemoveAll("/etc/containers/certs.d/localhost:5000") + Expect(setup.ExitCode()).To(Equal(0)) push = podmanTest.Podman([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) push.WaitWithDefaultTimeout() @@ -155,23 +151,22 @@ var _ = Describe("Podman push", func() { }) It("podman push to docker-archive", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp:latest"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("docker-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to docker daemon", func() { setup := SystemExec("bash", []string{"-c", "systemctl status docker 2>&1"}) - setup.WaitWithDefaultTimeout() if setup.LineInOutputContains("Active: inactive") { setup = SystemExec("systemctl", []string{"start", "docker"}) - setup.WaitWithDefaultTimeout() - - defer SystemExec("systemctl", []string{"stop", "docker"}) + defer func() { + stop := SystemExec("systemctl", []string{"stop", "docker"}) + Expect(stop.ExitCode()).To(Equal(0)) + }() } else if setup.ExitCode() != 0 { Skip("Docker is not available") } @@ -181,22 +176,19 @@ var _ = Describe("Podman push", func() { Expect(session.ExitCode()).To(Equal(0)) check := SystemExec("docker", []string{"images", "--format", "{{.Repository}}:{{.Tag}}"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(0)) Expect(check.OutputToString()).To(ContainSubstring("alpine:podmantest")) clean := SystemExec("docker", []string{"rmi", "alpine:podmantest"}) - clean.WaitWithDefaultTimeout() Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to oci-archive", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp.tar:latest"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("oci-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp.tar"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to local ostree", func() { @@ -208,33 +200,29 @@ var _ = Describe("Podman push", func() { os.MkdirAll(ostreePath, os.ModePerm) setup := SystemExec("ostree", []string{strings.Join([]string{"--repo=", ostreePath}, ""), "init"}) - setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"push", ALPINE, strings.Join([]string{"ostree:alp@", ostreePath}, "")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"-rf", ostreePath}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to docker-archive no reference", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to oci-archive no reference", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp-oci"}) + ociarc := filepath.Join(podmanTest.TempDir, "alp-oci") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("oci-archive:%s", ociarc)}) + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp-oci"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) }) diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index aa823b4e6..1f2a4085d 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -36,14 +36,16 @@ var _ = Describe("Podman run exit", func() { It("podman run -d mount cleanup test", func() { mount := SystemExec("mount", nil) - mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + out1 := mount.OutputToString() result := podmanTest.Podman([]string{"create", "-dt", ALPINE, "echo", "hello"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) mount = SystemExec("mount", nil) - mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + out2 := mount.OutputToString() Expect(out1).To(Equal(out2)) }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index a07e4d047..c89a4f487 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -58,7 +58,6 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) Expect(session.ExitCode()).To(Equal(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - results.Wait(30) Expect(results.ExitCode()).To(Equal(0)) Expect(results.OutputToString()).To(ContainSubstring("222")) Expect(results.OutputToString()).To(ContainSubstring("223")) @@ -69,12 +68,10 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) Expect(session.ExitCode()).To(Equal(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - results.Wait(30) Expect(results.ExitCode()).To(Equal(0)) Expect(results.OutputToString()).To(ContainSubstring("8000")) ncBusy := SystemExec("nc", []string{"-l", "-p", "80"}) - ncBusy.Wait(10) Expect(ncBusy.ExitCode()).ToNot(Equal(0)) }) @@ -183,26 +180,40 @@ var _ = Describe("Podman run networking", func() { if Containerized() { Skip("Can not be run within a container.") } - SystemExec("ip", []string{"netns", "add", "xxx"}) + addXXX := SystemExec("ip", []string{"netns", "add", "xxx"}) + Expect(addXXX.ExitCode()).To(Equal(0)) + defer func() { + delXXX := SystemExec("ip", []string{"netns", "delete", "xxx"}) + Expect(delXXX.ExitCode()).To(Equal(0)) + }() + session := podmanTest.Podman([]string{"run", "-dt", "--net", "ns:/run/netns/xxx", ALPINE, "wget", "www.podman.io"}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) - SystemExec("ip", []string{"netns", "delete", "xxx"}) }) It("podman run n user created network namespace with resolv.conf", func() { if Containerized() { Skip("Can not be run within a container.") } - SystemExec("ip", []string{"netns", "add", "xxx"}) - SystemExec("mkdir", []string{"-p", "/etc/netns/xxx"}) - SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx/resolv.conf"}) - session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx", ALPINE, "cat", "/etc/resolv.conf"}) + addXXX2 := SystemExec("ip", []string{"netns", "add", "xxx2"}) + Expect(addXXX2.ExitCode()).To(Equal(0)) + defer func() { + delXXX2 := SystemExec("ip", []string{"netns", "delete", "xxx2"}) + Expect(delXXX2.ExitCode()).To(Equal(0)) + }() + + mdXXX2 := SystemExec("mkdir", []string{"-p", "/etc/netns/xxx2"}) + Expect(mdXXX2.ExitCode()).To(Equal(0)) + defer os.RemoveAll("/etc/netns/xxx2") + + nsXXX2 := SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx2/resolv.conf"}) + Expect(nsXXX2.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx2", ALPINE, "cat", "/etc/resolv.conf"}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11")) - SystemExec("ip", []string{"netns", "delete", "xxx"}) - SystemExec("rm", []string{"-rf", "/etc/netns/xxx"}) }) It("podman run network in bogus user created network namespace", func() { diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 9962185f2..3d95c3a0b 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -53,7 +53,6 @@ var _ = Describe("Podman run ns", func() { It("podman run ipcns test", func() { setup := SystemExec("ls", []string{"--inode", "-d", "/dev/shm"}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) hostShm := setup.OutputToString() @@ -65,7 +64,6 @@ var _ = Describe("Podman run ns", func() { It("podman run ipcns ipcmk host test", func() { setup := SystemExec("ipcmk", []string{"-M", "1024"}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) output := strings.Split(setup.OutputToString(), " ") ipc := output[len(output)-1] @@ -74,7 +72,6 @@ var _ = Describe("Podman run ns", func() { Expect(session.ExitCode()).To(Equal(0)) setup = SystemExec("ipcrm", []string{"-m", ipc}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 0c0de30c5..ee6e8e950 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -46,7 +46,6 @@ var _ = Describe("Podman privileged container tests", func() { It("podman privileged CapEff", func() { cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() Expect(cap.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"run", "--privileged", "busybox", "grep", "CapEff", "/proc/self/status"}) @@ -57,7 +56,6 @@ var _ = Describe("Podman privileged container tests", func() { It("podman cap-add CapEff", func() { cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() Expect(cap.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"run", "--cap-add", "all", "busybox", "grep", "CapEff", "/proc/self/status"}) @@ -97,7 +95,6 @@ var _ = Describe("Podman privileged container tests", func() { } cap := SystemExec("grep", []string{"NoNewPrivs", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() if cap.ExitCode() != 0 { Skip("Can't determine NoNewPrivs") } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 6bd49de33..93ee5036f 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -387,7 +387,6 @@ var _ = Describe("Podman run", func() { err = ioutil.WriteFile(keyFile, []byte(mountString), 0755) Expect(err).To(BeNil()) execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")}) - execSession.WaitWithDefaultTimeout() Expect(execSession.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "cat", "/run/secrets/test.txt"}) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index a7e7a1500..252361288 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -53,31 +53,27 @@ WantedBy=multi-user.target sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemd_unit_file), 0644) Expect(sys_file).To(BeNil()) + defer func() { + stop := SystemExec("bash", []string{"-c", "systemctl stop redis"}) + os.Remove("/etc/systemd/system/redis.service") + SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) + Expect(stop.ExitCode()).To(Equal(0)) + }() create := podmanTest.Podman([]string{"create", "-d", "--name", "redis", "redis"}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) - enable := SystemExec("bash", []string{"-c", "systemctl daemon-reload && systemctl enable --now redis"}) - enable.WaitWithDefaultTimeout() + enable := SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) Expect(enable.ExitCode()).To(Equal(0)) start := SystemExec("bash", []string{"-c", "systemctl start redis"}) - start.WaitWithDefaultTimeout() + Expect(start.ExitCode()).To(Equal(0)) logs := SystemExec("bash", []string{"-c", "journalctl -n 20 -u redis"}) - logs.WaitWithDefaultTimeout() + Expect(logs.ExitCode()).To(Equal(0)) status := SystemExec("bash", []string{"-c", "systemctl status redis"}) - status.WaitWithDefaultTimeout() Expect(status.OutputToString()).To(ContainSubstring("active (running)")) - - cleanup := SystemExec("bash", []string{"-c", "systemctl stop redis && systemctl disable redis"}) - cleanup.WaitWithDefaultTimeout() - Expect(cleanup.ExitCode()).To(Equal(0)) - os.Remove("/etc/systemd/system/redis.service") - sys_clean := SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) - sys_clean.WaitWithDefaultTimeout() - Expect(sys_clean.ExitCode()).To(Equal(0)) }) }) diff --git a/test/test_podman_baseline.sh b/test/test_podman_baseline.sh index 8a878b4e7..664fd2b03 100755 --- a/test/test_podman_baseline.sh +++ b/test/test_podman_baseline.sh @@ -195,7 +195,7 @@ podman rmi --all ######## # 1.004608 MB is 1,004,608 bytes. The container overhead is 4608 bytes (or 9 512 byte pages), so this allocates 1 MB of usable storage -PODMANBASE="-s overlay --storage-opt overlay.size=1.004608M --root /tmp/podman_test/crio" +PODMANBASE="--storage-driver overlay --storage-opt overlay.size=1.004608M --root /tmp/podman_test/crio" TMPDIR=/tmp/podman_test mkdir $TMPDIR dd if=/dev/zero of=$TMPDIR/virtfs bs=1024 count=30720 diff --git a/test/utils/utils.go b/test/utils/utils.go index 098779321..499466f5a 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -326,6 +326,7 @@ func SystemExec(command string, args []string) *PodmanSession { if err != nil { Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " "))) } + session.Wait(defaultWaitTimeout) return &PodmanSession{session} } |