diff options
-rw-r--r-- | .cirrus.yml | 10 | ||||
-rw-r--r-- | cmd/podman/containers/create.go | 5 | ||||
-rw-r--r-- | cmd/podman/machine/list.go | 3 | ||||
-rw-r--r-- | cmd/podman/machine/start.go | 2 | ||||
-rw-r--r-- | cmd/podman/pods/create.go | 10 | ||||
-rwxr-xr-x | contrib/cirrus/setup_environment.sh | 6 | ||||
-rw-r--r-- | docs/source/markdown/podman-machine-list.1.md | 39 | ||||
-rw-r--r-- | libpod/kube.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/pods.go | 12 | ||||
-rw-r--r-- | test/e2e/containers_conf_test.go | 32 | ||||
-rw-r--r-- | test/system/010-images.bats | 4 | ||||
-rw-r--r-- | test/system/035-logs.bats | 8 | ||||
-rw-r--r-- | test/system/200-pod.bats | 5 |
13 files changed, 98 insertions, 40 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index 3dfbff11b..c33ed9c0c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -29,7 +29,7 @@ env: UBUNTU_NAME: "ubuntu-2110" # Google-cloud VM Images - IMAGE_SUFFIX: "c6015869890330624" + IMAGE_SUFFIX: "c6454758209748992" FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}" PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}" UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}" @@ -612,10 +612,10 @@ rootless_gitlab_test_task: alias: rootless_gitlab_test skip: *tags only_if: *not_docs - # Test temporarily ignored due to failure on/around 7-10th Dec. 2021 - # Appears related to https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28732 - # Log: https://cirrus-ci.com/task/5708221852680192?logs=setup#L433 - allow_failures: $CI == $CI + # Community-maintained downstream test may fail unexpectedly. + # Ref. repository: https://gitlab.com/gitlab-org/gitlab-runner + # If necessary, uncomment the next line and file issue(s) with details. + # allow_failures: $CI == $CI depends_on: - rootless_integration_test gce_instance: *standardvm diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index 9610c29dc..694b97fe5 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -388,10 +388,7 @@ func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts if err != nil { return nil, err } - imageName := config.DefaultInfraImage - podGen.InfraImage = imageName - podGen.InfraContainerSpec = specgen.NewSpecGenerator(imageName, false) - podGen.InfraContainerSpec.RawImageName = imageName + podGen.InfraContainerSpec = specgen.NewSpecGenerator("", false) podGen.InfraContainerSpec.NetworkOptions = podGen.NetworkOptions err = specgenutil.FillOutSpecGen(podGen.InfraContainerSpec, &infraOpts, []string{}) if err != nil { diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index 858d87401..ed43b42df 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -32,6 +32,7 @@ var ( Args: validate.NoArgs, ValidArgsFunction: completion.AutocompleteNone, Example: `podman machine list, + podman machine list --format json podman machine ls`, } listFlag = listFlagType{} @@ -96,7 +97,7 @@ func list(cmd *cobra.Command, args []string) error { return err } - b, err := json.Marshal(machineReporter) + b, err := json.MarshalIndent(machineReporter, "", " ") if err != nil { return err } diff --git a/cmd/podman/machine/start.go b/cmd/podman/machine/start.go index 9c9c24f64..a3770d61a 100644 --- a/cmd/podman/machine/start.go +++ b/cmd/podman/machine/start.go @@ -60,9 +60,9 @@ func start(cmd *cobra.Command, args []string) error { if err != nil { return err } + fmt.Printf("Starting machine %q\n", vmName) if err := vm.Start(vmName, machine.StartOptions{}); err != nil { return err } - fmt.Printf("Machine %q started successfully\n", vmName) return nil } diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index f844812c2..6a28f7a79 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -71,7 +71,11 @@ func init() { _ = createCommand.RegisterFlagCompletionFunc(nameFlagName, completion.AutocompleteNone) infraImageFlagName := "infra-image" - flags.StringVar(&infraImage, infraImageFlagName, containerConfig.Engine.InfraImage, "The image of the infra container to associate with the pod") + var defInfraImage string + if !registry.IsRemote() { + defInfraImage = containerConfig.Engine.InfraImage + } + flags.StringVar(&infraImage, infraImageFlagName, defInfraImage, "The image of the infra container to associate with the pod") _ = createCommand.RegisterFlagCompletionFunc(infraImageFlagName, common.AutocompleteImages) podIDFileFlagName := "pod-id-file" @@ -109,7 +113,9 @@ func create(cmd *cobra.Command, args []string) error { return errors.Wrapf(err, "unable to process labels") } - imageName = infraImage + if cmd.Flag("infra-image").Changed { + imageName = infraImage + } img := imageName if !createOptions.Infra { if cmd.Flag("no-hosts").Changed { diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index ee80a209c..8f535c7e7 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -118,12 +118,6 @@ fi case "$OS_RELEASE_ID" in ubuntu) ;; fedora) - # Force a crun version that has this fix: https://github.com/containers/crun/pull/819 - # FIXME: Remove once a fixed crun made its way into Fedora - if test "$OS_RELEASE_VER" == "35"; then - yum upgrade -y crun - fi - if ((CONTAINER==0)); then # All SELinux distros need this for systemd-in-a-container msg "Enabling container_manage_cgroup" diff --git a/docs/source/markdown/podman-machine-list.1.md b/docs/source/markdown/podman-machine-list.1.md index accdd760c..b2596ac59 100644 --- a/docs/source/markdown/podman-machine-list.1.md +++ b/docs/source/markdown/podman-machine-list.1.md @@ -20,16 +20,23 @@ tied to the Linux kernel. #### **--format**=*format* -Format list output using a Go template. - +Change the default output format. This can be of a supported type like 'json' +or a Go template. Valid placeholders for the Go template are listed below: | **Placeholder** | **Description** | | --------------- | ------------------------------- | -| .Name | VM name | +| .CPUs | Number of CPUs | | .Created | Time since VM creation | +| .Default | Is default machine | +| .DiskSize | Disk size of machine | +| .LastUp | Time machine was last up | | .LastUp | Time since the VM was last run | -| .VMType | VM type | +| .Memory | Allocated memeory for machine | +| .Name | VM name | +| .Running | Is machine running | +| .Stream | Stream name | +| .VMType | VM type | #### **--help** @@ -43,8 +50,28 @@ Omit the table headings from the listing of pods. ``` $ podman machine list - -$ podman machine ls --format {{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\n +NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE +podman-machine-default qemu 2 weeks ago 2 weeks ago 1 2.147GB 10.74GB + +$ podman machine ls --format "table {{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}" +NAME VM TYPE CREATED LAST UP +podman-machine-default qemu 2 weeks ago 2 weeks ago + +$ podman machine ls --format json +[ + { + "Name": "podman-machine-default", + "Default": false, + "Created": "2021-12-27T10:36:14.373347492-05:00", + "Running": false, + "LastUp": "2021-12-27T11:22:50.17333371-05:00", + "Stream": "default", + "VMType": "qemu", + "CPUs": 1, + "Memory": "2147483648", + "DiskSize": "10737418240" + } +] ``` ## SEE ALSO diff --git a/libpod/kube.go b/libpod/kube.go index d667616d0..f465fc776 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -595,7 +595,7 @@ func containerToV1Container(ctx context.Context, c *Container) (v1.Container, [] // pause one and make sure it's in the storage by pulling it down if // missing. if image == "" && c.IsInfra() { - image = config.DefaultInfraImage + image = c.runtime.config.Engine.InfraImage if _, err := c.runtime.libimageRuntime.Pull(ctx, image, config.PullPolicyMissing, nil); err != nil { return kubeContainer, nil, nil, nil, err } diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index 1b29831b4..43b39060b 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -7,7 +7,6 @@ import ( "strings" "time" - "github.com/containers/common/pkg/config" "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/api/handlers" @@ -62,15 +61,8 @@ func PodCreate(w http.ResponseWriter, r *http.Request) { psg.InfraContainerSpec.Name = psg.InfraName psg.InfraContainerSpec.ConmonPidFile = psg.InfraConmonPidFile psg.InfraContainerSpec.ContainerCreateCommand = psg.InfraCommand - imageName := psg.InfraImage - rawImageName := psg.InfraImage - if imageName == "" { - imageName = config.DefaultInfraImage - rawImageName = config.DefaultInfraImage - } - psg.InfraImage = imageName - psg.InfraContainerSpec.Image = imageName - psg.InfraContainerSpec.RawImageName = rawImageName + psg.InfraContainerSpec.Image = psg.InfraImage + psg.InfraContainerSpec.RawImageName = psg.InfraImage } podSpecComplete := entities.PodSpec{PodSpecGen: psg} pod, err := generate.MakePod(&podSpecComplete, runtime) diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 2a6f177f2..838221dd5 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -452,4 +452,36 @@ var _ = Describe("Podman run", func() { Expect(result).Should(Exit(0)) Expect(result.OutputToString()).To(ContainSubstring("(default 1234)")) }) + + It("podman bad infra_image name in containers.conf", func() { + infra1 := "i.do/not/exist:image" + infra2 := "i.still.do/not/exist:image" + errorString := "initializing source docker://" + infra1 + error2String := "initializing source docker://" + infra2 + configPath := filepath.Join(podmanTest.TempDir, "containers.conf") + os.Setenv("CONTAINERS_CONF", configPath) + + containersConf := []byte("[engine]\ninfra_image=\"" + infra1 + "\"") + err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) + Expect(err).To(BeNil()) + + if IsRemote() { + podmanTest.RestartRemoteService() + } + + result := podmanTest.Podman([]string{"pod", "create", "--infra-image", infra2}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(125)) + Expect(result.ErrorToString()).To(ContainSubstring(error2String)) + + result = podmanTest.Podman([]string{"pod", "create"}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(125)) + Expect(result.ErrorToString()).To(ContainSubstring(errorString)) + + result = podmanTest.Podman([]string{"create", "--pod", "new:pod1", ALPINE}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(125)) + Expect(result.ErrorToString()).To(ContainSubstring(errorString)) + }) }) diff --git a/test/system/010-images.bats b/test/system/010-images.bats index 201418620..ebd71450f 100644 --- a/test/system/010-images.bats +++ b/test/system/010-images.bats @@ -272,6 +272,10 @@ Deleted: $pauseID" "infra images gets removed as well" is "$output" "" run_podman create --pod new:$pname $IMAGE + # Clean up + run_podman rm "${lines[-1]}" + run_podman pod rm -a + run_podman rmi $pauseImage } @test "podman images - rmi -f can remove infra images" { diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index 3caf97a22..db50c8f8c 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -90,14 +90,16 @@ ${cid[0]} d" "Sequential output from logs" } function _log_test_restarted() { - run_podman run --log-driver=$1 --name logtest $IMAGE sh -c 'start=0; if test -s log; then start=`tail -n 1 log`; fi; seq `expr $start + 1` `expr $start + 10` | tee -a log' + local driver=$1 + local events_backend=$(_additional_events_backend $driver) + run_podman run --log-driver=$driver ${events_backend} --name logtest $IMAGE sh -c 'start=0; if test -s log; then start=`tail -n 1 log`; fi; seq `expr $start + 1` `expr $start + 10` | tee -a log' # FIXME: #9597 # run/start is flaking for remote so let's wait for the container condition # to stop wasting energy until the root cause gets fixed. run_podman container wait --condition=exited logtest - run_podman start -a logtest + run_podman ${events_backend} start -a logtest logfile=$(mktemp -p ${PODMAN_TMPDIR} logfileXXXXXXXX) - $PODMAN $_PODMAN_TEST_OPTS logs -f logtest > $logfile + $PODMAN $_PODMAN_TEST_OPTS ${events_backend} logs -f logtest > $logfile expected=$(mktemp -p ${PODMAN_TMPDIR} expectedXXXXXXXX) seq 1 20 > $expected diff -u ${expected} ${logfile} diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index 57d052ce2..6abdf9779 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -62,8 +62,8 @@ function teardown() { @test "podman pod create - custom infra image" { + skip_if_remote "CONTAINERS_CONF only effects server side" image="i.do/not/exist:image" - tmpdir=$PODMAN_TMPDIR/pod-test run mkdir -p $tmpdir containersconf=$tmpdir/containers.conf @@ -77,6 +77,9 @@ EOF CONTAINERS_CONF=$containersconf run_podman 125 pod create is "$output" ".*initializing source docker://$image:.*" + + CONTAINERS_CONF=$containersconf run_podman 125 create --pod new:test $IMAGE + is "$output" ".*initializing source docker://$image:.*" } @test "podman pod - communicating between pods" { |