diff options
-rw-r--r-- | .cirrus.yml | 32 | ||||
-rw-r--r-- | docs/source/markdown/podman-manifest.1.md | 2 | ||||
-rw-r--r-- | pkg/machine/fedora.go | 32 | ||||
-rw-r--r-- | pkg/machine/pull.go | 7 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 46 | ||||
-rw-r--r-- | test/system/251-system-service.bats | 58 |
6 files changed, 104 insertions, 73 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index b9c284002..b585c41f8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -25,9 +25,10 @@ env: #### #### Cache-image names to test with (double-quotes around names are critical) + #### Comment out fedora-35 for podman 4.x branches. #### FEDORA_NAME: "fedora-36" - PRIOR_FEDORA_NAME: "fedora-35" + #PRIOR_FEDORA_NAME: "fedora-35" UBUNTU_NAME: "ubuntu-2110" # Image identifiers @@ -35,12 +36,12 @@ env: FEDORA_AMI_ID: "ami-06a41d8a81ab56afa" # Complete image names FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}" - PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}" + #PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}" UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}" # Container FQIN's FEDORA_CONTAINER_FQIN: "quay.io/libpod/fedora_podman:${IMAGE_SUFFIX}" - PRIOR_FEDORA_CONTAINER_FQIN: "quay.io/libpod/prior-fedora_podman:${IMAGE_SUFFIX}" + #PRIOR_FEDORA_CONTAINER_FQIN: "quay.io/libpod/prior-fedora_podman:${IMAGE_SUFFIX}" UBUNTU_CONTAINER_FQIN: "quay.io/libpod/ubuntu_podman:${IMAGE_SUFFIX}" #### @@ -168,11 +169,11 @@ build_task: CTR_FQIN: ${FEDORA_CONTAINER_FQIN} # ID for re-use of build output CI_DESIRED_RUNTIME: crun - - env: &priorfedora_envvars - DISTRO_NV: ${PRIOR_FEDORA_NAME} - VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} - CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} - CI_DESIRED_RUNTIME: crun + #- env: &priorfedora_envvars + #DISTRO_NV: ${PRIOR_FEDORA_NAME} + #VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} + #CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} + #CI_DESIRED_RUNTIME: crun - env: &ubuntu_envvars DISTRO_NV: ${UBUNTU_NAME} VM_IMAGE_NAME: ${UBUNTU_CACHE_IMAGE_NAME} @@ -422,7 +423,8 @@ unit_test_task: - validate matrix: - env: *stdenvars - - env: *priorfedora_envvars + # Fedora 35 skipped for podman4 + #- env: *priorfedora_envvars - env: *ubuntu_envvars # Special-case: Rootless on latest Fedora (standard) VM - name: "Rootless unit on $DISTRO_NV" @@ -548,11 +550,11 @@ container_integration_test_task: _BUILD_CACHE_HANDLE: ${FEDORA_NAME}-build-${CIRRUS_BUILD_ID} VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME} CTR_FQIN: ${FEDORA_CONTAINER_FQIN} - - env: - DISTRO_NV: ${PRIOR_FEDORA_NAME} - _BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} - VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} - CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} + #- env: + #DISTRO_NV: ${PRIOR_FEDORA_NAME} + #_BUILD_CACHE_HANDLE: ${PRIOR_FEDORA_NAME}-build-${CIRRUS_BUILD_ID} + #VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME} + #CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN} gce_instance: *standardvm timeout_in: 90m env: @@ -843,9 +845,9 @@ meta_task: image: quay.io/libpod/imgts:$IMAGE_SUFFIX env: # Space-separated list of images used by this repository state + # Disabled ${PRIOR_FEDORA_CACHE_IMAGE_NAME} for Fedora 35 IMGNAMES: >- ${FEDORA_CACHE_IMAGE_NAME} - ${PRIOR_FEDORA_CACHE_IMAGE_NAME} ${UBUNTU_CACHE_IMAGE_NAME} build-push-${IMAGE_SUFFIX} BUILDID: "${CIRRUS_BUILD_ID}" diff --git a/docs/source/markdown/podman-manifest.1.md b/docs/source/markdown/podman-manifest.1.md index 5ff44c1d5..cc716b2a0 100644 --- a/docs/source/markdown/podman-manifest.1.md +++ b/docs/source/markdown/podman-manifest.1.md @@ -22,7 +22,7 @@ The `podman manifest` command provides subcommands which can be used to: | inspect | [podman-manifest-inspect(1)](podman-manifest-inspect.1.md) | Display a manifest list or image index. | | push | [podman-manifest-push(1)](podman-manifest-push.1.md) | Push a manifest list or image index to a registry. | | remove | [podman-manifest-remove(1)](podman-manifest-remove.1.md) | Remove an image from a manifest list or image index. | -| rm | [podman-manifest-rme(1)](podman-manifest-rm.1.md) | Remove manifest list or image index from local storage. | +| rm | [podman-manifest-rm(1)](podman-manifest-rm.1.md) | Remove manifest list or image index from local storage. | ## EXAMPLES diff --git a/pkg/machine/fedora.go b/pkg/machine/fedora.go index 7c80fc5d3..7ac4692e3 100644 --- a/pkg/machine/fedora.go +++ b/pkg/machine/fedora.go @@ -6,7 +6,10 @@ package machine import ( "errors" "fmt" + "io" "os" + "path" + "strings" "net/http" "net/url" @@ -23,7 +26,7 @@ type FedoraDownload struct { } func NewFedoraDownloader(vmType, vmName, releaseStream string) (DistributionDownload, error) { - downloadURL, size, err := getFedoraDownload(githubLatestReleaseURL) + downloadURL, version, size, err := getFedoraDownload(githubLatestReleaseURL) if err != nil { return nil, err } @@ -33,7 +36,7 @@ func NewFedoraDownloader(vmType, vmName, releaseStream string) (DistributionDown return nil, err } - imageName := "rootfs.tar.xz" + imageName := fmt.Sprintf("fedora-podman-%s.tar.xz", version) f := FedoraDownload{ Download: Download{ @@ -77,21 +80,36 @@ func (f FedoraDownload) CleanCache() error { return removeImageAfterExpire(f.CacheDir, expire) } -func getFedoraDownload(releaseURL string) (*url.URL, int64, error) { +func getFedoraDownload(releaseURL string) (*url.URL, string, int64, error) { downloadURL, err := url.Parse(releaseURL) if err != nil { - return nil, -1, fmt.Errorf("invalid URL generated from discovered Fedora file: %s: %w", releaseURL, err) + return nil, "", -1, fmt.Errorf("invalid URL generated from discovered Fedora file: %s: %w", releaseURL, err) } resp, err := http.Head(releaseURL) if err != nil { - return nil, -1, fmt.Errorf("head request failed: %s: %w", releaseURL, err) + return nil, "", -1, fmt.Errorf("head request failed: %s: %w", releaseURL, err) } _ = resp.Body.Close() + contentLen := resp.ContentLength if resp.StatusCode != http.StatusOK { - return nil, -1, fmt.Errorf("head request failed: %s: %w", releaseURL, err) + return nil, "", -1, fmt.Errorf("head request failed: %s: %w", releaseURL, err) } - return downloadURL, resp.ContentLength, nil + verURL := *downloadURL + verURL.Path = path.Join(path.Dir(downloadURL.Path), "version") + + resp, err = http.Get(verURL.String()) + if err != nil { + return nil, "", -1, fmt.Errorf("get request failed: %s: %w", verURL.String(), err) + } + + bytes, err := io.ReadAll(&io.LimitedReader{R: resp.Body, N: 1024}) + if err != nil { + return nil, "", -1, fmt.Errorf("failed reading: %s: %w", verURL.String(), err) + } + _ = resp.Body.Close() + + return downloadURL, strings.TrimSpace(string(bytes)), contentLen, nil } diff --git a/pkg/machine/pull.go b/pkg/machine/pull.go index 08baa7df8..26b6adc67 100644 --- a/pkg/machine/pull.go +++ b/pkg/machine/pull.go @@ -113,7 +113,7 @@ func DownloadImage(d DistributionDownload) error { return err } if !ok { - if err := DownloadVMImage(d.Get().URL, d.Get().LocalPath); err != nil { + if err := DownloadVMImage(d.Get().URL, d.Get().ImageName, d.Get().LocalPath); err != nil { return err } // Clean out old cached images, since we didn't find needed image in cache @@ -128,7 +128,7 @@ func DownloadImage(d DistributionDownload) error { // DownloadVMImage downloads a VM image from url to given path // with download status -func DownloadVMImage(downloadURL *url2.URL, localImagePath string) error { +func DownloadVMImage(downloadURL *url2.URL, imageName string, localImagePath string) error { out, err := os.Create(localImagePath) if err != nil { return err @@ -153,8 +153,7 @@ func DownloadVMImage(downloadURL *url2.URL, localImagePath string) error { return fmt.Errorf("downloading VM image %s: %s", downloadURL, resp.Status) } size := resp.ContentLength - urlSplit := strings.Split(downloadURL.Path, "/") - prefix := "Downloading VM image: " + urlSplit[len(urlSplit)-1] + prefix := "Downloading VM image: " + imageName onComplete := prefix + ": done" p := mpb.New( diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 70ae76eb8..9a91501dd 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -296,8 +296,6 @@ LISTEN_FDNAMES=listen_fdnames" | sort) } @test "podman-kube@.service template" { - skip_if_remote "systemd units do not work with remote clients" - # If running from a podman source directory, build and use the source # version of the play-kube-@ unit file unit_name="podman-kube@.service" @@ -375,48 +373,4 @@ EOF rm -f $UNIT_DIR/$unit_name } -@test "podman-system-service containers survive service stop" { - skip_if_remote "N/A under podman-remote" - - SERVICE_NAME=podman-service-$(random_string) - port=$(random_free_port) - URL=tcp://127.0.0.1:$port - - systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 - wait_for_port 127.0.0.1 $port - - # Start a long-running container. - cname=keeps-running - run_podman --url $URL run -d --name $cname $IMAGE top -d 2 - - run_podman container inspect -l --format "{{.State.Running}}" - is "$output" "true" "This should never fail" - - systemctl stop $SERVICE_NAME - - run_podman container inspect $cname --format "{{.State.Running}}" - is "$output" "true" "Container is still running after podman server stops" - - run_podman rm -f -t 0 $cname -} - -@test "podman-system-service containers --host" { - skip_if_remote "N/A under podman-remote" - - SERVICE_NAME=podman-service-$(random_string) - port=$(random_free_port) - URL=tcp://127.0.0.1:$port - - systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 - wait_for_port 127.0.0.1 $port - - run_podman --host $URL run --rm $IMAGE true - run_podman -H $URL run --rm $IMAGE true - - systemctl stop $SERVICE_NAME - - # Make sure the option is actually connecting - run_podman 125 --host $URL run --rm $IMAGE true - assert "$output" =~ "Cannot connect to Podman.*connection refused" -} # vim: filetype=sh diff --git a/test/system/251-system-service.bats b/test/system/251-system-service.bats new file mode 100644 index 000000000..edee4a28c --- /dev/null +++ b/test/system/251-system-service.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats -*- bats -*- +# +# Tests that require 'podman system service' but no other systemd aspects + +load helpers +load helpers.systemd + +SERVICE_NAME="podman-service-$(random_string)" + +function teardown() { + # Ignore exit status: this is just a backup stop in case tests failed + run systemctl stop "$SERVICE_NAME" + + basic_teardown +} + + +@test "podman-system-service containers survive service stop" { + skip_if_remote "podman system service unavailable over remote" + + port=$(random_free_port) + URL=tcp://127.0.0.1:$port + + systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 + wait_for_port 127.0.0.1 $port + + # Start a long-running container. + cname=keeps-running + run_podman --url $URL run -d --name $cname $IMAGE top -d 2 + + run_podman container inspect -l --format "{{.State.Running}}" + is "$output" "true" "This should never fail" + + systemctl stop $SERVICE_NAME + + run_podman container inspect $cname --format "{{.State.Running}}" + is "$output" "true" "Container is still running after podman server stops" + + run_podman rm -f -t 0 $cname +} + +# This doesn't actually test podman system service, but we require it, +# so least-awful choice is to run from this test file. +@test "podman --host / -H options" { + port=$(random_free_port) + URL=tcp://127.0.0.1:$port + + # %%-remote makes this run real podman even when testing podman-remote + systemd-run --unit=$SERVICE_NAME ${PODMAN%%-remote*} system service $URL --time=0 + wait_for_port 127.0.0.1 $port + + for opt in --host -H; do + run_podman $opt $URL info --format '{{.Host.RemoteSocket.Path}}' + is "$output" "$URL" "RemoteSocket.Path using $opt" + done + + systemctl stop $SERVICE_NAME +} |