Merge branch 'containers:main' into main

This commit is contained in:
ryanhockstad
2023-09-13 14:23:16 -04:00
committed by GitHub
170 changed files with 17279 additions and 3754 deletions

View File

@ -158,6 +158,8 @@ spelled with complete minutiae.
1. Edit `version/rawversion/version.go` and bump the `Version` value to the new
release version. If there were API changes, also bump `APIVersion` value.
Make sure to also bump the version in the swagger.yaml `pkg/api/server/docs.go`
For major and minor versions also add the new branch name to
`docs/source/Reference.rst` to show the new swagger version on docs.podman.io.
1. Commit this and sign the commit (`git commit -a -s -S`). The commit message
should be `Bump to vX.Y.Z` (using the actual version numbers).
1. Push this single change to your GitHub fork, and make a new PR,

View File

@ -67,7 +67,7 @@ func rm(cmd *cobra.Command, args []string) error {
deletedFarms := []string{}
for _, k := range args {
if _, ok := cfg.Farms.List[k]; !ok {
logrus.Warnf("farm %q doesn't exists; nothing to remove", k)
logrus.Warnf("farm %q doesn't exist; nothing to remove", k)
continue
}
delete(cfg.Farms.List, k)

View File

@ -46,7 +46,7 @@ var (
playOptions = playKubeOptionsWrapper{}
playDescription = `Reads in a structured file of Kubernetes YAML.
Creates pods or volumes based on the Kubernetes kind described in the YAML. Supported kinds are Pods, Deployments and PersistentVolumeClaims.`
Creates pods or volumes based on the Kubernetes kind described in the YAML. Supported kinds are Pods, Deployments, DaemonSets and PersistentVolumeClaims.`
playCmd = &cobra.Command{
Use: "play [options] KUBEFILE|-",

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
_ "github.com/containers/podman/v4/cmd/podman/completion"
@ -43,9 +44,7 @@ func main() {
(len(os.Args[0]) > 0 && filepath.Base(os.Args[0][1:]) == registry.PodmanSh) {
shell := strings.TrimPrefix(os.Args[0], "-")
// The wait timeout will soon be made configurable via the
// upcoming `podmansh_timeout` option in containers.conf
args := []string{shell, "exec", "-i", "--wait", "30"}
args := []string{shell, "exec", "-i", "--wait", strconv.FormatUint(uint64(registry.PodmanConfig().ContainersConfDefaultsRO.Engine.PodmanshTimeout), 10)}
if term.IsTerminal(0) || term.IsTerminal(1) || term.IsTerminal(2) {
args = append(args, "-t")
}

View File

@ -364,8 +364,9 @@ case "$TEST_FLAVOR" in
pip install --requirement $GOSRC/test/apiv2/python/requirements.txt
;& # continue with next item
compose)
make install.tools
dnf install -y podman-docker*
showrun make install.tools
showrun dnf remove -y gvisor-tap-vsock
showrun dnf install -y podman-docker*
;& # continue with next item
int)
make .install.ginkgo

View File

@ -33,7 +33,7 @@ Note: **N/A** means that the option cannot be supported in a single-node Podman
| topologySpreadConstraints\.labelSelector | N/A |
| topologySpreadConstraints\.minDomains | N/A |
| restartPolicy | ✅ |
| terminationGracePeriod | no |
| terminationGracePeriodSeconds | |
| activeDeadlineSeconds | no |
| readinessGates\.conditionType | no |
| hostname | ✅ |
@ -173,3 +173,15 @@ Note: **N/A** means that the option cannot be supported in a single-node Podman
| revisionHistoryLimit | no |
| progressDeadlineSeconds | no |
| paused | no |
## DaemonSet Fields
| Field | Support |
|-----------------------------------------|-------------------------------------------------------|
| selector | ✅ |
| template | ✅ |
| minReadySeconds | no |
| strategy\.type | no |
| strategy\.rollingUpdate\.maxSurge | no |
| strategy\.rollingUpdate\.maxUnavailable | no |
| revisionHistoryLimit | no |

View File

@ -7,6 +7,8 @@ Show the API documentation for version:
* `latest (main branch) <_static/api.html>`_
* `version 4.6 <_static/api.html?version=v4.6>`_
* `version 4.5 <_static/api.html?version=v4.5>`_
* `version 4.4 <_static/api.html?version=v4.4>`_

View File

@ -13,7 +13,7 @@ Initialize one or more containers.
You may use container IDs or names as input.
Initializing a container performs all tasks necessary for starting the container (mounting filesystems, creating an OCI spec, initializing the container network) but does not start the container.
If a container is not initialized, the `podman start` and `podman run` commands initialize it automatically prior to starting it.
This command is intended to be used for inspecting or modifying the container's filesystem or OCI spec prior to starting it.
This command is intended to be used for inspecting a container's filesystem or OCI spec prior to starting it.
This can be used to inspect the container before it runs, or debug why a container is failing to run.
## OPTIONS

View File

@ -30,6 +30,8 @@ Note that the generated Kubernetes YAML file can be used to re-run the deploymen
Note that if the pod being generated was created with the **--infra-name** flag set, then the generated kube yaml will have the **io.podman.annotations.infra.name** set where the value is the name of the infra container set by the user.
Also note that both Deployment and DaemonSet can only have `restartPolicy` set to `Always`.
## OPTIONS
#### **--filename**, **-f**=*filename*
@ -54,9 +56,9 @@ Note: this can only be set with the option `--type=deployment`.
Generate a Kubernetes service object in addition to the Pods. Used to generate a Service specification for the corresponding Pod output. In particular, if the object has portmap bindings, the service specification includes a NodePort declaration to expose the service. A random port is assigned by Podman in the specification.
#### **--type**, **-t**=*pod | deployment*
#### **--type**, **-t**=*pod* | *deployment* | *daemonset*
The Kubernetes kind to generate in the YAML file. Currently, the only supported Kubernetes specifications are `Pod` and `Deployment`. By default, the `Pod` specification is generated.
The Kubernetes kind to generate in the YAML file. Currently, the only supported Kubernetes specifications are `Pod`, `Deployment` and `DaemonSet`. By default, the `Pod` specification is generated.
## EXAMPLES

View File

@ -23,6 +23,7 @@ Currently, the supported Kubernetes kinds are:
- PersistentVolumeClaim
- ConfigMap
- Secret
- DaemonSet
`Kubernetes Pods or Deployments`

View File

@ -125,7 +125,7 @@ Valid options for `[Container]` are listed below:
|--------------------------------|------------------------------------------------------|
| AddCapability=CAP | --cap-add CAP |
| AddDevice=/dev/foo | --device /dev/foo |
| Annotation="YXZ" | --annotation "XYZ" |
| Annotation="XYZ" | --annotation "XYZ" |
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
| ContainerName=name | --name name |
| DNS=192.168.55.1 | --dns=192.168.55.1 |
@ -144,16 +144,16 @@ Valid options for `[Container]` are listed below:
| HealthRetries=5 | --health-retries=5 |
| HealthStartPeriod=1m | --health-start-period=period=1m |
| HealthStartupCmd="command" | --health-startup-cmd="command" |
| HealthStartupInterval=1m | --health-startup-interval=2m |
| HealthStartupInterval=1m | --health-startup-interval=1m |
| HealthStartupRetries=8 | --health-startup-retries=8 |
| HealthStartupSuccess=2 | --health-startup-success=2 |
| HealthStartupTimeout=1m33s | --health-startup-timeout=1m33s |
| HealthTimeout=20s | --health-timeout=20s |
| HostName=new-host-name | --hostname="new-host-name" |
| Image=ubi8 | Image specification - ubi8 |
| IP=192.5.0.1 | --ip 192.5.0.0 |
| IP6=fd46:db93:aa76:ac37::10 | --ip6 2001:db8::1 |
| Label="YXZ" | --label "XYZ" |
| IP=192.5.0.1 | --ip 192.5.0.1 |
| IP6=2001:db8::1 | --ip6 2001:db8::1 |
| Label="XYZ" | --label "XYZ" |
| LogDriver=journald | --log-driver journald |
| Mount=type=... | --mount type=... |
| Network=host | --net host |
@ -733,7 +733,7 @@ Valid options for `[Network]` are listed below:
| IPAMDriver=dhcp | --ipam-driver dhcp |
| IPRange=192.168.55.128/25 | --ip-range 192.168.55.128/25 |
| IPv6=true | --ipv6 |
| Label="YXZ" | --label "XYZ" |
| Label="XYZ" | --label "XYZ" |
| NetworkName=foo | podman network create foo |
| Options=isolate | --opt isolate |
| PodmanArgs=--dns=192.168.55.1 | --dns=192.168.55.1 |

View File

@ -20,6 +20,8 @@ Systemd will automatically create the container when the user session is started
Administrators can use volumes to expose specific host data from the host system to the user, without the user being exposed to other parts of the system.
Timeout for podmansh can be set using the `podmansh_timeout` option in containers.conf.
## Setup
Create user login session using useradd while running as root.
@ -126,7 +128,7 @@ _EOF
```
## SEE ALSO
**[podman(1)](podman.1.md)**, **[podman-exec(1)](podman-exec.1.md)**, **quadlet(5)**
**[containers.conf(5)](containers.conf.5.md)**, **[podman(1)](podman.1.md)**, **[podman-exec(1)](podman-exec.1.md)**, **quadlet(5)**
## HISTORY
May 2023, Originally compiled by Dan Walsh <dwalsh@redhat.com>

23
go.mod
View File

@ -9,17 +9,17 @@ require (
github.com/buger/goterm v1.0.4
github.com/checkpoint-restore/checkpointctl v0.1.0
github.com/checkpoint-restore/go-criu/v6 v6.3.0
github.com/container-orchestrated-devices/container-device-interface v0.6.0
github.com/container-orchestrated-devices/container-device-interface v0.6.1
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.3.0
github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6
github.com/containers/common v0.55.1-0.20230830075933-12405381ff45
github.com/containers/common v0.55.1-0.20230912125309-7fa3c55bd517
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa
github.com/containers/image/v5 v5.27.1-0.20230911141411-81c35e010bab
github.com/containers/libhvee v0.4.1-0.20230905135638-56fb23533417
github.com/containers/ocicrypt v1.1.8
github.com/containers/psgo v1.8.0
github.com/containers/storage v1.49.1-0.20230823084450-6902c2df7cca
github.com/containers/storage v1.50.0
github.com/coreos/go-systemd/v22 v22.5.0
github.com/coreos/stream-metadata-go v0.4.3
github.com/crc-org/vfkit v0.1.1
@ -59,7 +59,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/ulikunitz/xz v0.5.11
github.com/vbauerster/mpb/v8 v8.6.0
github.com/vbauerster/mpb/v8 v8.6.1
github.com/vishvananda/netlink v1.2.1-beta.2
go.etcd.io/bbolt v1.3.7
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
@ -78,14 +78,14 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/hcsshim v0.10.0 // indirect
github.com/Microsoft/hcsshim v0.11.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/containerd/cgroups/v3 v3.0.2 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/containerd v1.7.5 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
@ -125,7 +125,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-containerregistry v0.15.2 // indirect
github.com/google/go-containerregistry v0.16.1 // indirect
github.com/google/go-intervals v0.0.2 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@ -163,13 +163,14 @@ require (
github.com/proglottis/gpgme v0.1.3 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/seccomp/libseccomp-golang v0.10.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/sigstore/fulcio v1.4.0 // indirect
github.com/sigstore/rekor v1.2.2 // indirect
github.com/sigstore/sigstore v1.7.1 // indirect
github.com/sigstore/sigstore v1.7.3 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
github.com/sylabs/sif/v2 v2.11.5 // indirect
github.com/sylabs/sif/v2 v2.13.0 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/theupdateframework/go-tuf v0.5.2 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
@ -186,7 +187,7 @@ require (
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect

52
go.sum
View File

@ -67,8 +67,8 @@ github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
github.com/Microsoft/hcsshim v0.10.0 h1:PbvoxdUGgXxyirmN5Oncp3POLkxEG5LbWCEBfWmHTGA=
github.com/Microsoft/hcsshim v0.10.0/go.mod h1:3j1trOamcUdi86J5Tr5+1BpqMjSv/QeRWkX2whBF6dY=
github.com/Microsoft/hcsshim v0.11.0 h1:7EFNIY4igHEXUdj1zXgAyU3fLc7QfOKHbkldRVTBdiM=
github.com/Microsoft/hcsshim v0.11.0/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM=
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@ -149,8 +149,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/container-orchestrated-devices/container-device-interface v0.6.0 h1:aWwcz/Ep0Fd7ZuBjQGjU/jdPloM7ydhMW13h85jZNvk=
github.com/container-orchestrated-devices/container-device-interface v0.6.0/go.mod h1:OQlgtJtDrOxSQ1BWODC8OZK1tzi9W69wek+Jy17ndzo=
github.com/container-orchestrated-devices/container-device-interface v0.6.1 h1:mz77uJoP8im/4Zins+mPqt677ZMaflhoGaYrRAl5jvA=
github.com/container-orchestrated-devices/container-device-interface v0.6.1/go.mod h1:40T6oW59rFrL/ksiSs7q45GzjGlbvxnA4xaK6cyq+kA=
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=
@ -165,8 +165,8 @@ github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340/go.mod h1:s5q4S
github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo=
github.com/containerd/cgroups v0.0.0-20210114181951-8a68de567b68/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU=
github.com/containerd/cgroups/v3 v3.0.2 h1:f5WFqIVSgo5IZmtTT3qVBo6TzI1ON6sycSBKkymb9L0=
github.com/containerd/cgroups/v3 v3.0.2/go.mod h1:JUgITrzdFqp42uI2ryGA+ge0ap/nxzYgkGmIcetmErE=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE=
@ -246,12 +246,12 @@ github.com/containernetworking/plugins v1.3.0 h1:QVNXMT6XloyMUoO2wUOqWTC1hWFV62Q
github.com/containernetworking/plugins v1.3.0/go.mod h1:Pc2wcedTQQCVuROOOaLBPPxrEXqqXBFt3cZ+/yVg6l0=
github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6 h1:K/S8SFQsnnNTF0Ws58SrBD9L0EuClzAG8Zp08d7+6AA=
github.com/containers/buildah v1.31.1-0.20230722114901-5ece066f82c6/go.mod h1:0sptTFBBtSznLqoTh80DfvMOCNbdRsNRgVOKhBhrupA=
github.com/containers/common v0.55.1-0.20230830075933-12405381ff45 h1:hwUrFFjPuaQLKDjaXTc3hDfZp2X89IWKx4rBQX0bUwc=
github.com/containers/common v0.55.1-0.20230830075933-12405381ff45/go.mod h1:Xcw3UosoUax8jn+MZoxL7LbEbfxKqhUNMZyhdd5s/vk=
github.com/containers/common v0.55.1-0.20230912125309-7fa3c55bd517 h1:VbCiDKqzPx8N1gyB1vtXKbI0HpX7QaFK9/9d0n4HgU4=
github.com/containers/common v0.55.1-0.20230912125309-7fa3c55bd517/go.mod h1:udRQMEx9cbPslGo/yCKmnBr7NJ6aVrqGOLKLs/c1Lqc=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa h1:wDfVQtc6ik2MvsUmu/YRSyBAE5YUxdjcEDtuT1q2KDo=
github.com/containers/image/v5 v5.26.1-0.20230807184415-3fb422379cfa/go.mod h1:apL4qwq31NV0gsSZQJPxYyTH0yzWavmMCjT8vsQaXSk=
github.com/containers/image/v5 v5.27.1-0.20230911141411-81c35e010bab h1:bAK5q9Coo11AMbtK/rojwOssSa+kXqAVhPYlHNmBZPE=
github.com/containers/image/v5 v5.27.1-0.20230911141411-81c35e010bab/go.mod h1:h4O2N9IxSqe/O/ThgOkPk/JaK2j+jhbEM8GhNI5WtbI=
github.com/containers/libhvee v0.4.1-0.20230905135638-56fb23533417 h1:fr+j21PD+IYR6Kvlf2Zrm1x9oAjV12T2Vz3oZIGTusw=
github.com/containers/libhvee v0.4.1-0.20230905135638-56fb23533417/go.mod h1:HiXu8GZyjzGjU834fROO00Ka/4B1IM8qxy/6q6x1f+4=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
@ -264,8 +264,8 @@ github.com/containers/ocicrypt v1.1.8/go.mod h1:jM362hyBtbwLMWzXQZTlkjKGAQf/BN/L
github.com/containers/psgo v1.8.0 h1:2loGekmGAxM9ir5OsXWEfGwFxorMPYnc6gEDsGFQvhY=
github.com/containers/psgo v1.8.0/go.mod h1:T8ZxnX3Ur4RvnhxFJ7t8xJ1F48RhiZB4rSrOaR/qGHc=
github.com/containers/storage v1.43.0/go.mod h1:uZ147thiIFGdVTjMmIw19knttQnUCl3y9zjreHrg11s=
github.com/containers/storage v1.49.1-0.20230823084450-6902c2df7cca h1:W5cl16PWueRYxe0cbVPJap6QDYYXn41HtbBiztuWJN4=
github.com/containers/storage v1.49.1-0.20230823084450-6902c2df7cca/go.mod h1:fCvGMWQ0BOvlReQf9DqRAcl73ofTfRXE8l6ifnI4a3g=
github.com/containers/storage v1.50.0 h1:b46xv6ewEV3KLP3y9fLAZ8x+ZAEaAkkFkZ8FTkY3YPA=
github.com/containers/storage v1.50.0/go.mod h1:XuzgVgTBiVKOREY1AKgY1u4ZMK4+feUGHTcqabFwJ68=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
@ -458,7 +458,7 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-rod/rod v0.113.3 h1:oLiKZW721CCMwA5g7977cWfcAKQ+FuosP47Zf1QiDrA=
github.com/go-rod/rod v0.114.3 h1:gAUT2Bc2wy0tQL5KEet05HNDvmndaHAGCjQ01TB2efA=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
@ -558,8 +558,8 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
github.com/google/go-containerregistry v0.15.2 h1:MMkSh+tjSdnmJZO7ljvEqV1DjfekB6VUEAZgy3a+TQE=
github.com/google/go-containerregistry v0.15.2/go.mod h1:wWK+LnOv4jXMM23IT/F1wdYftGWGr47Is8CG+pmHK1Q=
github.com/google/go-containerregistry v0.16.1 h1:rUEt426sR6nyrL3gt+18ibRcvYpKYdpsa5ZW7MA08dQ=
github.com/google/go-containerregistry v0.16.1/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/google/go-intervals v0.0.2 h1:FGrVEiUnTRKR8yE04qzXYaJMtnIYqobR5QbblK3ixcM=
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@ -897,8 +897,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rootless-containers/rootlesskit v1.1.1 h1:F5psKWoWY9/VjZ3ifVcaosjvFZJOagX85U22M0/EQZE=
github.com/rootless-containers/rootlesskit v1.1.1/go.mod h1:UD5GoA3dqKCJrnvnhVgQQnweMF2qZnf9KLw8EewcMZI=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@ -909,6 +909,8 @@ github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24
github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y=
github.com/seccomp/libseccomp-golang v0.10.0 h1:aA4bp+/Zzi0BnWZ2F1wgNBs5gTpm+na2rWM6M9YjLpY=
github.com/seccomp/libseccomp-golang v0.10.0/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/secure-systems-lab/go-securesystemslib v0.7.0 h1:OwvJ5jQf9LnIAS83waAjPbcMsODrTQUpJ02eNLUoxBg=
github.com/secure-systems-lab/go-securesystemslib v0.7.0/go.mod h1:/2gYnlnHVQ6xeGtfIqFy7Do03K4cdCY0A/GlJLDKLHI=
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
@ -917,8 +919,8 @@ github.com/sigstore/fulcio v1.4.0 h1:05+k8BFvwTQzfCkVxESWzCN4b70KIRliGYz0Upmdrs8
github.com/sigstore/fulcio v1.4.0/go.mod h1:wcjlktbhoy6+ZTxO3yXpvqUxsLV+JEH4FF3a5Jz4VPI=
github.com/sigstore/rekor v1.2.2 h1:5JK/zKZvcQpL/jBmHvmFj3YbpDMBQnJQ6ygp8xdF3bY=
github.com/sigstore/rekor v1.2.2/go.mod h1:FGnWBGWzeNceJnp0x9eDFd41mI8aQqCjj+Zp0IEs0Qg=
github.com/sigstore/sigstore v1.7.1 h1:fCATemikcBK0cG4+NcM940MfoIgmioY1vC6E66hXxks=
github.com/sigstore/sigstore v1.7.1/go.mod h1:0PmMzfJP2Y9+lugD0wer4e7TihR5tM7NcIs3bQNk5xg=
github.com/sigstore/sigstore v1.7.3 h1:HVVTfrMezJeLyl2xhJ8edzkrEGBa4KxjQZB4FlQ4JLU=
github.com/sigstore/sigstore v1.7.3/go.mod h1:cl0c7Dtg3MM3c13L8pqqrfrmBa0eM3POcdtBepjylmw=
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
@ -976,8 +978,8 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/sylabs/sif/v2 v2.11.5 h1:7ssPH3epSonsTrzbS1YxeJ9KuqAN7ISlSM61a7j/mQM=
github.com/sylabs/sif/v2 v2.11.5/go.mod h1:GBoZs9LU3e4yJH1dcZ3Akf/jsqYgy5SeguJQC+zd75Y=
github.com/sylabs/sif/v2 v2.13.0 h1:dK/PQ/ohLAA4hptbjNuU0qoqkJ9Kl07hiSHArMNSKsQ=
github.com/sylabs/sif/v2 v2.13.0/go.mod h1:qEFrmE29XNbW2uyBagTsw9dgM82MwsckNYUFPweF2ek=
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
@ -1011,8 +1013,8 @@ github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/vbauerster/mpb/v8 v8.6.0 h1:b3GbUHKi9VmU587SxEqvYH1QAQEr9XYBiHGaQFsEQME=
github.com/vbauerster/mpb/v8 v8.6.0/go.mod h1:S0tuIjikxlLxCeNijNhwAuD/BB3UE/d2nygG8SOldk0=
github.com/vbauerster/mpb/v8 v8.6.1 h1:XbBpIbJxJOO9yMcKPpI4oEFPW6tLAptefNQJNcGWri8=
github.com/vbauerster/mpb/v8 v8.6.1/go.mod h1:S0tuIjikxlLxCeNijNhwAuD/BB3UE/d2nygG8SOldk0=
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
@ -1206,8 +1208,8 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU=
golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk=
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -1532,7 +1534,7 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -321,9 +321,7 @@ func (c *Container) execStartAndAttach(sessionID string, streams *define.AttachS
return err
}
if isHealthcheck {
c.newContainerEvent(events.HealthStatus)
} else {
if !isHealthcheck {
c.newContainerEvent(events.Exec)
}

View File

@ -633,6 +633,13 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
nprocSet := false
isRootless := rootless.IsRootless()
if isRootless {
if g.Config.Process != nil && g.Config.Process.OOMScoreAdj != nil {
var err error
*g.Config.Process.OOMScoreAdj, err = maybeClampOOMScoreAdj(*g.Config.Process.OOMScoreAdj)
if err != nil {
return nil, nil, err
}
}
for _, rlimit := range c.config.Spec.Process.Rlimits {
if rlimit.Type == "RLIMIT_NOFILE" {
nofileSet = true
@ -2938,3 +2945,19 @@ func (c *Container) umask() (uint32, error) {
}
return uint32(decVal), nil
}
func maybeClampOOMScoreAdj(oomScoreValue int) (int, error) {
v, err := os.ReadFile("/proc/self/oom_score_adj")
if err != nil {
return oomScoreValue, err
}
currentValue, err := strconv.Atoi(strings.TrimRight(string(v), "\n"))
if err != nil {
return oomScoreValue, err
}
if currentValue > oomScoreValue {
logrus.Warnf("Requested oom_score_adj=%d is lower than the current one, changing to %d", oomScoreValue, currentValue)
return currentValue, nil
}
return oomScoreValue, nil
}

View File

@ -45,4 +45,6 @@ const (
K8sKindPod = "pod"
// A Deployment kube yaml spec
K8sKindDeployment = "deployment"
// A DaemonSet kube yaml spec
K8sKindDaemonSet = "daemonset"
)

View File

@ -11,6 +11,7 @@ import (
"time"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/libpod/events"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
@ -60,6 +61,7 @@ func (c *Container) runHealthCheck(ctx context.Context, isStartup bool) (define.
returnCode int
inStartPeriod bool
)
hcCommand := c.HealthCheckConfig().Test
if isStartup {
logrus.Debugf("Running startup healthcheck for container %s", c.ID())
@ -167,6 +169,13 @@ func (c *Container) runHealthCheck(ctx context.Context, isStartup bool) (define.
return hcResult, "", fmt.Errorf("unable to update health check log %s for %s: %w", c.healthCheckLogPath(), c.ID(), err)
}
// Write HC event with appropriate status as the last thing before we
// return.
if hcResult == define.HealthCheckNotDefined || hcResult == define.HealthCheckInternalError {
return hcResult, logStatus, hcErr
}
c.newContainerEvent(events.HealthStatus)
return hcResult, logStatus, hcErr
}

View File

@ -119,6 +119,61 @@ func (p *Pod) getInfraContainer() (*Container, error) {
return p.runtime.GetContainer(infraID)
}
func GenerateForKubeDaemonSet(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDaemonSet, error) {
// Restart policy for DaemonSets can only be set to Always
if !(pod.Spec.RestartPolicy == "" || pod.Spec.RestartPolicy == v1.RestartPolicyAlways) {
return nil, fmt.Errorf("k8s DaemonSets can only have restartPolicy set to Always")
}
// Error out if the user tries to set replica count
if options.Replicas > 1 {
return nil, fmt.Errorf("k8s DaemonSets don't allow setting replicas")
}
// Create label map that will be added to podSpec and DaemonSet metadata
// The matching label lets the daemonset know which pod to manage
appKey := "app"
matchLabels := map[string]string{appKey: pod.Name}
// Add the key:value (app:pod-name) to the podSpec labels
if pod.Labels == nil {
pod.Labels = matchLabels
} else {
pod.Labels[appKey] = pod.Name
}
depSpec := YAMLDaemonSetSpec{
DaemonSetSpec: v1.DaemonSetSpec{
Selector: &v12.LabelSelector{
MatchLabels: matchLabels,
},
},
Template: &YAMLPodTemplateSpec{
PodTemplateSpec: v1.PodTemplateSpec{
ObjectMeta: pod.ObjectMeta,
},
Spec: pod.Spec,
},
}
// Create the DaemonSet object
dep := YAMLDaemonSet{
DaemonSet: v1.DaemonSet{
ObjectMeta: v12.ObjectMeta{
Name: pod.Name + "-daemonset",
CreationTimestamp: pod.CreationTimestamp,
Labels: pod.Labels,
},
TypeMeta: v12.TypeMeta{
Kind: "DaemonSet",
APIVersion: "apps/v1",
},
},
Spec: &depSpec,
}
return &dep, nil
}
// GenerateForKubeDeployment returns a YAMLDeployment from a YAMLPod that is then used to create a kubernetes Deployment
// kind YAML.
func GenerateForKubeDeployment(ctx context.Context, pod *YAMLPod, options entities.GenerateKubeOptions) (*YAMLDeployment, error) {
@ -262,6 +317,28 @@ type YAMLDeploymentSpec struct {
Strategy *v1.DeploymentStrategy `json:"strategy,omitempty"`
}
// YAMLDaemonSetSpec represents the same k8s API core DeploymentSpec with a small
// change and that is having Template as a pointer to YAMLPodTemplateSpec and Strategy
// as a pointer to k8s API core DaemonSetStrategy.
// Because Go doesn't omit empty struct and we want to omit Strategy and any fields in the Pod YAML
// if it's empty.
type YAMLDaemonSetSpec struct {
v1.DaemonSetSpec
Template *YAMLPodTemplateSpec `json:"template,omitempty"`
Strategy *v1.DaemonSetUpdateStrategy `json:"strategy,omitempty"`
}
// YAMLDaemonSet represents the same k8s API core DaemonSet with a small change
// and that is having Spec as a pointer to YAMLDaemonSetSpec and Status as a pointer to
// k8s API core DaemonSetStatus.
// Because Go doesn't omit empty struct and we want to omit Status and any fields in the DaemonSetSpec
// if it's empty.
type YAMLDaemonSet struct {
v1.DaemonSet
Spec *YAMLDaemonSetSpec `json:"spec,omitempty"`
Status *v1.DaemonSetStatus `json:"status,omitempty"`
}
// YAMLDeployment represents the same k8s API core Deployment with a small change
// and that is having Spec as a pointer to YAMLDeploymentSpec and Status as a pointer to
// k8s API core DeploymentStatus.
@ -435,7 +512,10 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
podInitCtrs := []v1.Container{}
podAnnotations := make(map[string]string)
dnsInfo := v1.PodDNSConfig{}
var hostname string
var (
hostname string
stopTimeout *uint
)
// Let's sort the containers in order of created time
// This will ensure that the init containers are defined in the correct order in the kube yaml
@ -463,6 +543,12 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
}
}
// Pick the first container that has a stop-timeout set and use that value
// Ignore podman's default
if ctr.config.StopTimeout != util.DefaultContainerConfig().Engine.StopTimeout && stopTimeout == nil {
stopTimeout = &ctr.config.StopTimeout
}
ctr, volumes, _, annotations, err := containerToV1Container(ctx, ctr, getService)
if err != nil {
return nil, err
@ -536,10 +622,11 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
&dnsInfo,
hostNetwork,
hostUsers,
hostname), nil
hostname,
stopTimeout), nil
}
func newPodObject(podName string, annotations map[string]string, initCtrs, containers []v1.Container, volumes []v1.Volume, dnsOptions *v1.PodDNSConfig, hostNetwork, hostUsers bool, hostname string) *v1.Pod {
func newPodObject(podName string, annotations map[string]string, initCtrs, containers []v1.Container, volumes []v1.Volume, dnsOptions *v1.PodDNSConfig, hostNetwork, hostUsers bool, hostname string, stopTimeout *uint) *v1.Pod {
tm := v12.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
@ -571,6 +658,10 @@ func newPodObject(podName string, annotations map[string]string, initCtrs, conta
if dnsOptions != nil && (len(dnsOptions.Nameservers)+len(dnsOptions.Searches)+len(dnsOptions.Options) > 0) {
ps.DNSConfig = dnsOptions
}
if stopTimeout != nil {
terminationGracePeriod := int64(*stopTimeout)
ps.TerminationGracePeriodSeconds = &terminationGracePeriod
}
p := v1.Pod{
TypeMeta: tm,
ObjectMeta: om,
@ -590,8 +681,11 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
podDNS := v1.PodDNSConfig{}
kubeAnnotations := make(map[string]string)
ctrNames := make([]string, 0, len(ctrs))
var hostname string
var restartPolicy *string
var (
hostname string
restartPolicy *string
stopTimeout *uint
)
for _, ctr := range ctrs {
ctrNames = append(ctrNames, removeUnderscores(ctr.Name()))
for k, v := range ctr.config.Spec.Annotations {
@ -616,6 +710,12 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
}
}
// Pick the first container that has a stop-timeout set and use that value
// Ignore podman's default
if ctr.config.StopTimeout != util.DefaultContainerConfig().Engine.StopTimeout && stopTimeout == nil {
stopTimeout = &ctr.config.StopTimeout
}
// Use the restart policy of the first non-init container
if !isInit && restartPolicy == nil {
restartPolicy = &ctr.config.RestartPolicy
@ -707,7 +807,8 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container, getServic
&podDNS,
hostNetwork,
hostUsers,
hostname)
hostname,
stopTimeout)
// Set the pod's restart policy
policy := ""

View File

@ -232,6 +232,16 @@ func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrIDs []string,
return nil, err
}
typeContent = append(typeContent, b)
case define.K8sKindDaemonSet:
dep, err := libpod.GenerateForKubeDaemonSet(ctx, libpod.ConvertV1PodToYAMLPod(po), options)
if err != nil {
return nil, err
}
b, err := generateKubeYAML(dep)
if err != nil {
return nil, err
}
typeContent = append(typeContent, b)
case define.K8sKindPod:
b, err := generateKubeYAML(libpod.ConvertV1PodToYAMLPod(po))
if err != nil {
@ -239,7 +249,7 @@ func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrIDs []string,
}
typeContent = append(typeContent, b)
default:
return nil, fmt.Errorf("invalid generation type - only pods and deployments are currently supported")
return nil, fmt.Errorf("invalid generation type - only pods, deployments and daemonsets are currently supported: %+v", options.Type)
}
if options.Service {
@ -289,6 +299,16 @@ func getKubePods(ctx context.Context, pods []*libpod.Pod, options entities.Gener
return nil, nil, err
}
out = append(out, b)
case define.K8sKindDaemonSet:
dep, err := libpod.GenerateForKubeDaemonSet(ctx, libpod.ConvertV1PodToYAMLPod(po), options)
if err != nil {
return nil, nil, err
}
b, err := generateKubeYAML(dep)
if err != nil {
return nil, nil, err
}
out = append(out, b)
case define.K8sKindPod:
b, err := generateKubeYAML(libpod.ConvertV1PodToYAMLPod(po))
if err != nil {
@ -296,7 +316,7 @@ func getKubePods(ctx context.Context, pods []*libpod.Pod, options entities.Gener
}
out = append(out, b)
default:
return nil, nil, fmt.Errorf("invalid generation type - only pods and deployments are currently supported")
return nil, nil, fmt.Errorf("invalid generation type - only pods, deployments and daemonsets are currently supported")
}
if options.Service {

View File

@ -16,6 +16,7 @@ import (
"syscall"
"github.com/containers/common/libimage"
"github.com/containers/common/libimage/filter"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/ssh"
"github.com/containers/image/v5/docker"
@ -462,7 +463,7 @@ func (ir *ImageEngine) Import(ctx context.Context, options entities.ImageImportO
// Search for images using term and filters
func (ir *ImageEngine) Search(ctx context.Context, term string, opts entities.ImageSearchOptions) ([]entities.ImageSearchReport, error) {
filter, err := libimage.ParseSearchFilter(opts.Filters)
filter, err := filter.ParseSearchFilter(opts.Filters)
if err != nil {
return nil, err
}

View File

@ -855,6 +855,10 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
Volumes: volumes,
}
if podYAML.Spec.TerminationGracePeriodSeconds != nil {
specgenOpts.TerminationGracePeriodSeconds = podYAML.Spec.TerminationGracePeriodSeconds
}
specGen, err := kube.ToSpecGen(ctx, &specgenOpts)
if err != nil {
return nil, nil, err

View File

@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/containers/common/libimage"
"github.com/containers/common/libimage/filter"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/ssh"
"github.com/containers/image/v5/docker/reference"
@ -339,7 +339,7 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
func (ir *ImageEngine) Search(ctx context.Context, term string, opts entities.ImageSearchOptions) ([]entities.ImageSearchReport, error) {
mappedFilters := make(map[string][]string)
filters, err := libimage.ParseSearchFilter(opts.Filters)
filters, err := filter.ParseSearchFilter(opts.Filters)
if err != nil {
return nil, err
}

View File

@ -4955,3 +4955,224 @@ type DeploymentList struct {
// Items is the list of Deployments.
Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// DaemonSetUpdateStrategy is a struct used to control the update strategy for a DaemonSet.
type DaemonSetUpdateStrategy struct {
// Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is RollingUpdate.
// +optional
Type DaemonSetUpdateStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"`
// Rolling update config params. Present only if type = "RollingUpdate".
//---
// TODO: Update this to follow our convention for oneOf, whatever we decide it
// to be. Same as Deployment `strategy.rollingUpdate`.
// See https://github.com/kubernetes/kubernetes/issues/35345
// +optional
RollingUpdate *RollingUpdateDaemonSet `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`
}
type DaemonSetUpdateStrategyType string
const (
// Replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
RollingUpdateDaemonSetStrategyType DaemonSetUpdateStrategyType = "RollingUpdate"
// Replace the old daemons only when it's killed
OnDeleteDaemonSetStrategyType DaemonSetUpdateStrategyType = "OnDelete"
)
// Spec to control the desired behavior of daemon set rolling update.
type RollingUpdateDaemonSet struct {
// The maximum number of DaemonSet pods that can be unavailable during the
// update. Value can be an absolute number (ex: 5) or a percentage of total
// number of DaemonSet pods at the start of the update (ex: 10%). Absolute
// number is calculated from percentage by rounding up.
// This cannot be 0 if MaxSurge is 0
// Default value is 1.
// Example: when this is set to 30%, at most 30% of the total number of nodes
// that should be running the daemon pod (i.e. status.desiredNumberScheduled)
// can have their pods stopped for an update at any given time. The update
// starts by stopping at most 30% of those DaemonSet pods and then brings
// up new DaemonSet pods in their place. Once the new pods are available,
// it then proceeds onto other DaemonSet pods, thus ensuring that at least
// 70% of original number of DaemonSet pods are available at all times during
// the update.
// +optional
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
// The maximum number of nodes with an existing available DaemonSet pod that
// can have an updated DaemonSet pod during during an update.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// This can not be 0 if MaxUnavailable is 0.
// Absolute number is calculated from percentage by rounding up to a minimum of 1.
// Default value is 0.
// Example: when this is set to 30%, at most 30% of the total number of nodes
// that should be running the daemon pod (i.e. status.desiredNumberScheduled)
// can have their a new pod created before the old pod is marked as deleted.
// The update starts by launching new pods on 30% of nodes. Once an updated
// pod is available (Ready for at least minReadySeconds) the old DaemonSet pod
// on that node is marked deleted. If the old pod becomes unavailable for any
// reason (Ready transitions to false, is evicted, or is drained) an updated
// pod is immediatedly created on that node without considering surge limits.
// Allowing surge implies the possibility that the resources consumed by the
// daemonset on any given node can double if the readiness check fails, and
// so resource intensive daemonsets should take into account that they may
// cause evictions during disruption.
// This is beta field and enabled/disabled by DaemonSetUpdateSurge feature gate.
// +optional
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"`
}
// DaemonSetSpec is the specification of a daemon set.
type DaemonSetSpec struct {
// A label query over pods that are managed by the daemon set.
// Must match in order to be controlled.
// It must match the pod template's labels.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,1,opt,name=selector"`
// An object that describes the pod that will be created.
// The DaemonSet will create exactly one copy of this pod on every node
// that matches the template's node selector (or on every node if no node
// selector is specified).
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
Template PodTemplateSpec `json:"template" protobuf:"bytes,2,opt,name=template"`
// An update strategy to replace existing DaemonSet pods with new pods.
// +optional
UpdateStrategy DaemonSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,3,opt,name=updateStrategy"`
// The minimum number of seconds for which a newly created DaemonSet pod should
// be ready without any of its container crashing, for it to be considered
// available. Defaults to 0 (pod will be considered available as soon as it
// is ready).
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
// The number of old history to retain to allow rollback.
// This is a pointer to distinguish between explicit zero and not specified.
// Defaults to 10.
// +optional
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,6,opt,name=revisionHistoryLimit"`
}
// DaemonSetStatus represents the current status of a daemon set.
type DaemonSetStatus struct {
// The number of nodes that are running at least 1
// daemon pod and are supposed to run the daemon pod.
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
CurrentNumberScheduled int32 `json:"currentNumberScheduled" protobuf:"varint,1,opt,name=currentNumberScheduled"`
// The number of nodes that are running the daemon pod, but are
// not supposed to run the daemon pod.
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
NumberMisscheduled int32 `json:"numberMisscheduled" protobuf:"varint,2,opt,name=numberMisscheduled"`
// The total number of nodes that should be running the daemon
// pod (including nodes correctly running the daemon pod).
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
DesiredNumberScheduled int32 `json:"desiredNumberScheduled" protobuf:"varint,3,opt,name=desiredNumberScheduled"`
// The number of nodes that should be running the daemon pod and have one
// or more of the daemon pod running and ready.
NumberReady int32 `json:"numberReady" protobuf:"varint,4,opt,name=numberReady"`
// The most recent generation observed by the daemon set controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,5,opt,name=observedGeneration"`
// The total number of nodes that are running updated daemon pod
// +optional
UpdatedNumberScheduled int32 `json:"updatedNumberScheduled,omitempty" protobuf:"varint,6,opt,name=updatedNumberScheduled"`
// The number of nodes that should be running the
// daemon pod and have one or more of the daemon pod running and
// available (ready for at least spec.minReadySeconds)
// +optional
NumberAvailable int32 `json:"numberAvailable,omitempty" protobuf:"varint,7,opt,name=numberAvailable"`
// The number of nodes that should be running the
// daemon pod and have none of the daemon pod running and available
// (ready for at least spec.minReadySeconds)
// +optional
NumberUnavailable int32 `json:"numberUnavailable,omitempty" protobuf:"varint,8,opt,name=numberUnavailable"`
// Count of hash collisions for the DaemonSet. The DaemonSet controller
// uses this field as a collision avoidance mechanism when it needs to
// create the name for the newest ControllerRevision.
// +optional
CollisionCount *int32 `json:"collisionCount,omitempty" protobuf:"varint,9,opt,name=collisionCount"`
// Represents the latest available observations of a DaemonSet's current state.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []DaemonSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
}
type DaemonSetConditionType string
// TODO: Add valid condition types of a DaemonSet.
// DaemonSetCondition describes the state of a DaemonSet at a certain point.
type DaemonSetCondition struct {
// Type of DaemonSet condition.
Type DaemonSetConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DaemonSetConditionType"`
// Status of the condition, one of True, False, Unknown.
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/api/core/v1.ConditionStatus"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
// The reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
// A human readable message indicating details about the transition.
// +optional
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// DaemonSet represents the configuration of a daemon set.
type DaemonSet struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// The desired behavior of this daemon set.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +optional
Spec DaemonSetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// The current status of this daemon set. This data may be
// out of date by some window of time.
// Populated by the system.
// Read-only.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +optional
Status DaemonSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
const (
// DefaultDaemonSetUniqueLabelKey is the default label key that is added
// to existing DaemonSet pods to distinguish between old and new
// DaemonSet pods during DaemonSet template updates.
DefaultDaemonSetUniqueLabelKey = "pod-template-has"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// DaemonSetList is a collection of daemon sets.
type DaemonSetList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// A list of daemon sets.
Items []DaemonSet `json:"items" protobuf:"bytes,2,rep,name=items"`
}

View File

@ -168,6 +168,8 @@ type CtrSpecGenOptions struct {
InitContainerType string
// PodSecurityContext is the security context specified for the pod
PodSecurityContext *v1.PodSecurityContext
// TerminationGracePeriodSeconds is the grace period given to a container to stop before being forcefully killed
TerminationGracePeriodSeconds *int64
}
func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) {
@ -584,6 +586,12 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.Labels[systemdDefine.EnvVariable] = unit
}
// Set the stopTimeout if terminationGracePeriodSeconds is set in the kube yaml
if opts.TerminationGracePeriodSeconds != nil {
timeout := uint(*opts.TerminationGracePeriodSeconds)
s.StopTimeout = &timeout
}
return s, nil
}

View File

@ -4,9 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"path"
"strconv"
"strings"
"github.com/containers/common/libimage"
@ -18,7 +16,6 @@ import (
"github.com/containers/podman/v4/pkg/specgen"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
@ -81,25 +78,6 @@ func getCgroupPermissions(unmask []string) string {
return ro
}
func maybeClampOOMScoreAdj(oomScoreValue int, isRootless bool) (int, error) {
if !isRootless {
return oomScoreValue, nil
}
v, err := os.ReadFile("/proc/self/oom_score_adj")
if err != nil {
return oomScoreValue, err
}
currentValue, err := strconv.Atoi(strings.TrimRight(string(v), "\n"))
if err != nil {
return oomScoreValue, err
}
if currentValue > oomScoreValue {
logrus.Warnf("Requested oom_score_adj=%d is lower than the current one, changing to %d", oomScoreValue, currentValue)
return currentValue, nil
}
return oomScoreValue, nil
}
// SpecGenToOCI returns the base configuration for the container.
func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runtime, rtc *config.Config, newImage *libimage.Image, mounts []spec.Mount, pod *libpod.Pod, finalCmd []string, compatibleOptions *libpod.InfraInherit) (*spec.Spec, error) {
cgroupPerm := getCgroupPermissions(s.Unmask)
@ -343,12 +321,9 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
}
if s.OOMScoreAdj != nil {
score, err := maybeClampOOMScoreAdj(*s.OOMScoreAdj, isRootless)
if err != nil {
return nil, err
}
g.SetProcessOOMScoreAdj(score)
g.SetProcessOOMScoreAdj(*s.OOMScoreAdj)
}
setProcOpts(s, &g)
if s.ReadOnlyFilesystem && !s.ReadWriteTmpfs {
setDevOptsReadOnly(&g)

View File

@ -1,6 +1,7 @@
package integration
import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@ -22,45 +23,45 @@ var _ = Describe("Podman container cleanup", func() {
It("podman cleanup container by id", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", cid})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
It("podman cleanup container by short id", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
shortID := cid[0:10]
session = podmanTest.Podman([]string{"container", "cleanup", shortID})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(shortID))
})
It("podman cleanup container by name", func() {
session := podmanTest.Podman([]string{"create", "--name", "foo", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("foo"))
})
It("podman cleanup all containers", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", "--all"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
@ -68,23 +69,23 @@ var _ = Describe("Podman container cleanup", func() {
SkipIfRemote("--latest flag n/a")
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", "--latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
It("podman cleanup running container", func() {
session := podmanTest.RunTopContainer("running")
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "running"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
@ -95,10 +96,10 @@ var _ = Describe("Podman container cleanup", func() {
SkipIfRootlessCgroupsV1("Pause is not supported in cgroups v1")
session := podmanTest.RunTopContainer("paused")
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"pause", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
@ -108,6 +109,6 @@ var _ = Describe("Podman container cleanup", func() {
// otherwise it fails with container state improper
session = podmanTest.Podman([]string{"unpause", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
})

View File

@ -22,6 +22,14 @@ var _ = Describe("Podman commit", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
if !IsRemote() {
messages := session.ErrorToString()
Expect(messages).To(ContainSubstring("Getting image source signatures"))
Expect(messages).To(ContainSubstring("Copying blob"))
Expect(messages).To(ContainSubstring("Writing manifest to image destination"))
Expect(messages).To(Not(ContainSubstring("level=")), "Unexpected logrus messages in stderr")
}
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
data := check.InspectImageJSON()
@ -33,9 +41,9 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "test1", "a"})
session := podmanTest.Podman([]string{"commit", "-q", "test1", "a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "localhost/a:latest"})
check.WaitWithDefaultTimeout()
@ -48,9 +56,9 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"container", "commit", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"container", "commit", "-q", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"image", "inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
@ -63,9 +71,9 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "-f", "docker", "--message", "testing-commit", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "-f", "docker", "--message", "testing-commit", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
@ -78,9 +86,9 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--author", "snoopy", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--author", "snoopy", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
@ -91,12 +99,12 @@ var _ = Describe("Podman commit", func() {
It("podman commit container with change flag", func() {
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
test.WaitWithDefaultTimeout()
Expect(test).Should(Exit(0))
Expect(test).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--change", "LABEL=image=blue", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--change", "LABEL=image=blue", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
@ -107,16 +115,16 @@ var _ = Describe("Podman commit", func() {
It("podman commit container with --squash", func() {
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
test.WaitWithDefaultTimeout()
Expect(test).Should(Exit(0))
Expect(test).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--squash", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--squash", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Check for one layers
Expect(strings.Fields(session.OutputToString())).To(HaveLen(1))
})
@ -124,12 +132,12 @@ var _ = Describe("Podman commit", func() {
It("podman commit container with change flag and JSON entrypoint with =", func() {
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
test.WaitWithDefaultTimeout()
Expect(test).Should(Exit(0))
Expect(test).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--change", `ENTRYPOINT ["foo", "bar=baz"]`, "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--change", `ENTRYPOINT ["foo", "bar=baz"]`, "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
@ -143,25 +151,25 @@ var _ = Describe("Podman commit", func() {
It("podman commit container with change CMD flag", func() {
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
test.WaitWithDefaultTimeout()
Expect(test).Should(Exit(0))
Expect(test).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--change", "CMD a b c", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--change", "CMD a b c", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Config.Cmd}}", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("sh -c a b c"))
session = podmanTest.Podman([]string{"commit", "--change", "CMD=[\"a\",\"b\",\"c\"]", "test1", "foobar.com/test1-image:latest"})
session = podmanTest.Podman([]string{"commit", "-q", "--change", "CMD=[\"a\",\"b\",\"c\"]", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Config.Cmd}}", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Not(ContainSubstring("sh -c")))
})
@ -170,27 +178,27 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "--pause=false", "test1", "foobar.com/test1-image:latest"})
session := podmanTest.Podman([]string{"commit", "-q", "--pause=false", "test1", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
check.WaitWithDefaultTimeout()
Expect(check).Should(Exit(0))
Expect(check).Should(ExitCleanly())
})
It("podman commit with volumes mounts and no include-volumes", func() {
s := podmanTest.Podman([]string{"run", "--name", "test1", "-v", "/tmp:/foo", "alpine", "date"})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))
Expect(s).Should(ExitCleanly())
c := podmanTest.Podman([]string{"commit", "test1", "newimage"})
c := podmanTest.Podman([]string{"commit", "-q", "test1", "newimage"})
c.WaitWithDefaultTimeout()
Expect(c).Should(Exit(0))
Expect(c).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "newimage"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
image := inspect.InspectImageJSON()
Expect(image[0].Config.Volumes).To(Not(HaveKey("/foo")))
})
@ -201,35 +209,35 @@ var _ = Describe("Podman commit", func() {
SkipIfRemote("--testing Remote Volumes")
s := podmanTest.Podman([]string{"run", "--name", "test1", "-v", "/tmp:/foo", "alpine", "date"})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))
Expect(s).Should(ExitCleanly())
c := podmanTest.Podman([]string{"commit", "--include-volumes", "test1", "newimage"})
c := podmanTest.Podman([]string{"commit", "-q", "--include-volumes", "test1", "newimage"})
c.WaitWithDefaultTimeout()
Expect(c).Should(Exit(0))
Expect(c).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "newimage"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
image := inspect.InspectImageJSON()
Expect(image[0].Config.Volumes).To(HaveKey("/foo"))
r := podmanTest.Podman([]string{"run", "newimage"})
r.WaitWithDefaultTimeout()
Expect(r).Should(Exit(0))
Expect(r).Should(ExitCleanly())
})
It("podman commit container check env variables", func() {
s := podmanTest.Podman([]string{"run", "--name", "test1", "-e", "TEST=1=1-01=9.01", "alpine", "true"})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))
Expect(s).Should(ExitCleanly())
c := podmanTest.Podman([]string{"commit", "test1", "newimage"})
c := podmanTest.Podman([]string{"commit", "-q", "test1", "newimage"})
c.WaitWithDefaultTimeout()
Expect(c).Should(Exit(0))
Expect(c).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "newimage"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
image := inspect.InspectImageJSON()
envMap := make(map[string]bool)
@ -252,9 +260,9 @@ var _ = Describe("Podman commit", func() {
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session := podmanTest.Podman([]string{"commit", "test1", "foobar.com/test1-image:latest", "--iidfile", targetFile})
session := podmanTest.Podman([]string{"commit", "-q", "test1", "foobar.com/test1-image:latest", "--iidfile", targetFile})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
id, _ := os.ReadFile(targetFile)
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
@ -271,16 +279,16 @@ var _ = Describe("Podman commit", func() {
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "--secret", "mysecret", "--name", "secr", ALPINE, "cat", "/run/secrets/mysecret"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(secretsString))
session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"})
session = podmanTest.Podman([]string{"commit", "-q", "secr", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "cat", "/run/secrets/mysecret"})
session.WaitWithDefaultTimeout()
@ -296,16 +304,16 @@ var _ = Describe("Podman commit", func() {
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "printenv", "mysecret"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(secretsString))
session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"})
session = podmanTest.Podman([]string{"commit", "-q", "secr", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "printenv", "mysecret"})
session.WaitWithDefaultTimeout()
@ -316,16 +324,16 @@ var _ = Describe("Podman commit", func() {
name := "testcon"
s := podmanTest.Podman([]string{"run", "--name", name, "-p", "8585:80", ALPINE, "true"})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))
Expect(s).Should(ExitCleanly())
newImageName := "newimage"
c := podmanTest.Podman([]string{"commit", name, newImageName})
c := podmanTest.Podman([]string{"commit", "-q", name, newImageName})
c.WaitWithDefaultTimeout()
Expect(c).Should(Exit(0))
Expect(c).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", newImageName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
images := inspect.InspectImageJSON()
Expect(images).To(HaveLen(1))
Expect(images[0].Config.ExposedPorts).To(HaveKey("80/tcp"))
@ -333,16 +341,16 @@ var _ = Describe("Podman commit", func() {
name = "testcon2"
s = podmanTest.Podman([]string{"run", "--name", name, "-d", NGINX_IMAGE})
s.WaitWithDefaultTimeout()
Expect(s).Should(Exit(0))
Expect(s).Should(ExitCleanly())
newImageName = "newimage2"
c = podmanTest.Podman([]string{"commit", name, newImageName})
c = podmanTest.Podman([]string{"commit", "-q", name, newImageName})
c.WaitWithDefaultTimeout()
Expect(c).Should(Exit(0))
Expect(c).Should(ExitCleanly())
inspect = podmanTest.Podman([]string{"inspect", newImageName})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
images = inspect.InspectImageJSON()
Expect(images).To(HaveLen(1))
Expect(images[0].Config.ExposedPorts).To(HaveKey("80/tcp"))

View File

@ -1,6 +1,7 @@
package integration
import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@ -15,36 +16,36 @@ var _ = Describe("Podman container clone", func() {
SkipIfRootlessCgroupsV1("starting a container with the memory limits not supported")
create := podmanTest.Podman([]string{"create", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", clone.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).To(Exit(0))
Expect(ctrInspect).To(ExitCleanly())
Expect(ctrInspect.InspectContainerToJSON()[0].Name).To(ContainSubstring("-clone1"))
ctrStart := podmanTest.Podman([]string{"container", "start", clone.OutputToString()})
ctrStart.WaitWithDefaultTimeout()
Expect(ctrStart).To(Exit(0))
Expect(ctrStart).To(ExitCleanly())
})
It("podman container clone image test", func() {
create := podmanTest.Podman([]string{"create", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", create.OutputToString(), "new_name", fedoraMinimal})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).To(Exit(0))
Expect(ctrInspect).To(ExitCleanly())
Expect(ctrInspect.InspectContainerToJSON()[0]).To(HaveField("ImageName", fedoraMinimal))
Expect(ctrInspect.InspectContainerToJSON()[0]).To(HaveField("Name", "new_name"))
})
@ -52,14 +53,14 @@ var _ = Describe("Podman container clone", func() {
It("podman container clone name test", func() {
create := podmanTest.Podman([]string{"create", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", "--name", "testing123", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
cloneInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(Exit(0))
Expect(cloneInspect).To(ExitCleanly())
cloneData := cloneInspect.InspectContainerToJSON()
Expect(cloneData[0]).To(HaveField("Name", "testing123"))
})
@ -68,46 +69,46 @@ var _ = Describe("Podman container clone", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
create := podmanTest.Podman([]string{"create", "--cpus=5", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
createInspect := podmanTest.Podman([]string{"inspect", create.OutputToString()})
createInspect.WaitWithDefaultTimeout()
Expect(createInspect).To(Exit(0))
Expect(createInspect).To(ExitCleanly())
createData := createInspect.InspectContainerToJSON()
cloneInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(Exit(0))
Expect(cloneInspect).To(ExitCleanly())
cloneData := cloneInspect.InspectContainerToJSON()
Expect(createData[0].HostConfig).To(HaveField("NanoCpus", cloneData[0].HostConfig.NanoCpus))
create = podmanTest.Podman([]string{"create", "--memory=5", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "--cpus=6", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
createInspect = podmanTest.Podman([]string{"inspect", create.OutputToString()})
createInspect.WaitWithDefaultTimeout()
Expect(createInspect).To(Exit(0))
Expect(createInspect).To(ExitCleanly())
createData = createInspect.InspectContainerToJSON()
cloneInspect = podmanTest.Podman([]string{"inspect", clone.OutputToString()})
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(Exit(0))
Expect(cloneInspect).To(ExitCleanly())
cloneData = cloneInspect.InspectContainerToJSON()
Expect(createData[0].HostConfig).To(HaveField("MemorySwap", cloneData[0].HostConfig.MemorySwap))
create = podmanTest.Podman([]string{"create", "--cpus=5", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "--cpus=4", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
var nanoCPUs int64
numCpus := 4
@ -115,26 +116,26 @@ var _ = Describe("Podman container clone", func() {
createInspect = podmanTest.Podman([]string{"inspect", create.OutputToString()})
createInspect.WaitWithDefaultTimeout()
Expect(createInspect).To(Exit(0))
Expect(createInspect).To(ExitCleanly())
createData = createInspect.InspectContainerToJSON()
cloneInspect = podmanTest.Podman([]string{"inspect", clone.OutputToString()})
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(Exit(0))
Expect(cloneInspect).To(ExitCleanly())
cloneData = cloneInspect.InspectContainerToJSON()
Expect(createData[0].HostConfig.NanoCpus).ToNot(Equal(cloneData[0].HostConfig.NanoCpus))
Expect(cloneData[0].HostConfig).To(HaveField("NanoCpus", nanoCPUs))
create = podmanTest.Podman([]string{"create", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "--cpus=4", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
cloneInspect = podmanTest.Podman([]string{"inspect", clone.OutputToString()})
cloneInspect.WaitWithDefaultTimeout()
Expect(cloneInspect).To(Exit(0))
Expect(cloneInspect).To(ExitCleanly())
cloneData = cloneInspect.InspectContainerToJSON()
Expect(cloneData[0].HostConfig).To(HaveField("MemorySwappiness", int64(0)))
@ -144,33 +145,33 @@ var _ = Describe("Podman container clone", func() {
SkipIfRootlessCgroupsV1("starting a container with the memory limits not supported")
run := podmanTest.Podman([]string{"run", "-dt", "--pod", "new:1234", ALPINE, "sleep", "20"})
run.WaitWithDefaultTimeout()
Expect(run).To(Exit(0))
Expect(run).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", run.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
ctrStart := podmanTest.Podman([]string{"container", "start", clone.OutputToString()})
ctrStart.WaitWithDefaultTimeout()
Expect(ctrStart).To(Exit(0))
Expect(ctrStart).To(ExitCleanly())
checkClone := podmanTest.Podman([]string{"ps", "-f", "id=" + clone.OutputToString(), "--ns", "--format", "{{.Namespaces.IPC}} {{.Namespaces.UTS}} {{.Namespaces.NET}}"})
checkClone.WaitWithDefaultTimeout()
Expect(checkClone).Should(Exit(0))
Expect(checkClone).Should(ExitCleanly())
cloneArray := checkClone.OutputToStringArray()
checkCreate := podmanTest.Podman([]string{"ps", "-f", "id=" + run.OutputToString(), "--ns", "--format", "{{.Namespaces.IPC}} {{.Namespaces.UTS}} {{.Namespaces.NET}}"})
checkCreate.WaitWithDefaultTimeout()
Expect(checkCreate).Should(Exit(0))
Expect(checkCreate).Should(ExitCleanly())
createArray := checkCreate.OutputToStringArray()
Expect(cloneArray).To(ContainElements(createArray))
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
Expect(ctrInspect).Should(ExitCleanly())
runInspect := podmanTest.Podman([]string{"inspect", run.OutputToString()})
runInspect.WaitWithDefaultTimeout()
Expect(runInspect).Should(Exit(0))
Expect(runInspect).Should(ExitCleanly())
Expect(ctrInspect.InspectContainerToJSON()[0].Pod).Should(Equal(runInspect.InspectContainerToJSON()[0].Pod))
Expect(ctrInspect.InspectContainerToJSON()[0].HostConfig.NetworkMode).Should(Equal(runInspect.InspectContainerToJSON()[0].HostConfig.NetworkMode))
@ -179,19 +180,20 @@ var _ = Describe("Podman container clone", func() {
It("podman container clone to a pod", func() {
createPod := podmanTest.Podman([]string{"pod", "create", "--share", "uts", "--name", "foo-pod"})
createPod.WaitWithDefaultTimeout()
Expect(createPod).To(Exit(0))
Expect(createPod).To(ExitCleanly())
ctr := podmanTest.RunTopContainer("ctr")
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(ctr).Should(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", "--name", "cloned", "--pod", "foo-pod", "ctr"})
clone.WaitWithDefaultTimeout()
// Cannot use ExitCleanly() because of warning: "At least one namespace was reset to the default configuration"
Expect(clone).To(Exit(0))
ctrInspect := podmanTest.Podman([]string{"inspect", "cloned"})
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
Expect(ctrInspect).Should(ExitCleanly())
Expect(ctrInspect.InspectContainerToJSON()[0].Pod).Should(Equal(createPod.OutputToString()))
@ -199,15 +201,16 @@ var _ = Describe("Podman container clone", func() {
createPod = podmanTest.Podman([]string{"pod", "create", "--share", "uts,net", "--name", "bar-pod"})
createPod.WaitWithDefaultTimeout()
Expect(createPod).To(Exit(0))
Expect(createPod).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "--name", "cloned2", "--pod", "bar-pod", "ctr"})
clone.WaitWithDefaultTimeout()
// Cannot use ExitCleanly() because of warning: "At least one namespace was reset to the default configuration"
Expect(clone).To(Exit(0))
ctrInspect = podmanTest.Podman([]string{"inspect", "cloned2"})
ctrInspect.WaitWithDefaultTimeout()
Expect(ctrInspect).Should(Exit(0))
Expect(ctrInspect).Should(ExitCleanly())
Expect(ctrInspect.InspectContainerToJSON()[0].Pod).Should(Equal(createPod.OutputToString()))
@ -217,32 +220,32 @@ var _ = Describe("Podman container clone", func() {
It("podman container clone --destroy --force test", func() {
create := podmanTest.Podman([]string{"create", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).To(Exit(0))
Expect(create).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", "--destroy", create.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", create.OutputToString()})
inspect.WaitWithDefaultTimeout()
Expect(inspect).ToNot(Exit(0))
Expect(inspect).ToNot(ExitCleanly())
run := podmanTest.Podman([]string{"run", "-dt", ALPINE})
run := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"})
run.WaitWithDefaultTimeout()
Expect(run).To(Exit(0))
Expect(run).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "--destroy", "-f", run.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
inspect = podmanTest.Podman([]string{"inspect", run.OutputToString()})
inspect.WaitWithDefaultTimeout()
Expect(inspect).ToNot(Exit(0))
Expect(inspect).ToNot(ExitCleanly())
run = podmanTest.Podman([]string{"run", "-dt", ALPINE})
run.WaitWithDefaultTimeout()
Expect(run).To(Exit(0))
Expect(run).To(ExitCleanly())
clone = podmanTest.Podman([]string{"container", "clone", "-f", run.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).ToNot(Exit(0))
Expect(clone).ToNot(ExitCleanly())
})
@ -250,22 +253,22 @@ var _ = Describe("Podman container clone", func() {
networkCreate := podmanTest.Podman([]string{"network", "create", "testing123"})
networkCreate.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork("testing123")
Expect(networkCreate).To(Exit(0))
Expect(networkCreate).To(ExitCleanly())
run := podmanTest.Podman([]string{"run", "--network", "bridge", "-dt", ALPINE})
run.WaitWithDefaultTimeout()
Expect(run).To(Exit(0))
Expect(run).To(ExitCleanly())
connect := podmanTest.Podman([]string{"network", "connect", "testing123", run.OutputToString()})
connect.WaitWithDefaultTimeout()
Expect(connect).To(Exit(0))
Expect(connect).To(ExitCleanly())
clone := podmanTest.Podman([]string{"container", "clone", run.OutputToString()})
clone.WaitWithDefaultTimeout()
Expect(clone).To(Exit(0))
Expect(clone).To(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
inspect.WaitWithDefaultTimeout()
Expect(inspect).To(Exit(0))
Expect(inspect).To(ExitCleanly())
networks := inspect.InspectContainerToJSON()[0].NetworkSettings.Networks
Expect(networks).To(HaveLen(2))
Expect(networks).To(HaveKey("testing123"))
@ -274,28 +277,28 @@ var _ = Describe("Podman container clone", func() {
It("podman container clone env test", func() {
session := podmanTest.Podman([]string{"run", "--name", "env_ctr", "-e", "ENV_TEST=123", ALPINE, "printenv", "ENV_TEST"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "clone", "env_ctr"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "env_ctr-clone"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).Should(ContainSubstring("123"))
session = podmanTest.Podman([]string{"run", "--name", "env_ctr2", "-e", "ENV_TEST=12=3", ALPINE, "printenv", "ENV_TEST"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "clone", "env_ctr2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "env_ctr2-clone"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).Should(ContainSubstring("12=3"))
})

View File

@ -5,9 +5,9 @@ import (
"os"
"path/filepath"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string) {
@ -40,7 +40,7 @@ func createContainersConfFile(pTest *PodmanTestIntegration) {
func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, data string) {
create := pTest.Podman([]string{"create", "--name", cont, image})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
Expect(create).Should(ExitCleanly())
inspect := pTest.InspectContainer(cont)
Expect(inspect).To(HaveLen(1))
@ -51,7 +51,7 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d
volList := pTest.Podman([]string{"volume", "list", "--quiet"})
volList.WaitWithDefaultTimeout()
Expect(volList).Should(Exit(0))
Expect(volList).Should(ExitCleanly())
Expect(volList.OutputToStringArray()).To(HaveLen(1))
Expect(volList.OutputToStringArray()[0]).To(Equal(mntName))
@ -98,6 +98,6 @@ var _ = Describe("Podman create data volume", func() {
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "echo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
})

View File

@ -3,9 +3,9 @@ package integration
import (
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/annotations"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman container inspect", func() {
@ -14,7 +14,7 @@ var _ = Describe("Podman container inspect", func() {
const testContainer = "container-inspect-test-1"
setup := podmanTest.RunTopContainer(testContainer)
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
data := podmanTest.InspectContainer(testContainer)
Expect(data[0].Config.Annotations[annotations.ContainerManager]).
@ -25,7 +25,7 @@ var _ = Describe("Podman container inspect", func() {
name := "testcon"
session := podmanTest.Podman([]string{"run", "-d", "--stop-timeout", "0", "--expose", "8787/udp", "--name", name, ALPINE, "sleep", "inf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
data := podmanTest.InspectContainer(name)
Expect(data).To(HaveLen(1))
@ -37,7 +37,7 @@ var _ = Describe("Podman container inspect", func() {
name := "testcon"
session := podmanTest.Podman([]string{"run", "-d", "--expose", "8989", "--name", name, NGINX_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
data := podmanTest.InspectContainer(name)
Expect(data).To(HaveLen(1))

View File

@ -31,12 +31,12 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf is set to "nofile=500:500"
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("500"))
session = podmanTest.Podman([]string{"run", "--rm", "--ulimit", "nofile=2048:2048", fedoraMinimal, "ulimit", "-n"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("2048"))
// Reset CONTAINERS_CONF to "/dev/null"
@ -44,7 +44,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
os.Setenv("CONTAINERS_CONF", "/dev/null")
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
if IsRemote() {
Expect(session.OutputToString()).To(ContainSubstring("500"))
} else {
@ -58,7 +58,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf is set to "oom_score_adj=999"
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/self/oom_score_adj"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("999"))
raw, err := os.ReadFile("/proc/self/oom_score_adj")
@ -71,7 +71,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
os.Setenv("CONTAINERS_CONF", "/dev/null")
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/self/oom_score_adj"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
if IsRemote() {
Expect(session.OutputToString()).To(Equal("999"))
} else {
@ -104,12 +104,12 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf is set to "pids.max=1234"
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/sys/fs/cgroup/pids.max"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("1234"))
session = podmanTest.Podman([]string{"run", "--rm", "--cgroup-conf", "pids.max=400", ALPINE, "cat", "/sys/fs/cgroup/pids.max"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("400"))
})
@ -117,7 +117,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf default env includes foo
session := podmanTest.Podman([]string{"run", ALPINE, "printenv"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("foo=bar"))
})
@ -125,7 +125,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf devices includes notone
session := podmanTest.Podman([]string{"run", "--device", "/dev/null:/dev/bar", ALPINE, "ls", "/dev"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(
And(
ContainSubstring("bar"),
@ -137,12 +137,12 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf default sets shm-size=201k, which ends up as 200k
session := podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("size=200k"))
session = podmanTest.Podman([]string{"run", "--shm-size", "1g", ALPINE, "grep", "shm", "/proc/self/mounts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("size=1048576k"))
})
@ -150,7 +150,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1")
cap := podmanTest.Podman([]string{"run", ALPINE, "grep", "CapEff", "/proc/self/status"})
cap.WaitWithDefaultTimeout()
Expect(cap).Should(Exit(0))
Expect(cap).Should(ExitCleanly())
os.Setenv("CONTAINERS_CONF", "config/containers-ns.conf")
if IsRemote() {
@ -158,7 +158,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
}
session := podmanTest.Podman([]string{"run", BB, "grep", "CapEff", "/proc/self/status"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).ToNot(Equal(cap.OutputToString()))
})
@ -167,7 +167,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
setup.WaitWithDefaultTimeout()
result := podmanTest.Podman([]string{"top", "test1", "capeff"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(
And(
ContainSubstring("FOWNER"),
@ -184,7 +184,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
setup.WaitWithDefaultTimeout()
result := podmanTest.Podman([]string{"container", "top", "test1", "capeff"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).ToNot(
And(
ContainSubstring("SETUID"),
@ -201,7 +201,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf default ipcns to default to host
session := podmanTest.Podman([]string{"run", ALPINE, "ls", "-l", nspath})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
fields := strings.Split(session.OutputToString(), " ")
ctrNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
@ -214,7 +214,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session = podmanTest.Podman([]string{"run", option, "private", ALPINE, "ls", "-l", nspath})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
fields = strings.Split(session.OutputToString(), " ")
ctrNS = fields[len(fields)-1]
Expect(hostNS).ToNot(Equal(ctrNS))
@ -248,12 +248,12 @@ var _ = Describe("Verify podman containers.conf usage", func() {
}
logc := podmanTest.Podman([]string{"run", "-d", ALPINE, "sh", "-c", "echo podman; sleep 0.1; echo podman; sleep 0.1; echo podman"})
logc.WaitWithDefaultTimeout()
Expect(logc).Should(Exit(0))
Expect(logc).Should(ExitCleanly())
cid := logc.OutputToString()
wait := podmanTest.Podman([]string{"wait", cid})
wait.WaitWithDefaultTimeout()
Expect(wait).Should(Exit(0))
Expect(wait).Should(ExitCleanly())
// Flake prevention: journalctl makes no timeliness guarantees.
time.Sleep(1 * time.Second)
@ -278,55 +278,55 @@ var _ = Describe("Verify podman containers.conf usage", func() {
}
result := podmanTest.Podman([]string{"run", ALPINE, "ls", volume})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("sysctl test", func() {
// containers.conf is set to "net.ipv4.ping_group_range=0 1000"
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/sys/net/ipv4/ping_group_range"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("1000"))
// Ignore containers.conf setting if --net=host
session = podmanTest.Podman([]string{"run", "--rm", "--net", "host", fedoraMinimal, "cat", "/proc/sys/net/ipv4/ping_group_range"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).ToNot((ContainSubstring("1000")))
})
It("search domain", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com")))
})
It("add dns server", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4")))
})
It("add dns option", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug")))
})
It("remove all search domain", func() {
session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
})
It("add search domain", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
Expect(session.OutputToString()).To(
And(
@ -340,13 +340,13 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf timezone set to Pacific/Honolulu
session := podmanTest.Podman([]string{"run", "--tz", "", ALPINE, "date", "+'%H %Z'"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("HST"))
// verify flag still overrides
session = podmanTest.Podman([]string{"run", "--tz", "EST", ALPINE, "date", "+'%H %Z'"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("EST"))
})
@ -358,14 +358,14 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("0002"))
})
It("network slirp options to allow host loopback", func() {
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns", ALPINE, "ping", "-c1", "10.0.2.2"})
session.Wait(30)
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman-remote test localcontainers.conf", func() {
@ -376,13 +376,13 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// env
session := podmanTest.Podman([]string{"run", ALPINE, "printenv", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("bar"))
// dns-search, server, options
session = podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
Expect(session.OutputToString()).To(
And(
@ -394,26 +394,26 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// sysctls
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/sys/net/ipv4/ping_group_range"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("1000"))
// shm-size
session = podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("size=200k"))
// ulimits
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("500"))
// Configuration that comes from remote client
// Timezone
session = podmanTest.Podman([]string{"run", ALPINE, "date", "+'%H %Z'"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(
Or(
ContainSubstring("EST"),
@ -423,7 +423,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// Umask
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("0022"))
})
@ -431,7 +431,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// containers.conf is set to "run.oci.keep_original_groups=1"
session := podmanTest.Podman([]string{"create", "--rm", "--name", "test", fedoraMinimal})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .Config.Annotations }}", "test"})
inspect.WaitWithDefaultTimeout()
@ -446,18 +446,18 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session = podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", "--no-hosts=false", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("no-hosts=true /etc/hosts does not include hostname", func() {
session := podmanTest.Podman([]string{"run", "--rm", "--name", "test", ALPINE, "cat", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).ToNot(ContainSubstring("test"))
session = podmanTest.Podman([]string{"run", "--rm", "--name", "test", "--no-hosts=false", ALPINE, "cat", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("test"))
})
@ -476,7 +476,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.Security.SECCOMPProfilePath}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(profile))
})
@ -494,7 +494,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/var/tmp"))
storagePath := filepath.Join(podmanTest.TempDir, "storage")
@ -511,7 +511,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/foobar"))
containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=%q", storagePath))
@ -523,7 +523,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(storagePath))
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
@ -539,7 +539,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
os.Setenv("TMPDIR", "/hoge")
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/hoge"))
os.Unsetenv("TMPDIR")
}
@ -551,7 +551,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
result := podmanTest.Podman([]string{"system", "service", "--help"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring("(default 1234)"))
})
@ -624,7 +624,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
result := podmanTest.Podman([]string{"create", ALPINE, "true"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
inspect.WaitWithDefaultTimeout()
@ -636,7 +636,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
}
result = podmanTest.Podman([]string{"create", ALPINE, "true"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
inspect = podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
inspect.WaitWithDefaultTimeout()
@ -645,7 +645,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
// Check we can also create a pod when cgroups=disabled
result = podmanTest.Podman([]string{"pod", "create"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman containers.conf runtime", func() {
@ -657,7 +657,7 @@ var _ = Describe("Verify podman containers.conf usage", func() {
os.Setenv("CONTAINERS_CONF", conffile)
result := podmanTest.Podman([]string{"--help"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring("Path to the OCI-compatible binary used to run containers. (default \"testruntime\")"))
})
@ -683,11 +683,11 @@ var _ = Describe("Verify podman containers.conf usage", func() {
Expect(podman.ErrorToString()).Should(ContainSubstring("invalid default_rootless_network_cmd option \"invalid\""))
continue
}
Expect(podman).Should(Exit(0))
Expect(podman).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{.HostConfig.NetworkMode}}", mode})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
Expect(inspect.OutputToString()).Should(Equal(mode))
}
})

View File

@ -9,7 +9,6 @@ import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
// NOTE: Only smoke tests. The system tests (i.e., "./test/system/*") take
@ -33,7 +32,7 @@ var _ = Describe("Podman cp", func() {
// Create a container. NOTE that container mustn't be running for copying.
session := podmanTest.Podman([]string{"create", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
name := session.OutputToString()
// Copy TO the container.
@ -46,7 +45,7 @@ var _ = Describe("Podman cp", func() {
// The file will now be created (and written to).
session = podmanTest.Podman([]string{"cp", srcFile.Name(), name + ":foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Copy FROM the container.
@ -57,11 +56,11 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", name + ":foo", destFile.Name()})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", name})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Now make sure the content matches.
roundtripContent, err := os.ReadFile(destFile.Name())
@ -84,17 +83,17 @@ var _ = Describe("Podman cp", func() {
// Create a container. NOTE that container mustn't be running for copying.
session := podmanTest.Podman([]string{"create", "--pid=host", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
name := session.OutputToString()
session = podmanTest.Podman([]string{"start", name})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// The file will now be created (and written to).
session = podmanTest.Podman([]string{"cp", srcFile.Name(), name + ":foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Copy FROM the container.
@ -105,7 +104,7 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", name + ":foo", destFile.Name()})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Now make sure the content matches.
roundtripContent, err := os.ReadFile(destFile.Name())
@ -128,25 +127,25 @@ var _ = Describe("Podman cp", func() {
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
name := session.OutputToString()
session = podmanTest.Podman([]string{"exec", name, "ln", "-s", "/tmp", "/test"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"cp", "--pause=false", srcFile.Name(), name + ":/test"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", name, "cat", "/tmp/" + filepath.Base(srcFile.Name())})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(string(originalContent)))
session = podmanTest.Podman([]string{"exec", name, "cat", "/test/" + filepath.Base(srcFile.Name())})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(string(originalContent)))
})
@ -166,21 +165,21 @@ var _ = Describe("Podman cp", func() {
Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"volume", "create", "data"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", "-v", "data:/data", "--name", "container1", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"cp", srcFile.Name(), "container1" + ":/data/file.txt"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Now get the volume's mount point, read the file and make
// sure the contents match.
session = podmanTest.Podman([]string{"volume", "inspect", "data", "--format", "{{.Mountpoint}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
volumeMountPoint := session.OutputToString()
copiedContent, err := os.ReadFile(filepath.Join(volumeMountPoint, "file.txt"))
@ -199,19 +198,19 @@ var _ = Describe("Podman cp", func() {
setup := podmanTest.RunTopContainer("testctr")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "testctr", "adduser", "-S", "testuser"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "-u", "testuser", "testctr", "touch", "/tmp/testfile"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"cp", "--pause=false", "testctr:/tmp/testfile", srcFile.Name()})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// owner of the file copied to local machine is not testuser
u, err := user.Current()
@ -223,12 +222,12 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", "--pause=false", srcFile.Name(), "testctr:testfile2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// owner of the file copied to a container is the root user
session = podmanTest.Podman([]string{"exec", "testctr", "ls", "-l", "testfile2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("root"))
})
@ -237,17 +236,17 @@ var _ = Describe("Podman cp", func() {
container := "copyroottohost"
session := podmanTest.RunTopContainer(container)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", container, "touch", "/dummy.txt"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
tmpDir := GinkgoT().TempDir()
session = podmanTest.Podman([]string{"cp", container + ":/", tmpDir})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cmd := exec.Command("ls", "-la", tmpDir)
output, err := cmd.Output()

View File

@ -21,7 +21,7 @@ var _ = Describe("Podman create with --ip flag", func() {
SkipIfRootless("--ip not supported without network in rootless mode")
result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "203.0.113.124", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
result = podmanTest.Podman([]string{"start", "test"})
result.WaitWithDefaultTimeout()
@ -36,11 +36,11 @@ var _ = Describe("Podman create with --ip flag", func() {
if isRootless() {
Expect(result).Should(Exit(125))
} else {
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
result = podmanTest.Podman([]string{"start", "-a", "test"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring(ip + "/16"))
}
})
@ -50,20 +50,20 @@ var _ = Describe("Podman create with --ip flag", func() {
ip := GetSafeIPAddress()
result := podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test1", "--ip", ip, ALPINE, "sleep", "999"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
result = podmanTest.Podman([]string{"create", "--log-driver", "k8s-file", "--name", "test2", "--ip", ip, ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
result = podmanTest.Podman([]string{"start", "test1"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
// race prevention: wait until IP address is assigned and
// container is running.
for i := 0; i < 5; i++ {
result = podmanTest.Podman([]string{"inspect", "--format", "{{.State.Status}} {{.NetworkSettings.IPAddress}}", "test1"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
if result.OutputToString() == "running "+ip {
break
}

View File

@ -1,6 +1,7 @@
package integration
import (
. "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -15,7 +16,7 @@ var _ = Describe("Podman run with --mac-address flag", func() {
if isRootless() {
Expect(result).Should(Exit(125))
} else {
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:0a:29:34"))
}
})
@ -25,11 +26,11 @@ var _ = Describe("Podman run with --mac-address flag", func() {
session := podmanTest.Podman([]string{"network", "create", net})
session.WaitWithDefaultTimeout()
defer podmanTest.removeNetwork(net)
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
result := podmanTest.Podman([]string{"run", "--network", net, "--mac-address", "92:d0:c6:00:29:34", ALPINE, "ip", "addr"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:00:29:34"))
})
})

View File

@ -20,7 +20,7 @@ var _ = Describe("Podman create", func() {
session := podmanTest.Podman([]string{"create", "--name", "local_image_test", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
cid := session.OutputToString()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
check := podmanTest.Podman([]string{"inspect", "local_image_test"})
@ -30,22 +30,22 @@ var _ = Describe("Podman create", func() {
})
It("podman create container based on a remote image", func() {
session := podmanTest.Podman([]string{"create", BB_GLIBC, "ls"})
session := podmanTest.Podman([]string{"create", "-q", BB_GLIBC, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
})
It("podman container create container based on a remote image", func() {
containerCreate := podmanTest.Podman([]string{"container", "create", BB_GLIBC, "ls"})
containerCreate := podmanTest.Podman([]string{"container", "create", "-q", BB_GLIBC, "ls"})
containerCreate.WaitWithDefaultTimeout()
Expect(containerCreate).Should(Exit(0))
Expect(containerCreate).Should(ExitCleanly())
lock := GetPortLock("5000")
defer lock.Unlock()
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@ -53,21 +53,21 @@ var _ = Describe("Podman create", func() {
create := podmanTest.Podman([]string{"container", "create", "--tls-verify=false", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
Expect(create).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(3))
})
It("podman create using short options", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
})
It("podman create using existing name", func() {
session := podmanTest.Podman([]string{"create", "--name=foo", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
session = podmanTest.Podman([]string{"create", "--name=foo", ALPINE, "ls"})
@ -78,7 +78,7 @@ var _ = Describe("Podman create", func() {
It("podman create adds annotation", func() {
session := podmanTest.Podman([]string{"create", "--annotation", "HELLO=WORLD", "--name", "annotate_test", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
check := podmanTest.Podman([]string{"inspect", "annotate_test"})
@ -90,24 +90,24 @@ var _ = Describe("Podman create", func() {
It("podman create --entrypoint command", func() {
session := podmanTest.Podman([]string{"create", "--name", "entrypoint_test", "--entrypoint", "/bin/foobar", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
result := podmanTest.Podman([]string{"inspect", "entrypoint_test", "--format", "{{.Config.Entrypoint}}"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(Equal("/bin/foobar"))
})
It("podman create --entrypoint \"\"", func() {
session := podmanTest.Podman([]string{"create", "--entrypoint", "", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
result := podmanTest.Podman([]string{"inspect", session.OutputToString(), "--format", "{{.Config.Entrypoint}}"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(Equal(""))
})
@ -115,12 +115,12 @@ var _ = Describe("Podman create", func() {
jsonString := `[ "/bin/foo", "-c"]`
session := podmanTest.Podman([]string{"create", "--name", "entrypoint_json", "--entrypoint", jsonString, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
result := podmanTest.Podman([]string{"inspect", "entrypoint_json", "--format", "{{.Config.Entrypoint}}"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(Equal("/bin/foo -c"))
})
@ -134,11 +134,11 @@ var _ = Describe("Podman create", func() {
session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "test"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).ToNot(ContainSubstring("cannot touch"))
})
@ -152,26 +152,26 @@ var _ = Describe("Podman create", func() {
Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "test"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("/create/test rw"))
session = podmanTest.Podman([]string{"create", "--name", "test_ro", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,ro", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "test_ro"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("/create/test ro"))
session = podmanTest.Podman([]string{"create", "--name", "test_shared", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,shared", mountPath), ALPINE, "awk", `$5 == "/create/test" { print $6 " " $7}`, "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "test_shared"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("rw"))
Expect(session.OutputToString()).To(ContainSubstring("shared"))
@ -180,17 +180,17 @@ var _ = Describe("Podman create", func() {
Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"create", "--name", "test_tmpfs", "--mount", "type=tmpfs,target=/create/test", ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"start", "-a", "test_tmpfs"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("/create/test rw,nosuid,nodev,relatime - tmpfs"))
})
It("podman create --pod automatically", func() {
session := podmanTest.Podman([]string{"create", "--pod", "new:foobar", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
check.WaitWithDefaultTimeout()
@ -213,11 +213,11 @@ var _ = Describe("Podman create", func() {
// Now, let's create a pod with --pod-id-file.
session = podmanTest.Podman([]string{"pod", "create", "--pod-id-file", podIDFile, "--name", podName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"pod", "inspect", podName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
podData := session.InspectPodToJSON()
@ -225,7 +225,7 @@ var _ = Describe("Podman create", func() {
// some checks to make sure it's working as expected.
session = podmanTest.Podman([]string{"create", "--pod-id-file", podIDFile, "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
ctrJSON := podmanTest.InspectContainer(ctrName)
Expect(podData).To(HaveField("ID", ctrJSON[0].Pod)) // Make sure the container's pod matches the pod's ID
@ -235,7 +235,7 @@ var _ = Describe("Podman create", func() {
name := "test101"
create := podmanTest.Podman([]string{"create", "--name", name, REDIS_IMAGE})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
Expect(create).Should(ExitCleanly())
ctrJSON := podmanTest.InspectContainer(name)
Expect(ctrJSON).To(HaveLen(1))
@ -252,19 +252,20 @@ var _ = Describe("Podman create", func() {
session = podmanTest.Podman([]string{"create", "--pull", "always", "--name=foo", "testimage:00000000"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.ErrorToString()).To(ContainSubstring("Copying blob"), "progress message from pull")
})
It("podman create using image list by tag", func() {
session := podmanTest.Podman([]string{"create", "--pull=always", "--arch=arm64", "--name=foo", ALPINELISTTAG})
session := podmanTest.Podman([]string{"create", "-q", "--pull=always", "--arch=arm64", "--name=foo", ALPINELISTTAG})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG))
})
@ -272,41 +273,42 @@ var _ = Describe("Podman create", func() {
session := podmanTest.Podman([]string{"create", "--pull=always", "--arch=arm64", "--name=foo", ALPINELISTDIGEST})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"), "progress message from pull")
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST))
})
It("podman create using image list instance by digest", func() {
session := podmanTest.Podman([]string{"create", "--pull=always", "--arch=arm64", "--name=foo", ALPINEARM64DIGEST})
session := podmanTest.Podman([]string{"create", "-q", "--pull=always", "--arch=arm64", "--name=foo", ALPINEARM64DIGEST})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST))
})
It("podman create using cross-arch image list instance by digest", func() {
session := podmanTest.Podman([]string{"create", "--pull=always", "--arch=arm64", "--name=foo", ALPINEARM64DIGEST})
session := podmanTest.Podman([]string{"create", "-q", "--pull=always", "--arch=arm64", "--name=foo", ALPINEARM64DIGEST})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST))
})
@ -323,13 +325,13 @@ var _ = Describe("Podman create", func() {
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
session = podmanTest.Podman([]string{"create", "--pull=always", "--signature-policy", "/etc/containers/policy.json", ALPINE})
session = podmanTest.Podman([]string{"create", "-q", "--pull=always", "--signature-policy", "/etc/containers/policy.json", ALPINE})
session.WaitWithDefaultTimeout()
if IsRemote() {
Expect(session).To(ExitWithError())
Expect(session.ErrorToString()).To(ContainSubstring("unknown flag"))
} else {
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
}
})
@ -338,7 +340,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testctr"
session := podmanTest.Podman([]string{"create", "--label", "TESTKEY1=", "--label", "TESTKEY2", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -354,7 +356,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testctr"
session := podmanTest.Podman([]string{"create", "--label", "TESTKEY1=value1", "--label", "TESTKEY2=bar", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -369,7 +371,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testctr"
session := podmanTest.Podman([]string{"create", "-t", "--restart", "on-failure:5", "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -390,7 +392,7 @@ var _ = Describe("Podman create", func() {
unlessStopped := "unless-stopped"
session := podmanTest.Podman([]string{"create", "-t", "--restart", unlessStopped, "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -405,7 +407,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testCtr"
session := podmanTest.Podman([]string{"create", "-t", "-m", fmt.Sprintf("%db", numMem), "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -421,7 +423,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testCtr"
session := podmanTest.Podman([]string{"create", "-t", "--cpus", fmt.Sprintf("%d", numCpus), "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -441,7 +443,7 @@ var _ = Describe("Podman create", func() {
for i := 0; i < 5; i++ {
session = podmanTest.Podman([]string{"create", "--replace", "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
}
})
@ -449,7 +451,7 @@ var _ = Describe("Podman create", func() {
ctrName := "testCtr"
session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "/bin/sh"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", ctrName})
inspect.WaitWithDefaultTimeout()
@ -536,7 +538,7 @@ var _ = Describe("Podman create", func() {
name := "createwithstaticip"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod).Should(Exit(0))
Expect(pod).Should(ExitCleanly())
session := podmanTest.Podman([]string{"create", "--pod", name, "--ip", "192.168.1.2", ALPINE, "top"})
session.WaitWithDefaultTimeout()
@ -548,7 +550,7 @@ var _ = Describe("Podman create", func() {
name := "createwithstaticmac"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod).Should(Exit(0))
Expect(pod).Should(ExitCleanly())
session := podmanTest.Podman([]string{"create", "--pod", name, "--mac-address", "52:54:00:6d:2f:82", ALPINE, "top"})
session.WaitWithDefaultTimeout()
@ -559,24 +561,24 @@ var _ = Describe("Podman create", func() {
name := "createwithnetwork"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod).Should(Exit(0))
Expect(pod).Should(ExitCleanly())
netName := "pod" + stringid.GenerateRandomID()
session := podmanTest.Podman([]string{"network", "create", netName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
defer podmanTest.removeNetwork(netName)
session = podmanTest.Podman([]string{"create", "--pod", name, "--network", netName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("create container in pod with ports should fail", func() {
name := "createwithports"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod).Should(Exit(0))
Expect(pod).Should(ExitCleanly())
session := podmanTest.Podman([]string{"create", "--pod", name, "-p", "8086:80", ALPINE, "top"})
session.WaitWithDefaultTimeout()
@ -587,7 +589,7 @@ var _ = Describe("Podman create", func() {
name := "createwithpublishports"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod).Should(Exit(0))
Expect(pod).Should(ExitCleanly())
session := podmanTest.Podman([]string{"create", "--pod", name, "-P", ALPINE, "top"})
session.WaitWithDefaultTimeout()
@ -595,21 +597,21 @@ var _ = Describe("Podman create", func() {
})
It("create use local store image if input image contains a manifest list", func() {
session := podmanTest.Podman([]string{"pull", BB})
session := podmanTest.Podman([]string{"pull", "-q", BB})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"manifest", "create", "mylist"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"manifest", "add", "--all", "mylist", BB})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", "mylist"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman create -d should fail, can not detach create containers", func() {
@ -644,16 +646,16 @@ var _ = Describe("Podman create", func() {
session = podmanTest.Podman([]string{"create", "-q", "--platform=linux/arm64", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
setup := podmanTest.Podman([]string{"container", "inspect", session.OutputToString()})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
data := setup.InspectContainerToJSON()
setup = podmanTest.Podman([]string{"image", "inspect", data[0].Image})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
idata := setup.InspectImageJSON() // returns []inspect.ImageData
Expect(idata).To(HaveLen(1))
@ -664,12 +666,12 @@ var _ = Describe("Podman create", func() {
It("podman create --uid/gidmap --pod conflict test", func() {
create := podmanTest.Podman([]string{"create", "--uidmap", "0:1000:1000", "--pod", "new:testing123", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).ShouldNot(Exit(0))
Expect(create).ShouldNot(ExitCleanly())
Expect(create.ErrorToString()).To(ContainSubstring("cannot specify a new uid/gid map when entering a pod with an infra container"))
create = podmanTest.Podman([]string{"create", "--gidmap", "0:1000:1000", "--pod", "new:testing1234", ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).ShouldNot(Exit(0))
Expect(create).ShouldNot(ExitCleanly())
Expect(create.ErrorToString()).To(ContainSubstring("cannot specify a new uid/gid map when entering a pod with an infra container"))
})
@ -677,11 +679,11 @@ var _ = Describe("Podman create", func() {
It("podman create --chrootdirs inspection test", func() {
session := podmanTest.Podman([]string{"create", "--chrootdirs", "/var/local/qwerty", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
setup := podmanTest.Podman([]string{"container", "inspect", session.OutputToString()})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
data := setup.InspectContainerToJSON()
Expect(data).To(HaveLen(1))
@ -692,32 +694,32 @@ var _ = Describe("Podman create", func() {
It("podman create --chrootdirs functionality test", func() {
session := podmanTest.Podman([]string{"create", "-t", "--chrootdirs", "/var/local/qwerty", ALPINE, "/bin/cat"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
ctrID := session.OutputToString()
setup := podmanTest.Podman([]string{"start", ctrID})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
setup = podmanTest.Podman([]string{"exec", ctrID, "cmp", "/etc/resolv.conf", "/var/local/qwerty/etc/resolv.conf"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
})
It("create container with name subset of existing ID", func() {
create1 := podmanTest.Podman([]string{"create", "-t", ALPINE, "top"})
create1.WaitWithDefaultTimeout()
Expect(create1).Should(Exit(0))
Expect(create1).Should(ExitCleanly())
ctr1ID := create1.OutputToString()
ctr2Name := ctr1ID[:5]
create2 := podmanTest.Podman([]string{"create", "-t", "--name", ctr2Name, ALPINE, "top"})
create2.WaitWithDefaultTimeout()
Expect(create2).Should(Exit(0))
Expect(create2).Should(ExitCleanly())
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{.Name}}", ctr2Name})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect).Should(ExitCleanly())
Expect(inspect.OutputToString()).Should(Equal(ctr2Name))
})
})

View File

@ -7,10 +7,10 @@ import (
"time"
"github.com/containers/podman/v4/libpod/events"
. "github.com/containers/podman/v4/test/utils"
"github.com/containers/storage/pkg/stringid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman events", func() {
@ -25,7 +25,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events with an event filter", func() {
@ -33,7 +33,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of events")
date := time.Now().Format("2006-01-02")
Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(date)), "event log has correct timestamp")
@ -47,13 +47,13 @@ var _ = Describe("Podman events", func() {
resultPrefix := podmanTest.Podman([]string{"events", "--stream=false", "--filter", fmt.Sprintf("volume=%s", vname[:5])})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(vname), "event log includes volume name")
resultPrefix.WaitWithDefaultTimeout()
Expect(resultPrefix).Should(Exit(0))
Expect(resultPrefix).Should(ExitCleanly())
events = resultPrefix.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(vname), "event log includes volume name")
@ -67,7 +67,7 @@ var _ = Describe("Podman events", func() {
time.Sleep(5 * time.Second)
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start", "--filter", fmt.Sprintf("container=%s", cid)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
Expect(events).To(HaveLen(1), "number of events")
Expect(events[0]).To(ContainSubstring(cid), "event log includes CID")
@ -79,7 +79,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", fmt.Sprintf("container=%s", cid)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(BeEmpty())
})
@ -88,11 +88,11 @@ var _ = Describe("Podman events", func() {
setup.WaitWithDefaultTimeout()
stop := podmanTest.Podman([]string{"pod", "stop", "foobarpod"})
stop.WaitWithDefaultTimeout()
Expect(stop).Should(Exit(0))
Expect(setup).Should(Exit(0))
Expect(stop).Should(ExitCleanly())
Expect(setup).Should(ExitCleanly())
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", "pod=foobarpod"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
events := result.OutputToStringArray()
GinkgoWriter.Println(events)
Expect(len(events)).To(BeNumerically(">=", 2), "Number of events")
@ -106,7 +106,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--since", "1m"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events --until", func() {
@ -114,7 +114,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"events", "--stream=false", "--until", "1h"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman events format", func() {
@ -123,7 +123,7 @@ var _ = Describe("Podman events", func() {
test := podmanTest.Podman([]string{"events", "--stream=false", "--format", "json"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
jsonArr := test.OutputToStringArray()
Expect(test.OutputToStringArray()).ShouldNot(BeEmpty())
@ -134,7 +134,7 @@ var _ = Describe("Podman events", func() {
test = podmanTest.Podman([]string{"events", "--stream=false", "--format", "{{json.}}"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
jsonArr = test.OutputToStringArray()
Expect(test.OutputToStringArray()).ShouldNot(BeEmpty())
@ -145,7 +145,7 @@ var _ = Describe("Podman events", func() {
test = podmanTest.Podman([]string{"events", "--stream=false", "--filter=type=container", "--format", "ID: {{.ID}}"})
test.WaitWithDefaultTimeout()
Expect(test).To(Exit(0))
Expect(test).To(ExitCleanly())
arr := test.OutputToStringArray()
Expect(len(arr)).To(BeNumerically(">", 1))
Expect(arr[0]).To(MatchRegexp("ID: [a-fA-F0-9]{64}"))
@ -157,7 +157,7 @@ var _ = Describe("Podman events", func() {
name3 := stringid.GenerateRandomID()
session := podmanTest.Podman([]string{"create", "--name", name1, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
var wg sync.WaitGroup
wg.Add(1)
@ -169,17 +169,17 @@ var _ = Describe("Podman events", func() {
time.Sleep(time.Second * 2)
session = podmanTest.Podman([]string{"create", "--name", name2, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", "--name", name3, ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
}()
// unix timestamp in 10 seconds
until := time.Now().Add(time.Second * 10).Unix()
result := podmanTest.Podman([]string{"events", "--since", "30s", "--until", fmt.Sprint(until)})
result.Wait(11)
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(ContainSubstring(name1))
Expect(result.OutputToString()).To(ContainSubstring(name2))
Expect(result.OutputToString()).To(ContainSubstring(name3))
@ -188,7 +188,7 @@ var _ = Describe("Podman events", func() {
untilT := time.Now().Add(time.Second * 9)
result = podmanTest.Podman([]string{"events", "--since", "30s", "--until", "10s"})
result.Wait(11)
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
tEnd := time.Now()
outDur := tEnd.Sub(untilT)
Expect(outDur.Seconds()).To(BeNumerically(">", 0), "duration")
@ -202,29 +202,29 @@ var _ = Describe("Podman events", func() {
It("podman events pod creation", func() {
create := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", "foobarpod"})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
Expect(create).Should(ExitCleanly())
id := create.OutputToString()
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "pod=" + id})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(1))
Expect(result.OutputToString()).To(ContainSubstring("create"))
ctrName := "testCtr"
run := podmanTest.Podman([]string{"create", "--pod", id, "--name", ctrName, ALPINE, "top"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
Expect(run).Should(ExitCleanly())
result2 := podmanTest.Podman([]string{"events", "--stream=false", "--filter", fmt.Sprintf("container=%s", ctrName), "--since", "30s"})
result2.WaitWithDefaultTimeout()
Expect(result2).Should(Exit(0))
Expect(result2).Should(ExitCleanly())
Expect(result2.OutputToString()).To(ContainSubstring(fmt.Sprintf("pod_id=%s", id)))
})
It("podman events health_status generated", func() {
session := podmanTest.Podman([]string{"run", "--name", "test-hc", "-dt", "--health-cmd", "echo working", "busybox"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
for i := 0; i < 5; i++ {
hc := podmanTest.Podman([]string{"healthcheck", "run", "test-hc"})
@ -238,7 +238,7 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of health_status events")
})

View File

@ -29,49 +29,49 @@ var _ = Describe("Podman exec", func() {
It("podman exec simple command", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "test1", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman container exec simple command", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"container", "exec", "test1", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman exec simple command using latest", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
cid := "-l"
if IsRemote() {
cid = "test1"
}
session := podmanTest.Podman([]string{"exec", cid, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman exec environment test", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("BAR"))
session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/bin"))
})
@ -79,12 +79,12 @@ var _ = Describe("Podman exec", func() {
// remote doesn't properly interpret os.Setenv
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
os.Setenv("FOO", "BAR")
session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("BAR"))
os.Unsetenv("FOO")
})
@ -92,7 +92,7 @@ var _ = Describe("Podman exec", func() {
It("podman exec exit code", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "test1", "sh", "-c", "exit 100"})
session.WaitWithDefaultTimeout()
@ -104,63 +104,63 @@ var _ = Describe("Podman exec", func() {
ctrName := "testctr1"
testCtr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, "--userns=keep-id", ALPINE, "top"})
testCtr.WaitWithDefaultTimeout()
Expect(testCtr).Should(Exit(0))
Expect(testCtr).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", ctrName, "grep", "CapEff", "/proc/self/status"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("0000000000000000"))
})
It("podman exec --privileged", func() {
session := podmanTest.Podman([]string{"run", "--privileged", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
session = podmanTest.Podman([]string{"run", "--privileged", "--rm", ALPINE, "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
effPerms := session.OutputToString()
setup := podmanTest.RunTopContainer("test-privileged")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
})
It("podman exec --privileged", func() {
session := podmanTest.Podman([]string{"run", "--privileged", "--user=bin", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
session = podmanTest.Podman([]string{"run", "--privileged", "--user=bin", "--rm", ALPINE, "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
effPerms := session.OutputToString()
setup := podmanTest.RunTopContainer("test-privileged")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
})
@ -168,52 +168,52 @@ var _ = Describe("Podman exec", func() {
It("podman exec --privileged", func() {
session := podmanTest.Podman([]string{"run", "--privileged", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
setup := podmanTest.RunTopContainer("test-privileged")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("00000000"))
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
})
It("podman exec --privileged container not running as root", func() {
session := podmanTest.Podman([]string{"run", "--privileged", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
setup := podmanTest.RunTopContainerWithArgs("test-privileged", []string{"--user=bin"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("00000000"))
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("00000000"))
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=root", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
session = podmanTest.Podman([]string{"exec", "--privileged", "--user=bin", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
})
@ -221,26 +221,26 @@ var _ = Describe("Podman exec", func() {
capAdd := "--cap-add=net_bind_service"
session := podmanTest.Podman([]string{"run", "--user=bin", capAdd, "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
session = podmanTest.Podman([]string{"run", "--user=bin", capAdd, "--rm", ALPINE, "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
effPerms := session.OutputToString()
setup := podmanTest.RunTopContainerWithArgs("test-privileged", []string{"--user=bin", capAdd})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
})
@ -249,62 +249,62 @@ var _ = Describe("Podman exec", func() {
capDrop := "--cap-drop=all"
session := podmanTest.Podman([]string{"run", "--user=bin", capDrop, capAdd, "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bndPerms := session.OutputToString()
session = podmanTest.Podman([]string{"run", "--user=bin", capDrop, capAdd, "--rm", ALPINE, "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
effPerms := session.OutputToString()
setup := podmanTest.RunTopContainerWithArgs("test-privileged", []string{"--user=bin", capDrop, capAdd})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bndPerms))
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapInh /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapPrm /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
session = podmanTest.Podman([]string{"exec", "test-privileged", "sh", "-c", "grep ^CapAmb /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(effPerms))
})
It("podman exec --privileged with user", func() {
session := podmanTest.Podman([]string{"run", "--privileged", "--user=bin", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
bindPerms := session.OutputToString()
setup := podmanTest.RunTopContainerWithArgs("test-privileged", []string{"--privileged", "--user=bin"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(bindPerms))
session = podmanTest.Podman([]string{"exec", "--privileged", "test-privileged", "sh", "-c", "grep ^CapEff /proc/self/status | cut -f 2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("0000000000000000"))
})
@ -313,48 +313,49 @@ var _ = Describe("Podman exec", func() {
setup := podmanTest.Podman([]string{"run", "-dti", "--name", "test1", fedoraMinimal, "sleep", "+Inf"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup.ErrorToString()).To(ContainSubstring("The input device is not a TTY. The --tty and --interactive flags might not work properly"))
for i := 0; i < 5; i++ {
session := podmanTest.Podman([]string{"exec", "-ti", "test1", "true"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
}
})
It("podman exec pseudo-terminal sanity check", func() {
setup := podmanTest.Podman([]string{"run", "--detach", "--name", "test1", fedoraMinimal, "sleep", "+Inf"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(" onlcr"))
})
It("podman exec simple command with user", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "--user", "root", "test1", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman exec with user only in container", func() {
testUser := "test123"
setup := podmanTest.Podman([]string{"run", "--name", "test1", "-d", fedoraMinimal, "sleep", "60"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "test1", "useradd", testUser})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session2 := podmanTest.Podman([]string{"exec", "--user", testUser, "test1", "whoami"})
session2.WaitWithDefaultTimeout()
Expect(session2).Should(Exit(0))
Expect(session2).Should(ExitCleanly())
Expect(session2.OutputToString()).To(Equal(testUser))
})
@ -362,41 +363,41 @@ var _ = Describe("Podman exec", func() {
testUser := "guest"
setup := podmanTest.Podman([]string{"run", "--user", testUser, "-d", ALPINE, "top"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
ctrID := setup.OutputToString()
session := podmanTest.Podman([]string{"exec", ctrID, "whoami"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(testUser))
overrideUser := "root"
session = podmanTest.Podman([]string{"exec", "--user", overrideUser, ctrID, "whoami"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(overrideUser))
})
It("podman exec simple working directory test", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/tmp"))
session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("/tmp"))
})
It("podman exec missing working directory test", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "--workdir", "/missing", "test1", "pwd"})
session.WaitWithDefaultTimeout()
@ -411,7 +412,7 @@ var _ = Describe("Podman exec", func() {
SkipIfNotFedora("FIXME: #19552 fails on Debian SID w/ runc 1.1.5")
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "test1", "/etc"})
session.WaitWithDefaultTimeout()
@ -421,7 +422,7 @@ var _ = Describe("Podman exec", func() {
It("podman exec command not found", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
session := podmanTest.Podman([]string{"exec", "test1", "notthere"})
session.WaitWithDefaultTimeout()
@ -431,7 +432,7 @@ var _ = Describe("Podman exec", func() {
It("podman exec preserve fds sanity check", func() {
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
Expect(setup).Should(ExitCleanly())
devNull, err := os.Open("/dev/null")
Expect(err).ToNot(HaveOccurred())
@ -441,7 +442,7 @@ var _ = Describe("Podman exec", func() {
}
session := podmanTest.PodmanExtraFiles([]string{"exec", "--preserve-fds", "1", "test1", "ls"}, files)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman exec preserves --group-add groups", func() {
@ -450,21 +451,21 @@ var _ = Describe("Podman exec", func() {
ctrName1 := "ctr1"
ctr1 := podmanTest.Podman([]string{"run", "--name", ctrName1, fedoraMinimal, "groupadd", "-g", gid, groupName})
ctr1.WaitWithDefaultTimeout()
Expect(ctr1).Should(Exit(0))
Expect(ctr1).Should(ExitCleanly())
imgName := "img1"
commit := podmanTest.Podman([]string{"commit", ctrName1, imgName})
commit := podmanTest.Podman([]string{"commit", "-q", ctrName1, imgName})
commit.WaitWithDefaultTimeout()
Expect(commit).Should(Exit(0))
Expect(commit).Should(ExitCleanly())
ctrName2 := "ctr2"
ctr2 := podmanTest.Podman([]string{"run", "-d", "--name", ctrName2, "--group-add", groupName, imgName, "sleep", "300"})
ctr2.WaitWithDefaultTimeout()
Expect(ctr2).Should(Exit(0))
Expect(ctr2).Should(ExitCleanly())
exec := podmanTest.Podman([]string{"exec", ctrName2, "id"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec).Should(ExitCleanly())
Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName)))
})
@ -479,11 +480,11 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
ctrName := "testctr"
ctr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, "--user", "auser:first", "--group-add", "second", imgName, "sleep", "300"})
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(ctr).Should(ExitCleanly())
exec := podmanTest.Podman([]string{"exec", ctrName, "id"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec).Should(ExitCleanly())
output := exec.OutputToString()
Expect(output).To(ContainSubstring("4000(first)"))
Expect(output).To(ContainSubstring("4001(second)"))
@ -492,18 +493,18 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
// Kill the container just so the test does not take 15 seconds to stop.
kill := podmanTest.Podman([]string{"kill", ctrName})
kill.WaitWithDefaultTimeout()
Expect(kill).Should(Exit(0))
Expect(kill).Should(ExitCleanly())
})
It("podman exec --detach", func() {
ctrName := "testctr"
ctr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
ctr.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(ctr).Should(ExitCleanly())
exec1 := podmanTest.Podman([]string{"exec", "-d", ctrName, "top"})
exec1.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(ctr).Should(ExitCleanly())
data := podmanTest.InspectContainer(ctrName)
Expect(data).To(HaveLen(1))
@ -512,14 +513,14 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
exec2 := podmanTest.Podman([]string{"exec", ctrName, "ps", "-a"})
exec2.WaitWithDefaultTimeout()
Expect(ctr).Should(Exit(0))
Expect(ctr).Should(ExitCleanly())
Expect(strings.Count(exec2.OutputToString(), "top")).To(Equal(2))
// Ensure that stop with a running detached exec session is
// clean.
stop := podmanTest.Podman([]string{"stop", ctrName})
stop.WaitWithDefaultTimeout()
Expect(stop).Should(Exit(0))
Expect(stop).Should(ExitCleanly())
})
It("podman exec with env var secret", func() {
@ -530,20 +531,20 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "-d", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"exec", "secr", "printenv", "mysecret"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(secretsString))
session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"})
session = podmanTest.Podman([]string{"commit", "-q", "secr", "foobar.com/test1-image:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "printenv", "mysecret"})
session.WaitWithDefaultTimeout()
@ -569,8 +570,8 @@ RUN useradd -u 1000 auser`, fedoraMinimal)
session.Wait(6)
Expect(session2).Should(Exit(0))
Expect(session).Should(Exit(0))
Expect(session2).Should(ExitCleanly())
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("root"))
})
})

View File

@ -56,21 +56,21 @@ var _ = Describe("podman farm", func() {
cmd := []string{"farm", "create", "farm1", "QA", "QB"}
session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" created"))
// create farm with only one system connection
cmd = []string{"farm", "create", "farm2", "QA"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" created"))
// create empty farm
cmd = []string{"farm", "create", "farm3"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm3\" created"))
cfg, err := config.ReadCustomConfig()
@ -84,7 +84,7 @@ var _ = Describe("podman farm", func() {
cmd = []string{"farm", "create", "farm3"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Not(Exit(0)))
Expect(session).Should(Not(ExitCleanly()))
})
It("update existing farms", func() {
@ -92,21 +92,21 @@ var _ = Describe("podman farm", func() {
cmd := []string{"farm", "create", "farm1", "QA", "QB"}
session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" created"))
// create farm with only one system connection
cmd = []string{"farm", "create", "farm2", "QA"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" created"))
// create empty farm
cmd = []string{"farm", "create", "farm3"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm3\" created"))
cfg, err := config.ReadCustomConfig()
@ -120,21 +120,21 @@ var _ = Describe("podman farm", func() {
cmd = []string{"farm", "update", "--remove", "QA,QB", "farm1"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" updated"))
// update farm3 to add QA and QB connections to it
cmd = []string{"farm", "update", "--add", "QB", "farm3"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm3\" updated"))
// update farm2 to be the default farm
cmd = []string{"farm", "update", "--default", "farm2"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" updated"))
cfg, err = config.ReadCustomConfig()
@ -148,7 +148,7 @@ var _ = Describe("podman farm", func() {
cmd = []string{"farm", "update", "--default=false", "farm2"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" updated"))
cfg, err = config.ReadCustomConfig()
@ -161,14 +161,14 @@ var _ = Describe("podman farm", func() {
cmd := []string{"farm", "create", "farm1", "QA", "QB"}
session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" created"))
// create farm with only one system connection
cmd = []string{"farm", "create", "farm2", "QA"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" created"))
cfg, err := config.ReadCustomConfig()
@ -184,6 +184,7 @@ var _ = Describe("podman farm", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" deleted"))
Expect(session.ErrorToString()).Should(ContainSubstring("doesn't exist; nothing to remove"))
cfg, err = config.ReadCustomConfig()
Expect(err).ShouldNot(HaveOccurred())
@ -195,7 +196,7 @@ var _ = Describe("podman farm", func() {
cmd = []string{"farm", "rm", "foo", "bar"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Not(Exit(0)))
Expect(session).Should(Not(ExitCleanly()))
})
It("remove --all farms", func() {
@ -203,14 +204,14 @@ var _ = Describe("podman farm", func() {
cmd := []string{"farm", "create", "farm1", "QA", "QB"}
session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" created"))
// create farm with only one system connection
cmd = []string{"farm", "create", "farm2", "QA"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm2\" created"))
cfg, err := config.ReadCustomConfig()
@ -223,7 +224,7 @@ var _ = Describe("podman farm", func() {
cmd = []string{"farm", "rm", "--all"}
session = podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.Out.Contents()).Should(ContainSubstring("All farms have been deleted"))
cfg, err = config.ReadCustomConfig()

View File

@ -52,6 +52,7 @@ var _ = Describe("Podman kube generate", func() {
Expect(pod.Spec.Containers[0].SecurityContext).To(BeNil())
Expect(pod.Spec.Containers[0].Env).To(BeNil())
Expect(pod).To(HaveField("Name", "top-pod"))
Expect(pod.Spec.TerminationGracePeriodSeconds).To(BeNil())
numContainers := 0
for range pod.Spec.Containers {
@ -1880,4 +1881,79 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(err).ToNot(HaveOccurred())
Expect(pod.Annotations).To(BeEmpty())
})
It("podman generate kube on pod with --stop-timeout set for ctr", func() {
podName := "test-pod"
podSession := podmanTest.Podman([]string{"pod", "create", podName})
podSession.WaitWithDefaultTimeout()
Expect(podSession).Should(Exit(0))
session := podmanTest.Podman([]string{"create", "--pod", podName, "--stop-timeout", "20", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
kube := podmanTest.Podman([]string{"generate", "kube", podName})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0))
// TerminationGracePeriodSeconds should be set to 20
pod := new(v1.Pod)
err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).ToNot(HaveOccurred())
Expect(int(*pod.Spec.TerminationGracePeriodSeconds)).To(Equal(20))
})
It("podman generate kube on pod with --type=daemonset", func() {
podName := "test-pod"
session := podmanTest.Podman([]string{"pod", "create", podName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "sleep", "100"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
kube := podmanTest.Podman([]string{"generate", "kube", "--type", "daemonset", podName})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0))
dep := new(v1.DaemonSet)
err := yaml.Unmarshal(kube.Out.Contents(), dep)
Expect(err).ToNot(HaveOccurred())
Expect(dep.Name).To(Equal(podName + "-daemonset"))
Expect(dep.Spec.Selector.MatchLabels).To(HaveKeyWithValue("app", podName))
Expect(dep.Spec.Template.Name).To(Equal(podName))
Expect(dep.Spec.Template.Spec.Containers).To(HaveLen(2))
})
It("podman generate kube on ctr with --type=daemonset and --replicas=3 should fail", func() {
ctrName := "test-ctr"
session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
kube := podmanTest.Podman([]string{"generate", "kube", "--type", "daemonset", "--replicas", "3", ctrName})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(125))
Expect(kube.ErrorToString()).To(ContainSubstring("--replicas can only be set when --type is set to deployment"))
})
It("podman generate kube on pod with --type=daemonset and --restart=no should fail", func() {
podName := "test-pod"
session := podmanTest.Podman([]string{"pod", "create", "--restart", "no", podName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
kube := podmanTest.Podman([]string{"generate", "kube", "--type", "daemonset", podName})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(125))
Expect(kube.ErrorToString()).To(ContainSubstring("k8s DaemonSets can only have restartPolicy set to Always"))
})
})

View File

@ -6,7 +6,6 @@ import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman generate spec", func() {
@ -25,22 +24,22 @@ var _ = Describe("Podman generate spec", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
session := podmanTest.Podman([]string{"create", "--cpus", "5", "--name", "specgen", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"generate", "spec", "--compact", "specgen"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman generate spec file", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
session := podmanTest.Podman([]string{"create", "--cpus", "5", "--name", "specgen", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"generate", "spec", "--filename", filepath.Join(tempdir, "out.json"), "specgen"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
path := filepath.Join(tempdir, "out.json")
@ -54,10 +53,10 @@ var _ = Describe("Podman generate spec", func() {
It("generate spec pod", func() {
session := podmanTest.Podman([]string{"pod", "create", "--cpus", "5", "--name", "podspecgen"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"generate", "spec", "--compact", "podspecgen"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
})

View File

@ -24,7 +24,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman disable healthcheck with --no-healthcheck on valid container", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(125))
@ -33,17 +33,17 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman disable healthcheck with --no-healthcheck must not show starting on status", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Health.Status}}", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
Expect(hc.OutputToString()).To(Not(ContainSubstring("starting")))
})
It("podman run healthcheck and logs should contain healthcheck output", func() {
session := podmanTest.Podman([]string{"run", "--name", "test-logs", "-dt", "--health-interval", "1s", "--health-cmd", "echo working", "busybox", "sleep", "3600"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Buy a little time to get container running
for i := 0; i < 5; i++ {
@ -58,26 +58,26 @@ var _ = Describe("Podman healthcheck run", func() {
hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.State.Healthcheck.Log}}", "test-logs"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
Expect(hc.OutputToString()).To(ContainSubstring("working"))
})
It("podman healthcheck from image's config (not container config)", func() {
// Regression test for #12226: a health check may be defined in
// the container or the container-config of an image.
session := podmanTest.Podman([]string{"create", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"})
session := podmanTest.Podman([]string{"create", "-q", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Healthcheck}}", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
Expect(hc.OutputToString()).To(Equal("{[CMD-SHELL curl -f http://localhost/ || exit 1] 0s 5m0s 3s 0}"))
})
It("podman disable healthcheck with --health-cmd=none on valid container", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "none", "--name", "hc", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(125))
@ -87,7 +87,7 @@ var _ = Describe("Podman healthcheck run", func() {
Skip("Extremely consistent flake - re-enable on debugging")
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", HEALTHCHECK_IMAGE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
exitCode := 999
@ -105,14 +105,14 @@ var _ = Describe("Podman healthcheck run", func() {
ps := podmanTest.Podman([]string{"ps"})
ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0))
Expect(ps).Should(ExitCleanly())
Expect(ps.OutputToString()).To(ContainSubstring("(healthy)"))
})
It("podman healthcheck that should fail", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"})
session := podmanTest.Podman([]string{"run", "-q", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -122,7 +122,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck on stopped container", func() {
session := podmanTest.Podman([]string{"run", "--name", "hc", HEALTHCHECK_IMAGE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -132,7 +132,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck on container without healthcheck", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -142,7 +142,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck should be starting", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
inspect := podmanTest.InspectContainer("hc")
Expect(inspect[0].State.Health).To(HaveField("Status", "starting"))
})
@ -150,7 +150,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck failed checks in start-period should not change status", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-start-period", "2m", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -173,7 +173,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck failed checks must reach retries before unhealthy ", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -195,11 +195,11 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck good check results in healthy even in start-period", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-start-period", "2m", "--health-retries", "2", "--health-cmd", "ls || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
inspect := podmanTest.InspectContainer("hc")
Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy))
@ -208,7 +208,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck unhealthy but valid arguments check", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "[\"ls\", \"/foo\"]", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -218,7 +218,7 @@ var _ = Describe("Podman healthcheck run", func() {
It("podman healthcheck single healthy result changes failed to healthy", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
@ -236,19 +236,29 @@ var _ = Describe("Podman healthcheck run", func() {
foo := podmanTest.Podman([]string{"exec", "hc", "touch", "/foo"})
foo.WaitWithDefaultTimeout()
Expect(foo).Should(Exit(0))
Expect(foo).Should(ExitCleanly())
hc = podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
inspect = podmanTest.InspectContainer("hc")
Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy))
// Test that events generated have correct status (#19237)
events := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"})
events.WaitWithDefaultTimeout()
Expect(events).Should(ExitCleanly())
eventsOut := events.OutputToStringArray()
Expect(eventsOut).To(HaveLen(3))
Expect(eventsOut[0]).To(ContainSubstring("health_status=starting"))
Expect(eventsOut[1]).To(ContainSubstring("health_status=unhealthy"))
Expect(eventsOut[2]).To(ContainSubstring("health_status=healthy"))
// Test podman ps --filter health is working (#11687)
ps := podmanTest.Podman([]string{"ps", "--filter", "health=healthy"})
ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0))
Expect(ps).Should(ExitCleanly())
Expect(ps.OutputToStringArray()).To(HaveLen(2))
Expect(ps.OutputToString()).To(ContainSubstring("hc"))
})
@ -256,15 +266,15 @@ var _ = Describe("Podman healthcheck run", func() {
It("stopping and then starting a container with healthcheck cmd", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-cmd", "[\"ls\", \"/foo\"]", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
stop := podmanTest.Podman([]string{"stop", "-t0", "hc"})
stop.WaitWithDefaultTimeout()
Expect(stop).Should(Exit(0))
Expect(stop).Should(ExitCleanly())
startAgain := podmanTest.Podman([]string{"start", "hc"})
startAgain.WaitWithDefaultTimeout()
Expect(startAgain).Should(Exit(0))
Expect(startAgain).Should(ExitCleanly())
Expect(startAgain.OutputToString()).To(Equal("hc"))
Expect(startAgain.ErrorToString()).To(Equal(""))
})
@ -289,17 +299,17 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
session := podmanTest.Podman([]string{"build", "--format", "docker", "-t", "test", "."})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// Check if image inspect contains CMD-SHELL generated by healthcheck.
session = podmanTest.Podman([]string{"image", "inspect", "--format", "{{.Config.Healthcheck}}", "test"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("CMD-SHELL"))
run := podmanTest.Podman([]string{"run", "-dt", "--name", "hctest", "test", "ls"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
Expect(run).Should(ExitCleanly())
inspect := podmanTest.InspectContainer("hctest")
// Check to make sure a default time value was added
@ -314,7 +324,7 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
ctrName := "hcCtr"
ctrRun := podmanTest.Podman([]string{"run", "-dt", "--name", ctrName, "--health-cmd", "echo regular", "--health-startup-cmd", "cat /test", ALPINE, "top"})
ctrRun.WaitWithDefaultTimeout()
Expect(ctrRun).Should(Exit(0))
Expect(ctrRun).Should(ExitCleanly())
inspect := podmanTest.InspectContainer(ctrName)
Expect(inspect[0].State.Health).To(HaveField("Status", "starting"))
@ -325,18 +335,18 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
exec := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "touch /test && echo startup > /test"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
Expect(exec).Should(ExitCleanly())
hc = podmanTest.Podman([]string{"healthcheck", "run", ctrName})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
inspect = podmanTest.InspectContainer(ctrName)
Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy))
hc = podmanTest.Podman([]string{"healthcheck", "run", ctrName})
hc.WaitWithDefaultTimeout()
Expect(hc).Should(Exit(0))
Expect(hc).Should(ExitCleanly())
inspect = podmanTest.InspectContainer(ctrName)
Expect(inspect[0].State.Health).To(HaveField("Status", define.HealthCheckHealthy))
@ -344,7 +354,7 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
// Test podman ps --filter health is working (#11687)
ps := podmanTest.Podman([]string{"ps", "--filter", "health=healthy"})
ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0))
Expect(ps).Should(ExitCleanly())
Expect(ps.OutputToStringArray()).To(HaveLen(2))
Expect(ps.OutputToString()).To(ContainSubstring("hc"))
})

View File

@ -4,7 +4,6 @@ import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman history", func() {
@ -12,45 +11,45 @@ var _ = Describe("Podman history", func() {
It("podman history output flag", func() {
session := podmanTest.Podman([]string{"history", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).ToNot(BeEmpty())
})
It("podman history with GO template", func() {
session := podmanTest.Podman([]string{"history", "--format", "{{.ID}} {{.Created}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).ToNot(BeEmpty())
session = podmanTest.Podman([]string{"history", "--format", "{{.CreatedAt}};{{.Size}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(MatchRegexp("[0-9-]{10}T[0-9:]{8}[Z0-9+:-]+;[0-9.]+[MG]*B( .+)?"))
})
It("podman history with human flag", func() {
session := podmanTest.Podman([]string{"history", "--human=false", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).ToNot(BeEmpty())
})
It("podman history with quiet flag", func() {
session := podmanTest.Podman([]string{"history", "-qH", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).ToNot(BeEmpty())
})
It("podman history with no-trunc flag", func() {
session := podmanTest.Podman([]string{"history", "--no-trunc", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).ToNot(BeEmpty())
session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.ID}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
lines := session.OutputToStringArray()
Expect(lines).ToNot(BeEmpty())
// the image id must be 64 chars long
@ -58,7 +57,7 @@ var _ = Describe("Podman history", func() {
session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.CreatedBy}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
lines = session.OutputToStringArray()
Expect(lines).ToNot(BeEmpty())
Expect(session.OutputToString()).ToNot(ContainSubstring("..."))
@ -69,7 +68,7 @@ var _ = Describe("Podman history", func() {
It("podman history with json flag", func() {
session := podmanTest.Podman([]string{"history", "--format=json", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
})
})

View File

@ -9,7 +9,6 @@ import (
"github.com/containers/storage/pkg/homedir"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("podman image scp", func() {
@ -33,7 +32,7 @@ var _ = Describe("podman image scp", func() {
}
session := podmanTest.Podman(cmd)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cfg, err := config.ReadCustomConfig()
Expect(err).ShouldNot(HaveOccurred())

View File

@ -5,9 +5,9 @@ import (
"os/exec"
"path/filepath"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
// Each of these tests runs with a different GNUPGHOME; gpg-agent blows up
@ -50,7 +50,7 @@ var _ = Describe("Podman image sign", Serial, func() {
Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"image", "sign", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
_, err = os.Stat(filepath.Join(sigDir, "library"))
Expect(err).ToNot(HaveOccurred())
})
@ -66,7 +66,7 @@ var _ = Describe("Podman image sign", Serial, func() {
Expect(err).ToNot(HaveOccurred())
session := podmanTest.Podman([]string{"image", "sign", "--all", "--directory", sigDir, "--sign-by", "foo@bar.com", "docker://library/alpine"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
fInfos, err := os.ReadDir(filepath.Join(sigDir, "library"))
Expect(err).ToNot(HaveOccurred())
Expect(len(fInfos)).To(BeNumerically(">", 1), "len(fInfos)")

View File

@ -17,7 +17,7 @@ var _ = Describe("Podman images", func() {
It("podman images", func() {
session := podmanTest.Podman([]string{"images"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
@ -26,7 +26,7 @@ var _ = Describe("Podman images", func() {
It("podman image List", func() {
session := podmanTest.Podman([]string{"image", "list"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
@ -37,15 +37,15 @@ var _ = Describe("Podman images", func() {
podmanTest.AddImageToRWStore(ALPINE)
session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// tag "foo:c" to "bar:{a,b}"
session = podmanTest.Podman([]string{"tag", "foo:c", "bar:a", "bar:b"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
// check all previous and the newly tagged images
session = podmanTest.Podman([]string{"images"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.LineInOutputContainsTag("quay.io/libpod/alpine", "latest")).To(BeTrue())
Expect(session.LineInOutputContainsTag("quay.io/libpod/busybox", "latest")).To(BeTrue())
Expect(session.LineInOutputContainsTag("localhost/foo", "a")).To(BeTrue())
@ -55,14 +55,14 @@ var _ = Describe("Podman images", func() {
Expect(session.LineInOutputContainsTag("localhost/bar", "b")).To(BeTrue())
session = podmanTest.Podman([]string{"images", "-qn"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES)))
})
It("podman images with digests", func() {
session := podmanTest.Podman([]string{"images", "--digests"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine")))
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox")))
@ -71,14 +71,14 @@ var _ = Describe("Podman images", func() {
It("podman empty images list in JSON format", func() {
session := podmanTest.Podman([]string{"images", "--format=json", "not-existing-image"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
})
It("podman images in JSON format", func() {
session := podmanTest.Podman([]string{"images", "--format=json"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
})
@ -86,13 +86,13 @@ var _ = Describe("Podman images", func() {
formatStr := "{{.ID}}\t{{.Created}}\t{{.CreatedAt}}\t{{.CreatedSince}}\t{{.CreatedTime}}"
session := podmanTest.Podman([]string{"images", fmt.Sprintf("--format=%s", formatStr)})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman images with short options", func() {
session := podmanTest.Podman([]string{"images", "-qn"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 1))
})
@ -102,43 +102,43 @@ var _ = Describe("Podman images", func() {
session := podmanTest.Podman([]string{"images", "-q", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(1))
session = podmanTest.Podman([]string{"tag", ALPINE, "foo:a"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"tag", BB, "foo:b"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"images", "-q", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(2))
})
It("podman images filter reference", func() {
result := podmanTest.Podman([]string{"images", "-q", "-f", "reference=quay.io/libpod/*"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(8))
retalpine := podmanTest.Podman([]string{"images", "-f", "reference=*lpine*"})
retalpine.WaitWithDefaultTimeout()
Expect(retalpine).Should(Exit(0))
Expect(retalpine).Should(ExitCleanly())
Expect(retalpine.OutputToStringArray()).To(HaveLen(5))
Expect(retalpine.OutputToString()).To(ContainSubstring("alpine"))
retalpine = podmanTest.Podman([]string{"images", "-f", "reference=alpine"})
retalpine.WaitWithDefaultTimeout()
Expect(retalpine).Should(Exit(0))
Expect(retalpine).Should(ExitCleanly())
Expect(retalpine.OutputToStringArray()).To(HaveLen(2))
Expect(retalpine.OutputToString()).To(ContainSubstring("alpine"))
retnone := podmanTest.Podman([]string{"images", "-q", "-f", "reference=bogus"})
retnone.WaitWithDefaultTimeout()
Expect(retnone).Should(Exit(0))
Expect(retnone).Should(ExitCleanly())
Expect(retnone.OutputToStringArray()).To(BeEmpty())
})
@ -149,7 +149,7 @@ RUN echo hello > /hello
podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
result := podmanTest.Podman([]string{"images", "-q", "-f", "before=foobar.com/before:latest"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).ToNot(BeEmpty())
})
@ -160,7 +160,7 @@ WORKDIR /test
podmanTest.BuildImage(dockerfile, "foobar.com/workdir:latest", "false")
result := podmanTest.Podman([]string{"run", "foobar.com/workdir:latest", "pwd"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToString()).To(Equal("/test"))
})
@ -174,13 +174,13 @@ WORKDIR /test
// `since` filter
result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "since=foobar.com/one:latest"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(2))
// `after` filter
result = podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=foobar.com/one:latest"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).Should(HaveLen(2), "list filter output: %q", result.OutputToString())
})
@ -199,13 +199,13 @@ WORKDIR /test
// Prevent regressing on issue #7651: error parsing name that includes a digest
// component as if were a name that includes tag component.
digestPullAndList := func(noneTag bool) {
session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST})
session := podmanTest.Podman([]string{"pull", "-q", ALPINEAMD64DIGEST})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
result := podmanTest.Podman([]string{"images", "--all", ALPINEAMD64DIGEST})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
if noneTag {
Expect(result.OutputToString()).To(ContainSubstring("<none>"))
@ -217,16 +217,16 @@ WORKDIR /test
// the additional image store we're using. Pull the same image by another name to
// copy an entry for the image into read-write storage so that the name can be
// attached to it.
session := podmanTest.Podman([]string{"pull", ALPINELISTTAG})
session := podmanTest.Podman([]string{"pull", "-q", ALPINELISTTAG})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
digestPullAndList(false)
// Now remove all names from the read-write image record, re-pull by digest and
// check for the "<none>" in its listing.
session = podmanTest.Podman([]string{"untag", ALPINELISTTAG})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
digestPullAndList(true)
})
@ -234,25 +234,25 @@ WORKDIR /test
It("podman check for image with sha256: prefix", func() {
session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
imageData := session.InspectImageJSON()
result := podmanTest.Podman([]string{"images", "sha256:" + imageData[0].ID})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman check for image with sha256: prefix", func() {
session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(BeValidJSON())
imageData := session.InspectImageJSON()
result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
It("podman images sort by values", func() {
@ -307,12 +307,12 @@ ENV foo=bar
podmanTest.BuildImage(dockerfile, "test", "true")
session := podmanTest.Podman([]string{"images"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES) + 2))
session2 := podmanTest.Podman([]string{"images", "--all"})
session2.WaitWithDefaultTimeout()
Expect(session2).Should(Exit(0))
Expect(session2).Should(ExitCleanly())
Expect(session2.OutputToStringArray()).To(HaveLen(len(CACHE_IMAGES) + 4))
})
@ -324,7 +324,7 @@ LABEL "com.example.vendor"="Example Vendor"
podmanTest.BuildImage(dockerfile, "test", "true")
session := podmanTest.Podman([]string{"images", "-f", "label=version=1.0"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(2))
})
@ -342,52 +342,52 @@ LABEL "com.example.vendor"="Example Vendor"
session := podmanTest.Podman([]string{"images", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output := session.OutputToString()
Expect(output).To(Not(MatchRegexp("<missing>")))
Expect(output).To(Not(MatchRegexp("error")))
session = podmanTest.Podman([]string{"image", "tree", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(MatchRegexp("No Image Layers"))
session = podmanTest.Podman([]string{"history", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(Not(MatchRegexp("error")))
session = podmanTest.Podman([]string{"history", "--quiet", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(6))
session = podmanTest.Podman([]string{"image", "list", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(Not(MatchRegexp("<missing>")))
Expect(output).To(Not(MatchRegexp("error")))
session = podmanTest.Podman([]string{"image", "list"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(Not(MatchRegexp("<missing>")))
Expect(output).To(Not(MatchRegexp("error")))
session = podmanTest.Podman([]string{"inspect", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(Not(MatchRegexp("<missing>")))
Expect(output).To(Not(MatchRegexp("error")))
session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
output = session.OutputToString()
Expect(output).To(Equal("[]"))
})
@ -398,7 +398,7 @@ LABEL "com.example.vendor"="Example Vendor"
podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/before:latest", "false", "test=with,comma")
result := podmanTest.Podman([]string{"images", "--filter", "label=test=with,comma"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(2))
})
@ -408,11 +408,11 @@ LABEL "com.example.vendor"="Example Vendor"
podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false")
result := podmanTest.Podman([]string{"images", "-f", "readonly=true"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
result1 := podmanTest.Podman([]string{"images", "--filter", "readonly=false"})
result1.WaitWithDefaultTimeout()
Expect(result1).Should(Exit(0))
Expect(result1).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(Not(Equal(result1.OutputToStringArray())))
})
@ -428,7 +428,7 @@ RUN > file2
// --force used to avoid y/n question
result := podmanTest.Podman([]string{"image", "prune", "--filter", "label=abc", "--force"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(1))
// check if really abc is removed
@ -449,7 +449,7 @@ RUN > file2
// --force used to to avoid y/n question
result := podmanTest.Podman([]string{"builder", "prune", "--filter", "label=abc", "--force"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
Expect(result.OutputToStringArray()).To(HaveLen(1))
// check if really abc is removed

View File

@ -18,15 +18,22 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", outfile, "foobar.com/imported-image:latest"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
if !IsRemote() {
messages := importImage.ErrorToString()
Expect(messages).Should(ContainSubstring("Getting image source signatures"))
Expect(messages).Should(ContainSubstring("Copying blob"))
Expect(messages).Should(ContainSubstring("Writing manifest to image destination"))
Expect(messages).Should(Not(ContainSubstring("level=")), "Unexpected logrus messages in stderr")
}
results := podmanTest.Podman([]string{"inspect", "--type", "image", "foobar.com/imported-image:latest"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
})
It("podman import with custom os, arch and variant", func() {
@ -36,15 +43,15 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--os", "testos", "--arch", "testarch", outfile, "foobar.com/imported-image:latest"})
importImage := podmanTest.Podman([]string{"import", "-q", "--os", "testos", "--arch", "testarch", outfile, "foobar.com/imported-image:latest"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
results := podmanTest.Podman([]string{"inspect", "--type", "image", "foobar.com/imported-image:latest"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
Expect(results.OutputToString()).To(ContainSubstring("testos"))
Expect(results.OutputToString()).To(ContainSubstring("testarch"))
})
@ -56,16 +63,16 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", outfile})
importImage := podmanTest.Podman([]string{"import", "-q", outfile})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
// tag the image which proves it is in R/W storage
tag := podmanTest.Podman([]string{"tag", importImage.OutputToString(), "foo"})
tag.WaitWithDefaultTimeout()
Expect(tag).Should(Exit(0))
Expect(tag).Should(ExitCleanly())
})
It("podman import with message flag", func() {
@ -75,15 +82,15 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--message", "importing container test message", outfile, "imported-image"})
importImage := podmanTest.Podman([]string{"import", "-q", "--message", "importing container test message", outfile, "imported-image"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
results := podmanTest.Podman([]string{"history", "imported-image", "--format", "{{.Comment}}"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
Expect(results.OutputToStringArray()).To(ContainElement(HavePrefix("importing container test message")))
})
@ -94,15 +101,15 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--change", "CMD=/bin/bash", outfile, "imported-image"})
importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD=/bin/bash", outfile, "imported-image"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
results := podmanTest.Podman([]string{"inspect", "imported-image"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
imageData := results.InspectImageJSON()
Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/sh"))
Expect(imageData[0].Config.Cmd[1]).To(Equal("-c"))
@ -116,15 +123,15 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--change", "CMD /bin/sh", outfile, "imported-image"})
importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD /bin/sh", outfile, "imported-image"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
results := podmanTest.Podman([]string{"inspect", "imported-image"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
imageData := results.InspectImageJSON()
Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/sh"))
Expect(imageData[0].Config.Cmd[1]).To(Equal("-c"))
@ -138,15 +145,15 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--change", "CMD [\"/bin/bash\"]", outfile, "imported-image"})
importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD [\"/bin/bash\"]", outfile, "imported-image"})
importImage.WaitWithDefaultTimeout()
Expect(importImage).Should(Exit(0))
Expect(importImage).Should(ExitCleanly())
results := podmanTest.Podman([]string{"inspect", "imported-image"})
results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0))
Expect(results).Should(ExitCleanly())
imageData := results.InspectImageJSON()
Expect(imageData[0].Config.Cmd[0]).To(Equal("/bin/bash"))
})
@ -160,20 +167,20 @@ var _ = Describe("Podman import", func() {
export := podmanTest.Podman([]string{"export", "-o", outfile, cid})
export.WaitWithDefaultTimeout()
Expect(export).Should(Exit(0))
Expect(export).Should(ExitCleanly())
importImage := podmanTest.Podman([]string{"import", "--signature-policy", "/no/such/file", outfile})
importImage := podmanTest.Podman([]string{"import", "-q", "--signature-policy", "/no/such/file", outfile})
importImage.WaitWithDefaultTimeout()
Expect(importImage).To(ExitWithError())
result := podmanTest.Podman([]string{"import", "--signature-policy", "/etc/containers/policy.json", outfile})
result := podmanTest.Podman([]string{"import", "-q", "--signature-policy", "/etc/containers/policy.json", outfile})
result.WaitWithDefaultTimeout()
if IsRemote() {
Expect(result).To(ExitWithError())
Expect(result.ErrorToString()).To(ContainSubstring("unknown flag"))
result := podmanTest.Podman([]string{"import", outfile})
result := podmanTest.Podman([]string{"import", "-q", outfile})
result.WaitWithDefaultTimeout()
}
Expect(result).Should(Exit(0))
Expect(result).Should(ExitCleanly())
})
})

View File

@ -8,6 +8,7 @@ import (
"path/filepath"
"strconv"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@ -46,20 +47,20 @@ var _ = Describe("Podman Info", func() {
It("podman info --format GO template", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Store.GraphRoot}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
It("podman info --format GO template", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Registries}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("registry"))
})
It("podman info --format GO template plugins", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Plugins}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("local"))
Expect(session.OutputToString()).To(ContainSubstring("journald"))
Expect(session.OutputToString()).To(ContainSubstring("bridge"))
@ -101,12 +102,12 @@ var _ = Describe("Podman Info", func() {
It("check RemoteSocket ", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.RemoteSocket.Path}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(MatchRegexp("/run/.*podman.*sock"))
session = podmanTest.Podman([]string{"info", "--format", "{{.Host.ServiceIsRemote}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
if podmanTest.RemoteTest {
Expect(session.OutputToString()).To(Equal("true"))
} else {
@ -115,7 +116,7 @@ var _ = Describe("Podman Info", func() {
session = podmanTest.Podman([]string{"info", "--format", "{{.Host.RemoteSocket.Exists}}"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
if IsRemote() {
Expect(session.OutputToString()).To(ContainSubstring("true"))
} else {
@ -129,7 +130,7 @@ var _ = Describe("Podman Info", func() {
SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users")
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.CgroupControllers}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring("memory"))
Expect(session.OutputToString()).To(ContainSubstring("pids"))
})
@ -145,7 +146,7 @@ var _ = Describe("Podman Info", func() {
}
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.OCIRuntime.Name}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(Equal(want))
})
@ -160,12 +161,12 @@ var _ = Describe("Podman Info", func() {
}
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.NetworkBackend}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(Equal(want))
session = podmanTest.Podman([]string{"info", "--format", "{{.Host.NetworkBackendInfo.Backend}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(Equal(want))
})
@ -180,7 +181,7 @@ var _ = Describe("Podman Info", func() {
}
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.DatabaseBackend}}"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
Expect(session).To(ExitCleanly())
Expect(session.OutputToString()).To(Equal(want))
})
@ -190,17 +191,17 @@ var _ = Describe("Podman Info", func() {
// no skips.
info1 := podmanTest.Podman([]string{"info", "--format", "{{ .Host.FreeLocks }}"})
info1.WaitWithDefaultTimeout()
Expect(info1).To(Exit(0))
Expect(info1).To(ExitCleanly())
free1, err := strconv.Atoi(info1.OutputToString())
Expect(err).To(Not(HaveOccurred()))
ctr := podmanTest.Podman([]string{"create", ALPINE, "top"})
ctr.WaitWithDefaultTimeout()
Expect(ctr).To(Exit(0))
Expect(ctr).To(ExitCleanly())
info2 := podmanTest.Podman([]string{"info", "--format", "{{ .Host.FreeLocks }}"})
info2.WaitWithDefaultTimeout()
Expect(info2).To(Exit(0))
Expect(info2).To(ExitCleanly())
free2, err := strconv.Atoi(info2.OutputToString())
Expect(err).To(Not(HaveOccurred()))

View File

@ -5991,4 +5991,27 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(ContainSubstring(`FOO=bar`))
})
It("podman kube play with TerminationGracePeriodSeconds set", func() {
ctrName := "ctr"
ctrNameInPod := "ctr-pod-ctr"
outputFile := filepath.Join(podmanTest.TempDir, "pod.yaml")
create := podmanTest.Podman([]string{"create", "--restart", "never", "--stop-timeout", "20", "--name", ctrName, ALPINE})
create.WaitWithDefaultTimeout()
Expect(create).Should(Exit(0))
generate := podmanTest.Podman([]string{"kube", "generate", "-f", outputFile, ctrName})
generate.WaitWithDefaultTimeout()
Expect(generate).Should(Exit(0))
play := podmanTest.Podman([]string{"kube", "play", outputFile})
play.WaitWithDefaultTimeout()
Expect(play).Should(Exit(0))
inspect := podmanTest.Podman([]string{"inspect", ctrNameInPod, "-f", "{{ .Config.StopTimeout }}"})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("20"))
})
})

View File

@ -648,10 +648,17 @@ USER bin`, BB)
currentOOMScoreAdj, err := os.ReadFile("/proc/self/oom_score_adj")
Expect(err).ToNot(HaveOccurred())
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/self/oom_score_adj"})
name := "ctr-with-oom-score"
session = podmanTest.Podman([]string{"create", "--name", name, fedoraMinimal, "cat", "/proc/self/oom_score_adj"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
for i := 0; i < 2; i++ {
session = podmanTest.Podman([]string{"start", "-a", name})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal(strings.TrimRight(string(currentOOMScoreAdj), "\n")))
}
})
It("podman run limits host test", func() {

View File

@ -203,3 +203,44 @@ load helpers.bash
run minikube kubectl delete namespace $project
assert $status -eq 0 "delete namespace $project"
}
@test "minikube - deploy generated container yaml to minikube --type=daemonset" {
cname="test-ctr"
fname="/tmp/minikube_deploy_$(random_string 6).yaml"
run_podman container create --name $cname $IMAGE top
run_podman kube generate --type daemonset -f $fname $cname
# deploy to the minikube cluster
project="dep-ctr-ns"
run minikube kubectl create namespace $project
assert "$status" -eq 0 "create new namespace $project"
run minikube kubectl -- apply -f $fname
assert "$status" -eq 0 "deploy $fname to the cluster"
assert "$output" == "daemonset.apps/$cname-pod-daemonset created"
wait_for_pods_to_start
run minikube kubectl delete namespace $project
assert $status -eq 0 "delete namespace $project"
}
@test "minikube - deploy generated pod yaml to minikube --type=daemonset" {
pname="test-pod"
cname1="test-ctr1"
cname2="test-ctr2"
fname="/tmp/minikube_deploy_$(random_string 6).yaml"
run_podman pod create --name $pname --publish 9999:8888
run_podman container create --name $cname1 --pod $pname $IMAGE sleep 1000
run_podman container create --name $cname2 --pod $pname $IMAGE sleep 2000
run_podman kube generate --type daemonset -f $fname $pname
# deploy to the minikube cluster
project="dep-pod-ns"
run minikube kubectl create namespace $project
assert "$status" -eq 0 "create new namespace $project"
run minikube kubectl -- apply -f $fname
assert "$status" -eq 0 "deploy $fname to the cluster"
assert "$output" == "daemonset.apps/$pname-daemonset created"
wait_for_pods_to_start
run minikube kubectl delete namespace $project
assert $status -eq 0 "delete namespace $project"
}

View File

@ -198,17 +198,26 @@ func (matcher *exitCleanlyMatcher) Match(actual interface{}) (success bool, err
return false, nil
}
// Exit status is 0. Now check for anything on stderr... except:
if Containerized() {
// FIXME: #19809, "failed to connect to syslog" warnings on f38
// FIXME: so, until that is fixed, don't check stderr if containerized
if !Containerized() {
return true, nil
}
info := GetHostDistributionInfo()
if info.Distribution == "fedora" {
if info.Distribution != "fedora" {
// runc on debian:
// FIXME: #11784 - lstat /sys/fs/.../*.scope: ENOENT
// FIXME: #11785 - cannot toggle freezer: cgroups not configured
return true, nil
}
if stderr != "" {
matcher.msg = fmt.Sprintf("Unexpected warnings seen on stderr: %q", stderr)
return false, nil
}
}
}
return true, nil
}

View File

@ -0,0 +1,57 @@
/*
mkwinsyscall generates windows system call bodies
It parses all files specified on command line containing function
prototypes (like syscall_windows.go) and prints system call bodies
to standard output.
The prototypes are marked by lines beginning with "//sys" and read
like func declarations if //sys is replaced by func, but:
- The parameter lists must give a name for each argument. This
includes return parameters.
- The parameter lists must give a type for each argument:
the (x, y, z int) shorthand is not allowed.
- If the return parameter is an error number, it must be named err.
- If go func name needs to be different from its winapi dll name,
the winapi name could be specified at the end, after "=" sign, like
//sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
- Each function that returns err needs to supply a condition, that
return value of winapi will be tested against to detect failure.
This would set err to windows "last-error", otherwise it will be nil.
The value can be provided at end of //sys declaration, like
//sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
and is [failretval==0] by default.
- If the function name ends in a "?", then the function not existing is non-
fatal, and an error will be returned instead of panicking.
Usage:
mkwinsyscall [flags] [path ...]
Flags
-output string
Output file name (standard output if omitted).
-sort
Sort DLL and function declarations (default true).
Intended to help transition from older versions of mkwinsyscall by making diffs
easier to read and understand.
-systemdll
Whether all DLLs should be loaded from the Windows system directory (default true).
-trace
Generate print statement after every syscall.
-utf16
Encode string arguments as UTF-16 for syscalls not ending in 'A' or 'W' (default true).
-winio
Import this package ("github.com/Microsoft/go-winio").
*/
package main

File diff suppressed because it is too large Load Diff

View File

@ -37,10 +37,6 @@ rootfs-conv/*
deps/*
out/*
# protobuf files
# only files at root of the repo, otherwise this will cause issues with vendoring
/protobuf/*
# test results
test/results

View File

@ -135,9 +135,3 @@ issues:
linters:
- stylecheck
Text: "ST1003:"
# v0 APIs are deprecated, but still retained for backwards compatability
- path: cmd\\ncproxy\\
linters:
- staticcheck
text: "^SA1019: .*(ncproxygrpc|nodenetsvc)[/]?v0"

View File

@ -1,25 +1,48 @@
version = "2"
generators = ["go", "go-grpc"]
version = "1"
generator = "gogoctrd"
plugins = ["grpc", "fieldpath"]
# Control protoc include paths.
# Control protoc include paths. Below are usually some good defaults, but feel
# free to try it without them if it works for your project.
[includes]
# Include paths that will be added before all others. Typically, you want to
# treat the root of the project as an include, but this may not be necessary.
before = ["./protobuf"]
# defaults are "/usr/local/include" and "/usr/include", which don't exist on Windows.
# override defaults to supress errors about non-existant directories.
after = []
# Paths that should be treated as include roots in relation to the vendor
# directory. These will be calculated with the vendor directory nearest the
# target package.
packages = ["github.com/gogo/protobuf"]
# This section maps protobuf imports to Go packages.
# This section maps protobuf imports to Go packages. These will become
# `-M` directives in the call to the go protobuf generator.
[packages]
# github.com/containerd/cgroups protofiles still list their go path as "github.com/containerd/cgroups/cgroup1/stats"
"github.com/containerd/cgroups/v3/cgroup1/stats/metrics.proto" = "github.com/containerd/cgroups/v3/cgroup1/stats"
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/struct.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
"github/containerd/cgroups/stats/v1/metrics.proto" = "github.com/containerd/cgroups/stats/v1"
[[overrides]]
prefixes = [
"github.com/Microsoft/hcsshim/internal/shimdiag",
"github.com/Microsoft/hcsshim/internal/extendedtask",
"github.com/Microsoft/hcsshim/internal/computeagent",
"github.com/Microsoft/hcsshim/internal/ncproxyttrpc",
"github.com/Microsoft/hcsshim/internal/vmservice",
]
generators = ["go", "go-ttrpc"]
prefixes = ["github.com/Microsoft/hcsshim/internal/shimdiag"]
plugins = ["ttrpc"]
[[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/extendedtask"]
plugins = ["ttrpc"]
[[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/computeagent"]
plugins = ["ttrpc"]
[[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/ncproxyttrpc"]
plugins = ["ttrpc"]
[[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/vmservice"]
plugins = ["ttrpc"]

View File

@ -1,25 +0,0 @@
/*
* HCS API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.5
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package hcsschema
const (
CimMountFlagNone uint32 = 0x0
CimMountFlagChildOnly uint32 = 0x1
CimMountFlagEnableDax uint32 = 0x2
CimMountFlagCacheFiles uint32 = 0x4
CimMountFlagCacheRegions uint32 = 0x8
)
type CimMount struct {
ImagePath string `json:"ImagePath,omitempty"`
FileSystemName string `json:"FileSystemName,omitempty"`
VolumeGuid string `json:"VolumeGuid,omitempty"`
MountFlags uint32 `json:"MountFlags,omitempty"`
}

View File

@ -10,7 +10,7 @@
package hcsschema
import (
v1 "github.com/containerd/cgroups/v3/cgroup1/stats"
v1 "github.com/containerd/cgroups/stats/v1"
)
type Properties struct {

View File

@ -4,13 +4,12 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"net"
"reflect"
"time"
"github.com/containerd/containerd/log"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
const TimeFormat = log.RFC3339NanoFixed
@ -68,22 +67,16 @@ func Format(ctx context.Context, v interface{}) string {
}
func encode(v interface{}) ([]byte, error) {
if m, ok := v.(proto.Message); ok {
// use canonical JSON encoding for protobufs (instead of [encoding/json])
// https://protobuf.dev/programming-guides/proto3/#json
return protojson.MarshalOptions{
AllowPartial: true,
// protobuf defaults to camel case for JSON encoding; use proto field name instead (snake case)
UseProtoNames: true,
}.Marshal(m)
return encodeBuffer(&bytes.Buffer{}, v)
}
buf := &bytes.Buffer{}
func encodeBuffer(buf *bytes.Buffer, v interface{}) ([]byte, error) {
enc := json.NewEncoder(buf)
enc.SetEscapeHTML(false)
enc.SetIndent("", "")
if err := enc.Encode(v); err != nil {
err = fmt.Errorf("could not marshall %T to JSON for logging: %w", v, err)
return nil, err
}

View File

@ -55,7 +55,7 @@ func ScrubProcessParameters(s string) (string, error) {
}
pp.Environment = map[string]string{_scrubbedReplacement: _scrubbedReplacement}
b, err := encode(pp)
b, err := encodeBuffer(bytes.NewBuffer(b[:0]), pp)
if err != nil {
return "", err
}

View File

@ -1,45 +0,0 @@
package winapi
import (
"unsafe"
"github.com/Microsoft/go-winio/pkg/guid"
"golang.org/x/sys/windows"
)
type g = guid.GUID
type FsHandle uintptr
type StreamHandle uintptr
type CimFsFileMetadata struct {
Attributes uint32
FileSize int64
CreationTime windows.Filetime
LastWriteTime windows.Filetime
ChangeTime windows.Filetime
LastAccessTime windows.Filetime
SecurityDescriptorBuffer unsafe.Pointer
SecurityDescriptorSize uint32
ReparseDataBuffer unsafe.Pointer
ReparseDataSize uint32
ExtendedAttributes unsafe.Pointer
EACount uint32
}
//sys CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) = cimfs.CimMountImage?
//sys CimDismountImage(volumeID *g) (hr error) = cimfs.CimDismountImage?
//sys CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) = cimfs.CimCreateImage?
//sys CimCloseImage(cimFSHandle FsHandle) (hr error) = cimfs.CimCloseImage?
//sys CimCommitImage(cimFSHandle FsHandle) (hr error) = cimfs.CimCommitImage?
//sys CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateFile?
//sys CimCloseStream(cimStreamHandle StreamHandle) (hr error) = cimfs.CimCloseStream?
//sys CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) = cimfs.CimWriteStream?
//sys CimDeletePath(cimFSHandle FsHandle, path string) (hr error) = cimfs.CimDeletePath?
//sys CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) = cimfs.CimCreateHardLink?
//sys CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) = cimfs.CimCreateAlternateStream?

View File

@ -80,9 +80,3 @@ func ConvertStringSetToSlice(buf []byte) ([]string, error) {
}
return nil, errors.New("string set malformed: missing null terminator at end of buffer")
}
// ParseUtf16LE parses a UTF-16LE byte array into a string (without passing
// through a uint16 or rune array).
func ParseUtf16LE(b []byte) string {
return windows.UTF16PtrToString((*uint16)(unsafe.Pointer(&b[0])))
}

View File

@ -43,7 +43,6 @@ var (
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
modbindfltapi = windows.NewLazySystemDLL("bindfltapi.dll")
modcfgmgr32 = windows.NewLazySystemDLL("cfgmgr32.dll")
modcimfs = windows.NewLazySystemDLL("cimfs.dll")
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
modnetapi32 = windows.NewLazySystemDLL("netapi32.dll")
@ -56,17 +55,6 @@ var (
procCM_Get_Device_ID_ListA = modcfgmgr32.NewProc("CM_Get_Device_ID_ListA")
procCM_Get_Device_ID_List_SizeA = modcfgmgr32.NewProc("CM_Get_Device_ID_List_SizeA")
procCM_Locate_DevNodeW = modcfgmgr32.NewProc("CM_Locate_DevNodeW")
procCimCloseImage = modcimfs.NewProc("CimCloseImage")
procCimCloseStream = modcimfs.NewProc("CimCloseStream")
procCimCommitImage = modcimfs.NewProc("CimCommitImage")
procCimCreateAlternateStream = modcimfs.NewProc("CimCreateAlternateStream")
procCimCreateFile = modcimfs.NewProc("CimCreateFile")
procCimCreateHardLink = modcimfs.NewProc("CimCreateHardLink")
procCimCreateImage = modcimfs.NewProc("CimCreateImage")
procCimDeletePath = modcimfs.NewProc("CimDeletePath")
procCimDismountImage = modcimfs.NewProc("CimDismountImage")
procCimMountImage = modcimfs.NewProc("CimMountImage")
procCimWriteStream = modcimfs.NewProc("CimWriteStream")
procSetJobCompartmentId = modiphlpapi.NewProc("SetJobCompartmentId")
procClosePseudoConsole = modkernel32.NewProc("ClosePseudoConsole")
procCopyFileW = modkernel32.NewProc("CopyFileW")
@ -176,235 +164,6 @@ func _CMLocateDevNode(pdnDevInst *uint32, pDeviceID *uint16, uFlags uint32) (hr
return
}
func CimCloseImage(cimFSHandle FsHandle) (hr error) {
hr = procCimCloseImage.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimCloseImage.Addr(), 1, uintptr(cimFSHandle), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCloseStream(cimStreamHandle StreamHandle) (hr error) {
hr = procCimCloseStream.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimCloseStream.Addr(), 1, uintptr(cimStreamHandle), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCommitImage(cimFSHandle FsHandle) (hr error) {
hr = procCimCommitImage.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimCommitImage.Addr(), 1, uintptr(cimFSHandle), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCreateAlternateStream(cimFSHandle FsHandle, path string, size uint64, cimStreamHandle *StreamHandle) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(path)
if hr != nil {
return
}
return _CimCreateAlternateStream(cimFSHandle, _p0, size, cimStreamHandle)
}
func _CimCreateAlternateStream(cimFSHandle FsHandle, path *uint16, size uint64, cimStreamHandle *StreamHandle) (hr error) {
hr = procCimCreateAlternateStream.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall6(procCimCreateAlternateStream.Addr(), 4, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), uintptr(size), uintptr(unsafe.Pointer(cimStreamHandle)), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCreateFile(cimFSHandle FsHandle, path string, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(path)
if hr != nil {
return
}
return _CimCreateFile(cimFSHandle, _p0, file, cimStreamHandle)
}
func _CimCreateFile(cimFSHandle FsHandle, path *uint16, file *CimFsFileMetadata, cimStreamHandle *StreamHandle) (hr error) {
hr = procCimCreateFile.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall6(procCimCreateFile.Addr(), 4, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(cimStreamHandle)), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCreateHardLink(cimFSHandle FsHandle, newPath string, oldPath string) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(newPath)
if hr != nil {
return
}
var _p1 *uint16
_p1, hr = syscall.UTF16PtrFromString(oldPath)
if hr != nil {
return
}
return _CimCreateHardLink(cimFSHandle, _p0, _p1)
}
func _CimCreateHardLink(cimFSHandle FsHandle, newPath *uint16, oldPath *uint16) (hr error) {
hr = procCimCreateHardLink.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimCreateHardLink.Addr(), 3, uintptr(cimFSHandle), uintptr(unsafe.Pointer(newPath)), uintptr(unsafe.Pointer(oldPath)))
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimCreateImage(imagePath string, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(imagePath)
if hr != nil {
return
}
return _CimCreateImage(_p0, oldFSName, newFSName, cimFSHandle)
}
func _CimCreateImage(imagePath *uint16, oldFSName *uint16, newFSName *uint16, cimFSHandle *FsHandle) (hr error) {
hr = procCimCreateImage.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall6(procCimCreateImage.Addr(), 4, uintptr(unsafe.Pointer(imagePath)), uintptr(unsafe.Pointer(oldFSName)), uintptr(unsafe.Pointer(newFSName)), uintptr(unsafe.Pointer(cimFSHandle)), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimDeletePath(cimFSHandle FsHandle, path string) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(path)
if hr != nil {
return
}
return _CimDeletePath(cimFSHandle, _p0)
}
func _CimDeletePath(cimFSHandle FsHandle, path *uint16) (hr error) {
hr = procCimDeletePath.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimDeletePath.Addr(), 2, uintptr(cimFSHandle), uintptr(unsafe.Pointer(path)), 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimDismountImage(volumeID *g) (hr error) {
hr = procCimDismountImage.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimDismountImage.Addr(), 1, uintptr(unsafe.Pointer(volumeID)), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimMountImage(imagePath string, fsName string, flags uint32, volumeID *g) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(imagePath)
if hr != nil {
return
}
var _p1 *uint16
_p1, hr = syscall.UTF16PtrFromString(fsName)
if hr != nil {
return
}
return _CimMountImage(_p0, _p1, flags, volumeID)
}
func _CimMountImage(imagePath *uint16, fsName *uint16, flags uint32, volumeID *g) (hr error) {
hr = procCimMountImage.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall6(procCimMountImage.Addr(), 4, uintptr(unsafe.Pointer(imagePath)), uintptr(unsafe.Pointer(fsName)), uintptr(flags), uintptr(unsafe.Pointer(volumeID)), 0, 0)
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func CimWriteStream(cimStreamHandle StreamHandle, buffer uintptr, bufferSize uint32) (hr error) {
hr = procCimWriteStream.Find()
if hr != nil {
return
}
r0, _, _ := syscall.Syscall(procCimWriteStream.Addr(), 3, uintptr(cimStreamHandle), uintptr(buffer), uintptr(bufferSize))
if int32(r0) < 0 {
if r0&0x1fff0000 == 0x00070000 {
r0 &= 0xffff
}
hr = syscall.Errno(r0)
}
return
}
func SetJobCompartmentId(handle windows.Handle, compartmentId uint32) (win32Err error) {
r0, _, _ := syscall.Syscall(procSetJobCompartmentId.Addr(), 2, uintptr(handle), uintptr(compartmentId), 0)
if r0 != 0 {

View File

@ -5,7 +5,6 @@ import (
"sync"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry"
)
// OSVersion is a wrapper for Windows version information
@ -58,18 +57,3 @@ func (osv OSVersion) String() string {
func (osv OSVersion) ToString() string {
return osv.String()
}
// Running `cmd /c ver` shows something like "10.0.20348.1000". The last component ("1000") is the revision
// number
func BuildRevision() (uint32, error) {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
if err != nil {
return 0, fmt.Errorf("open `CurrentVersion` registry key: %w", err)
}
defer k.Close()
s, _, err := k.GetIntegerValue("UBR")
if err != nil {
return 0, fmt.Errorf("read `UBR` from registry: %w", err)
}
return uint32(s), nil
}

5
vendor/github.com/Microsoft/hcsshim/tools.go generated vendored Normal file
View File

@ -0,0 +1,5 @@
//go:build tools
package hcsshim
import _ "github.com/Microsoft/go-winio/tools/mkwinsyscall"

View File

@ -49,7 +49,7 @@ type Cache struct {
}
// WithAutoRefresh returns an option to control automatic Cache refresh.
// By default auto-refresh is enabled, the list of Spec directories are
// By default, auto-refresh is enabled, the list of Spec directories are
// monitored and the Cache is automatically refreshed whenever a change
// is detected. This option can be used to disable this behavior when a
// manually refreshed mode is preferable.
@ -203,7 +203,7 @@ func (c *Cache) refresh() error {
// RefreshIfRequired triggers a refresh if necessary.
func (c *Cache) refreshIfRequired(force bool) (bool, error) {
// We need to refresh if
// - it's forced by an explicitly call to Refresh() in manual mode
// - it's forced by an explicit call to Refresh() in manual mode
// - a missing Spec dir appears (added to watch) in auto-refresh mode
if force || (c.autoRefresh && c.watch.update(c.dirErrors)) {
return true, c.refresh()
@ -244,7 +244,7 @@ func (c *Cache) InjectDevices(ociSpec *oci.Spec, devices ...string) ([]string, e
if unresolved != nil {
return unresolved, fmt.Errorf("unresolvable CDI devices %s",
strings.Join(devices, ", "))
strings.Join(unresolved, ", "))
}
if err := edits.Apply(ociSpec); err != nil {

View File

@ -20,11 +20,42 @@
package cdi
import (
"errors"
"fmt"
runc "github.com/opencontainers/runc/libcontainer/devices"
"golang.org/x/sys/unix"
)
const (
blockDevice = "b"
charDevice = "c" // or "u"
fifoDevice = "p"
)
// deviceInfoFromPath takes the path to a device and returns its type,
// major and minor device numbers.
//
// It was adapted from https://github.com/opencontainers/runc/blob/v1.1.9/libcontainer/devices/device_unix.go#L30-L69
func deviceInfoFromPath(path string) (devType string, major, minor int64, _ error) {
var stat unix.Stat_t
err := unix.Lstat(path, &stat)
if err != nil {
return "", 0, 0, err
}
switch stat.Mode & unix.S_IFMT {
case unix.S_IFBLK:
devType = blockDevice
case unix.S_IFCHR:
devType = charDevice
case unix.S_IFIFO:
devType = fifoDevice
default:
return "", 0, 0, errors.New("not a device node")
}
devNumber := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on e.g. MIPS.
return devType, int64(unix.Major(devNumber)), int64(unix.Minor(devNumber)), nil
}
// fillMissingInfo fills in missing mandatory attributes from the host device.
func (d *DeviceNode) fillMissingInfo() error {
if d.HostPath == "" {
@ -35,22 +66,22 @@ func (d *DeviceNode) fillMissingInfo() error {
return nil
}
hostDev, err := runc.DeviceFromPath(d.HostPath, "rwm")
deviceType, major, minor, err := deviceInfoFromPath(d.HostPath)
if err != nil {
return fmt.Errorf("failed to stat CDI host device %q: %w", d.HostPath, err)
}
if d.Type == "" {
d.Type = string(hostDev.Type)
d.Type = deviceType
} else {
if d.Type != string(hostDev.Type) {
if d.Type != deviceType {
return fmt.Errorf("CDI device (%q, %q), host type mismatch (%s, %s)",
d.Path, d.HostPath, d.Type, string(hostDev.Type))
d.Path, d.HostPath, d.Type, deviceType)
}
}
if d.Major == 0 && d.Type != "p" {
d.Major = hostDev.Major
d.Minor = hostDev.Minor
d.Major = major
d.Minor = minor
}
return nil

View File

@ -14,4 +14,4 @@
limitations under the License.
*/
package stats
package v1

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
file {
name: "github.com/containerd/cgroups/cgroup1/stats/metrics.proto"
name: "github.com/containerd/cgroups/stats/v1/metrics.proto"
package: "io.containerd.cgroups.v1"
dependency: "gogoproto/gogo.proto"
message_type {
name: "Metrics"
field {
@ -25,6 +26,9 @@ file {
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".io.containerd.cgroups.v1.CPUStat"
options {
65004: "CPU"
}
json_name: "cpu"
}
field {
@ -171,6 +175,9 @@ file {
number: 4
label: LABEL_REPEATED
type: TYPE_UINT64
options {
65004: "PerCPU"
}
json_name: "perCpu"
}
}
@ -212,6 +219,9 @@ file {
number: 2
label: LABEL_OPTIONAL
type: TYPE_UINT64
options {
65004: "RSS"
}
json_name: "rss"
}
field {
@ -219,6 +229,9 @@ file {
number: 3
label: LABEL_OPTIONAL
type: TYPE_UINT64
options {
65004: "RSSHuge"
}
json_name: "rssHuge"
}
field {
@ -331,6 +344,9 @@ file {
number: 19
label: LABEL_OPTIONAL
type: TYPE_UINT64
options {
65004: "TotalRSS"
}
json_name: "totalRss"
}
field {
@ -338,6 +354,9 @@ file {
number: 20
label: LABEL_OPTIONAL
type: TYPE_UINT64
options {
65004: "TotalRSSHuge"
}
json_name: "totalRssHuge"
}
field {
@ -454,6 +473,9 @@ file {
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".io.containerd.cgroups.v1.MemoryEntry"
options {
65004: "KernelTCP"
}
json_name: "kernelTcp"
}
}
@ -764,8 +786,5 @@ file {
json_name: "nrIoWait"
}
}
options {
go_package: "github.com/containerd/cgroups/cgroup1/stats"
}
syntax: "proto3"
}

View File

@ -2,12 +2,12 @@ syntax = "proto3";
package io.containerd.cgroups.v1;
option go_package = "github.com/containerd/cgroups/cgroup1/stats";
import "gogoproto/gogo.proto";
message Metrics {
repeated HugetlbStat hugetlb = 1;
PidsStat pids = 2;
CPUStat cpu = 3;
CPUStat cpu = 3 [(gogoproto.customname) = "CPU"];
MemoryStat memory = 4;
BlkIOStat blkio = 5;
RdmaStat rdma = 6;
@ -38,7 +38,7 @@ message CPUUsage {
uint64 total = 1;
uint64 kernel = 2;
uint64 user = 3;
repeated uint64 per_cpu = 4;
repeated uint64 per_cpu = 4 [(gogoproto.customname) = "PerCPU"];
}
@ -50,8 +50,8 @@ message Throttle {
message MemoryStat {
uint64 cache = 1;
uint64 rss = 2;
uint64 rss_huge = 3;
uint64 rss = 2 [(gogoproto.customname) = "RSS"];
uint64 rss_huge = 3 [(gogoproto.customname) = "RSSHuge"];
uint64 mapped_file = 4;
uint64 dirty = 5;
uint64 writeback = 6;
@ -67,8 +67,8 @@ message MemoryStat {
uint64 hierarchical_memory_limit = 16;
uint64 hierarchical_swap_limit = 17;
uint64 total_cache = 18;
uint64 total_rss = 19;
uint64 total_rss_huge = 20;
uint64 total_rss = 19 [(gogoproto.customname) = "TotalRSS"];
uint64 total_rss_huge = 20 [(gogoproto.customname) = "TotalRSSHuge"];
uint64 total_mapped_file = 21;
uint64 total_dirty = 22;
uint64 total_writeback = 23;
@ -84,7 +84,7 @@ message MemoryStat {
MemoryEntry usage = 33;
MemoryEntry swap = 34;
MemoryEntry kernel = 35;
MemoryEntry kernel_tcp = 36;
MemoryEntry kernel_tcp = 36 [(gogoproto.customname) = "KernelTCP"];
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
package filter
import (
"fmt"
"strconv"
"strings"
"github.com/containers/common/libimage/define"
"github.com/containers/image/v5/types"
)
// SearchFilter allows filtering images while searching.
type SearchFilter struct {
// Stars describes the minimal amount of starts of an image.
Stars int
// IsAutomated decides if only images from automated builds are displayed.
IsAutomated types.OptionalBool
// IsOfficial decides if only official images are displayed.
IsOfficial types.OptionalBool
}
// ParseSearchFilter turns the filter into a SearchFilter that can be used for
// searching images.
func ParseSearchFilter(filter []string) (*SearchFilter, error) {
sFilter := new(SearchFilter)
for _, f := range filter {
arr := strings.SplitN(f, "=", 2)
switch arr[0] {
case define.SearchFilterStars:
if len(arr) < 2 {
return nil, fmt.Errorf("invalid filter %q, should be stars=<value>", filter)
}
stars, err := strconv.Atoi(arr[1])
if err != nil {
return nil, fmt.Errorf("incorrect value type for stars filter: %w", err)
}
sFilter.Stars = stars
case define.SearchFilterAutomated:
if len(arr) == 2 && arr[1] == "false" {
sFilter.IsAutomated = types.OptionalBoolFalse
} else {
sFilter.IsAutomated = types.OptionalBoolTrue
}
case define.SearchFilterOfficial:
if len(arr) == 2 && arr[1] == "false" {
sFilter.IsOfficial = types.OptionalBoolFalse
} else {
sFilter.IsOfficial = types.OptionalBoolTrue
}
default:
return nil, fmt.Errorf("invalid filter type %q", f)
}
}
return sFilter, nil
}

View File

@ -110,7 +110,6 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
key = split[0]
value = split[1]
switch key {
case "after", "since":
img, err := r.time(key, value)
if err != nil {
@ -244,7 +243,7 @@ func (r *Runtime) until(value string) (time.Time, error) {
func (r *Runtime) time(key, value string) (*Image, error) {
img, _, err := r.LookupImage(value, nil)
if err != nil {
return nil, fmt.Errorf("could not find local image for filter filter %q=%q: %w", key, value, err)
return nil, fmt.Errorf("could not find local image for filter %q=%q: %w", key, value, err)
}
return img, nil
}

View File

@ -88,7 +88,7 @@ func ImageConfigFromChanges(changes []string) (*ImageConfig, error) { // nolint:
case "ENV":
// Format is either:
// ENV key=value
// ENV key=value key=value ...
// ENV key-1=value key-2=value ...
// ENV key value
// Both keys and values can be surrounded by quotes to group them.
// For now: we only support key=value

View File

@ -66,7 +66,7 @@ func (r *Runtime) Import(ctx context.Context, path string, options *ImportOption
u, err := url.ParseRequestURI(path)
if err == nil && u.Scheme != "" {
// If source is a URL, download the file.
fmt.Printf("Downloading from %q\n", path)
fmt.Printf("Downloading from %q\n", path) //nolint:forbidigo
file, err := download.FromURL(r.systemContext.BigFilesTemporaryDir, path)
if err != nil {
return "", err

View File

@ -138,7 +138,6 @@ func (r *Runtime) Pull(ctx context.Context, name string, pullPolicy config.PullP
// Dispatch the copy operation.
switch ref.Transport().Name() {
// DOCKER REGISTRY
case registryTransport.Transport.Name():
pulledImages, pullError = r.copyFromRegistry(ctx, ref, possiblyUnqualifiedName, pullPolicy, options)
@ -218,7 +217,6 @@ func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference,
// Figure out a name for the storage destination.
var storageName, imageName string
switch ref.Transport().Name() {
case dockerDaemonTransport.Transport.Name():
// Normalize to docker.io if needed (see containers/podman/issues/10998).
named, err := reference.ParseNormalizedNamed(ref.StringWithinTransport())

View File

@ -3,11 +3,10 @@ package libimage
import (
"context"
"fmt"
"strconv"
"strings"
"sync"
"github.com/containers/common/libimage/define"
"github.com/containers/common/libimage/filter"
registryTransport "github.com/containers/image/v5/docker"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/image/v5/transports/alltransports"
@ -46,7 +45,7 @@ type SearchResult struct {
// SearchOptions customize searching images.
type SearchOptions struct {
// Filter allows to filter the results.
Filter SearchFilter
Filter filter.SearchFilter
// Limit limits the number of queries per index (default: 25). Must be
// greater than 0 to overwrite the default value.
Limit int
@ -77,51 +76,6 @@ type SearchOptions struct {
Registries []string
}
// SearchFilter allows filtering images while searching.
type SearchFilter struct {
// Stars describes the minimal amount of starts of an image.
Stars int
// IsAutomated decides if only images from automated builds are displayed.
IsAutomated types.OptionalBool
// IsOfficial decides if only official images are displayed.
IsOfficial types.OptionalBool
}
// ParseSearchFilter turns the filter into a SearchFilter that can be used for
// searching images.
func ParseSearchFilter(filter []string) (*SearchFilter, error) {
sFilter := new(SearchFilter)
for _, f := range filter {
arr := strings.SplitN(f, "=", 2)
switch arr[0] {
case define.SearchFilterStars:
if len(arr) < 2 {
return nil, fmt.Errorf("invalid filter %q, should be stars=<value>", filter)
}
stars, err := strconv.Atoi(arr[1])
if err != nil {
return nil, fmt.Errorf("incorrect value type for stars filter: %w", err)
}
sFilter.Stars = stars
case define.SearchFilterAutomated:
if len(arr) == 2 && arr[1] == "false" {
sFilter.IsAutomated = types.OptionalBoolFalse
} else {
sFilter.IsAutomated = types.OptionalBoolTrue
}
case define.SearchFilterOfficial:
if len(arr) == 2 && arr[1] == "false" {
sFilter.IsOfficial = types.OptionalBoolFalse
} else {
sFilter.IsOfficial = types.OptionalBoolTrue
}
default:
return nil, fmt.Errorf("invalid filter type %q", f)
}
}
return sFilter, nil
}
// Search searches term. If term includes a registry, only this registry will
// be used for searching. Otherwise, the unqualified-search registries in
// containers-registries.conf(5) or the ones specified in the options will be
@ -261,7 +215,7 @@ func (r *Runtime) searchImageInRegistry(ctx context.Context, term, registry stri
paramsArr := []SearchResult{}
for i := 0; i < limit; i++ {
// Check whether query matches filters
if !(options.Filter.matchesAutomatedFilter(results[i]) && options.Filter.matchesOfficialFilter(results[i]) && options.Filter.matchesStarFilter(results[i])) {
if !(filterMatchesAutomatedFilter(&options.Filter, results[i]) && filterMatchesOfficialFilter(&options.Filter, results[i]) && filterMatchesStarFilter(&options.Filter, results[i])) {
continue
}
official := ""
@ -330,18 +284,18 @@ func searchRepositoryTags(ctx context.Context, sys *types.SystemContext, registr
return paramsArr, nil
}
func (f *SearchFilter) matchesStarFilter(result registryTransport.SearchResult) bool {
func filterMatchesStarFilter(f *filter.SearchFilter, result registryTransport.SearchResult) bool {
return result.StarCount >= f.Stars
}
func (f *SearchFilter) matchesAutomatedFilter(result registryTransport.SearchResult) bool {
func filterMatchesAutomatedFilter(f *filter.SearchFilter, result registryTransport.SearchResult) bool {
if f.IsAutomated != types.OptionalBoolUndefined {
return result.IsAutomated == (f.IsAutomated == types.OptionalBoolTrue)
}
return true
}
func (f *SearchFilter) matchesOfficialFilter(result registryTransport.SearchResult) bool {
func filterMatchesOfficialFilter(f *filter.SearchFilter, result registryTransport.SearchResult) bool {
if f.IsOfficial != types.OptionalBoolUndefined {
return result.IsOfficial == (f.IsOfficial == types.OptionalBoolTrue)
}

View File

@ -23,7 +23,7 @@ type netavarkError struct {
func (e *netavarkError) Error() string {
ec := ""
// only add the exit code the the error message if we have at least info log level
// only add the exit code the error message if we have at least info log level
// the normal user does not need to care about the number
if e.exitCode > 0 && logrus.IsLevelEnabled(logrus.InfoLevel) {
ec = " (exit code " + strconv.Itoa(e.exitCode) + ")"

View File

@ -65,7 +65,7 @@ func (n *netavarkNetwork) openDB() (*bbolt.DB, error) {
return db, nil
}
// allocIPs will allocate ips for the the container. It will change the
// allocIPs will allocate ips for the container. It will change the
// NetworkOptions in place. When static ips are given it will validate
// that these are free to use and will allocate them to the container.
func (n *netavarkNetwork) allocIPs(opts *types.NetworkOptions) error {

View File

@ -44,7 +44,7 @@ type netavarkNetwork struct {
// defaultsubnetPools contains the subnets which must be used to allocate a free subnet by network create
defaultsubnetPools []config.SubnetPool
// dnsBindPort is set the the port to pass to netavark for aardvark
// dnsBindPort is set the port to pass to netavark for aardvark
dnsBindPort uint16
// pluginDirs list of directories were netavark plugins are located
@ -87,7 +87,7 @@ type InitConfig struct {
// DefaultsubnetPools contains the subnets which must be used to allocate a free subnet by network create
DefaultsubnetPools []config.SubnetPool
// DNSBindPort is set the the port to pass to netavark for aardvark
// DNSBindPort is set the port to pass to netavark for aardvark
DNSBindPort uint16
// PluginDirs list of directories were netavark plugins are located

View File

@ -35,7 +35,7 @@ const (
// NetworkBackend returns the network backend name and interface
// It returns either the CNI or netavark backend depending on what is set in the config.
// If the the backend is set to "" we will automatically assign the backend on the following conditions:
// If the backend is set to "" we will automatically assign the backend on the following conditions:
// 1. read ${graphroot}/defaultNetworkBackend
// 2. find netavark binary (if not installed use CNI)
// 3. check containers, images and CNI networks and if there are some we have an existing install and should continue to use CNI

View File

@ -43,7 +43,7 @@ profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
deny /sys/kernel/security/** rwklx,
{{if ge .Version 208095}}
# suppress ptrace denials when using using 'ps' inside a container
# suppress ptrace denials when using 'ps' inside a container
ptrace (trace,read) peer={{.Name}},
{{end}}
}

View File

@ -10,13 +10,13 @@ import (
"path/filepath"
"strings"
"github.com/containers/common/pkg/util"
"github.com/containers/image/v5/docker"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/pkg/docker/config"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/image/v5/types"
"github.com/sirupsen/logrus"
terminal "golang.org/x/term"
)
// ErrNewCredentialsInvalid means that the new user-provided credentials are
@ -259,7 +259,7 @@ func getUserAndPass(opts *LoginOptions, password, userFromAuthFile string) (user
if err != nil {
return "", "", fmt.Errorf("reading username: %w", err)
}
// If the user just hit enter, use the displayed user from the
// If the user just hit enter, use the displayed user from
// the authentication file. This allows to do a lazy
// `$ buildah login -p $NEW_PASSWORD` without specifying the
// user.
@ -269,7 +269,7 @@ func getUserAndPass(opts *LoginOptions, password, userFromAuthFile string) (user
}
if password == "" {
fmt.Fprint(opts.Stdout, "Password: ")
pass, err := terminal.ReadPassword(int(os.Stdin.Fd()))
pass, err := util.ReadPassword(int(os.Stdin.Fd()))
if err != nil {
return "", "", fmt.Errorf("reading password: %w", err)
}
@ -336,7 +336,7 @@ func Logout(systemContext *types.SystemContext, opts *LogoutOptions, args []stri
authInvalid := docker.CheckAuth(context.Background(), systemContext, authConfig.Username, authConfig.Password, registry)
if authConfig.Username != "" && authConfig.Password != "" && authInvalid == nil {
fmt.Printf("Not logged into %s with current tool. Existing credentials were established via docker login. Please use docker logout instead.\n", key)
fmt.Printf("Not logged into %s with current tool. Existing credentials were established via docker login. Please use docker logout instead.\n", key) //nolint:forbidigo
return nil
}
return fmt.Errorf("not logged into %s", key)

View File

@ -34,7 +34,6 @@ func (c *linuxBlkioHandler) Apply(ctr *CgroupControl, res *configs.Resources) er
return err
}
return man.Set(res)
}
path := filepath.Join(cgroupRoot, Blkio, ctr.config.Path)
return c.Blkio.Set(path, res)

View File

@ -582,7 +582,7 @@ func (c *CgroupControl) Stat() (*Metrics, error) {
return &m, nil
}
func readCgroup2MapPath(path string) (map[string][]string, error) {
func readCgroupMapPath(path string) (map[string][]string, error) {
ret := map[string][]string{}
f, err := os.Open(path)
if err != nil {
@ -610,5 +610,5 @@ func readCgroup2MapPath(path string) (map[string][]string, error) {
func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, error) {
p := filepath.Join(cgroupRoot, ctr.path, name)
return readCgroup2MapPath(p)
return readCgroupMapPath(p)
}

View File

@ -269,7 +269,7 @@ func readFileByKeyAsUint64(path, key string) (uint64, error) {
for _, line := range strings.Split(string(content), "\n") {
fields := strings.SplitN(line, " ", 2)
if fields[0] == key {
v := cleanString(string(fields[1]))
v := cleanString(fields[1])
if v == "max" {
return math.MaxUint64, nil
}
@ -542,7 +542,7 @@ func (c *CgroupControl) Stat() (*cgroups.Stats, error) {
return &m, nil
}
func readCgroup2MapPath(path string) (map[string][]string, error) {
func readCgroupMapPath(path string) (map[string][]string, error) {
ret := map[string][]string{}
f, err := os.Open(path)
if err != nil {
@ -570,5 +570,5 @@ func readCgroup2MapPath(path string) (map[string][]string, error) {
func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, error) {
p := filepath.Join(cgroupRoot, ctr.config.Path, name)
return readCgroup2MapPath(p)
return readCgroupMapPath(p)
}

View File

@ -4,7 +4,9 @@
package cgroups
import (
"fmt"
"path/filepath"
"strconv"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
@ -63,9 +65,26 @@ func (c *linuxMemHandler) Stat(ctr *CgroupControl, m *cgroups.Stats) error {
} else {
memoryRoot = ctr.getCgroupv1Path(Memory)
limitFilename = "memory.limit_in_bytes"
if memUsage.Usage.Usage, err = readFileAsUint64(filepath.Join(memoryRoot, "memory.usage_in_bytes")); err != nil {
path := filepath.Join(memoryRoot, "memory.stat")
values, err := readCgroupMapPath(path)
if err != nil {
return err
}
// cgroup v1 does not have a single "anon" field, but we can calculate it
// from total_active_anon and total_inactive_anon
memUsage.Usage.Usage = 0
for _, key := range []string{"total_active_anon", "total_inactive_anon"} {
if _, found := values[key]; !found {
continue
}
res, err := strconv.ParseUint(values[key][0], 10, 64)
if err != nil {
return fmt.Errorf("parse %s from %s: %w", key, path, err)
}
memUsage.Usage.Usage += res
}
}
memUsage.Usage.Limit, err = readFileAsUint64(filepath.Join(memoryRoot, limitFilename))

View File

@ -29,7 +29,7 @@ func systemdCreate(resources *configs.Resources, path string, c *systemdDbus.Con
systemdDbus.PropDescription(fmt.Sprintf("cgroup %s", name)),
systemdDbus.PropWants(slice),
}
ioString := ""
var ioString string
v2, _ := IsCgroup2UnifiedMode()
if v2 {
ioString = "IOAccounting"
@ -250,7 +250,6 @@ func resourcesToProps(res *configs.Resources, v2 bool) (map[string]uint64, map[s
} else {
structMap["BlockIODeviceWeight"] = append(structMap["BlockIODeviceWeight"], newWeight)
}
}
}

View File

@ -64,7 +64,7 @@ func GetSystemCPUUsage() (uint64, error) {
}
p := filepath.Join(cgroupRoot, file.Name(), "cpu.stat")
values, err := readCgroup2MapPath(p)
values, err := readCgroupMapPath(p)
if err != nil {
return 0, err
}

View File

@ -26,7 +26,7 @@ func WriteFile(dir, file, data string) error {
}
defer fd.Close()
for {
_, err := fd.Write([]byte(data))
_, err := fd.WriteString(data)
if errors.Is(err, unix.EINTR) {
logrus.Infof("interrupted while writing %s to %s", data, fd.Name())
continue
@ -85,7 +85,6 @@ func OpenFile(dir, file string, flags int) (*os.File, error) {
Mode: uint64(mode),
})
if err != nil {
fmt.Println("Error in openat")
return nil, err
}

View File

@ -169,7 +169,7 @@ type ContainersConfig struct {
// InitPath is the path for init to run if the Init bool is enabled
InitPath string `toml:"init_path,omitempty"`
// IPCNS way to to create a ipc namespace for the container
// IPCNS way to create a ipc namespace for the container
IPCNS string `toml:"ipcns,omitempty"`
// LogDriver for the container. For example: k8s-file and journald
@ -321,7 +321,7 @@ type EngineConfig struct {
// helper binaries.
HelperBinariesDir []string `toml:"helper_binaries_dir"`
// configuration files. When the same filename is present in in
// configuration files. When the same filename is present in
// multiple directories, the file in the directory listed last in
// this slice takes precedence.
HooksDir []string `toml:"hooks_dir,omitempty"`
@ -740,14 +740,11 @@ func (c *Config) CheckCgroupsAndAdjustConfig() {
}
func (c *Config) addCAPPrefix() {
toCAPPrefixed := func(cap string) string {
if !strings.HasPrefix(strings.ToLower(cap), "cap_") {
return "CAP_" + strings.ToUpper(cap)
for i, val := range c.Containers.DefaultCapabilities {
if !strings.HasPrefix(strings.ToLower(val), "cap_") {
val = "CAP_" + strings.ToUpper(val)
}
return cap
}
for i, cap := range c.Containers.DefaultCapabilities {
c.Containers.DefaultCapabilities[i] = toCAPPrefixed(cap)
c.Containers.DefaultCapabilities[i] = val
}
}

View File

@ -30,7 +30,7 @@ func getDefaultProcessLimits() []string {
val := strings.TrimSuffix(string(dat), "\n")
max, err := strconv.ParseUint(val, 10, 64)
if err == nil {
rlim = unix.Rlimit{Cur: uint64(max), Max: uint64(max)}
rlim = unix.Rlimit{Cur: max, Max: max}
}
}
defaultLimits := []string{}

View File

@ -165,7 +165,7 @@ func (ob *optionalIntValue) String() string {
if !ob.present {
return "" // If the value is not present, just return an empty string, any other value wouldn't make sense.
}
return strconv.Itoa(int(ob.value))
return strconv.Itoa(ob.value)
}
// Type returns the int's type.

View File

@ -51,8 +51,7 @@ func Split(src string) (entries []string) {
}
entries = []string{}
var runes [][]rune
lastClass := 0
class := 0
var class, lastClass int
// split into fields based on class of unicode character
for _, r := range src {
switch {

View File

@ -74,7 +74,6 @@ func IsErrorRetryable(err error) bool {
}
switch e := err.(type) {
case errcode.Error:
switch e.Code {
case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeDenied,

View File

@ -150,7 +150,7 @@ func (d *Driver) getAllData() (map[string][]byte, error) {
return nil, err
}
secretData := new(map[string][]byte)
err = json.Unmarshal([]byte(byteValue), secretData)
err = json.Unmarshal(byteValue, secretData)
if err != nil {
return nil, err
}

View File

@ -58,7 +58,6 @@ func (cfg *driverConfig) ParseOpts(opts map[string]string) error {
cfg.ListCommand == "" ||
cfg.LookupCommand == "" ||
cfg.StoreCommand == "" {
return errMissingConfig
}
return nil

Some files were not shown because too many files have changed in this diff Show More