Skip to content

test/system: Remove stale cache directory left between pull attempts - #1828

Merged
debarshiray merged 1 commit into
containers:mainfrom
debarshiray:wip/rishi/test-system-libs-helpers-pull-cache-remove-stale-cache
Jul 29, 2026
Merged

test/system: Remove stale cache directory left between pull attempts#1828
debarshiray merged 1 commit into
containers:mainfrom
debarshiray:wip/rishi/test-system-libs-helpers-pull-cache-remove-stale-cache

Conversation

@debarshiray

@debarshiray debarshiray commented Jul 29, 2026

Copy link
Copy Markdown
Member

When setting up caching for images, if an iteration of the retry loop to download images to the cache fails, it leaves behind a stale cache which will cause the next attempt to also fail with:

  not ok 1 setup_suite
  # (from function `_pull_and_cache_distro_image' in file
       test/system/libs/helpers.bash, line 139,
  #  from function `setup_suite' in test file
       test/system/setup_suite.bash, line 59)
  #   `_pull_and_cache_distro_image ubuntu 20.04' failed
  # Failed to cache image quay.io/toolbx/ubuntu-toolbox:20.04 to
      /tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04
  # time="2026-07-28T22:40:16Z" level=fatal msg="initializing
      destination
      dir:/tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04:
      not a containers image directory, don't want to overwrite
      important data"

This is because skopeo(1) will refuse to write to the directory saying it's not a valid containers image directory. Specifically, this is the ErrNotContainerImageDir error from the go.podman.io/image/v5/directory package [1].

Add a clean-up step to remove the directory before the next attempt to avoid the issue.

Shell parameter expansion [2] is used to ensure that rm(1) doesn't recursively delete everything in the host operating system's root directory [3] due to future programmer errors.

[1] https://pkg.go.dev/go.podman.io/image/v5/directory

[2] https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

[3] https://www.shellcheck.net/wiki/SC2115

#1822

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jul 29, 2026
When setting up caching for images, if an iteration of the retry loop to
download images to the cache fails, it leaves behind a stale cache which
will cause the next attempt to also fail with:
  not ok 1 setup_suite
  # (from function `_pull_and_cache_distro_image' in file
       test/system/libs/helpers.bash, line 139,
  #  from function `setup_suite' in test file
       test/system/setup_suite.bash, line 59)
  #   `_pull_and_cache_distro_image ubuntu 20.04' failed
  # Failed to cache image quay.io/toolbx/ubuntu-toolbox:20.04 to
      /tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04
  # time="2026-07-28T22:40:16Z" level=fatal msg="initializing
      destination
      dir:/tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04:
      not a containers image directory, don't want to overwrite
      important data"

This is because skopeo(1) will refuse to write to the directory saying
it's not a valid containers image directory.  Specifically, this is the
ErrNotContainerImageDir error from the go.podman.io/image/v5/directory
package [1].

Add a cleanup step to remove the directory before the next attempt to
avoid the issue.

[1] https://pkg.go.dev/go.podman.io/image/v5/directory

containers#1822
containers#1828

Signed-off-by: Rolv Apneseth <rolv.apneseth@gmail.com>
@debarshiray
debarshiray force-pushed the wip/rishi/test-system-libs-helpers-pull-cache-remove-stale-cache branch from 8188923 to 074026c Compare July 29, 2026 14:36
When setting up caching for images, if an iteration of the retry loop to
download images to the cache fails, it leaves behind a stale cache which
will cause the next attempt to also fail with:
  not ok 1 setup_suite
  # (from function `_pull_and_cache_distro_image' in file
       test/system/libs/helpers.bash, line 139,
  #  from function `setup_suite' in test file
       test/system/setup_suite.bash, line 59)
  #   `_pull_and_cache_distro_image ubuntu 20.04' failed
  # Failed to cache image quay.io/toolbx/ubuntu-toolbox:20.04 to
      /tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04
  # time="2026-07-28T22:40:16Z" level=fatal msg="initializing
      destination
      dir:/tmp/bats-run-3FdzJ3/suite/image-cache/ubuntu-toolbox-20.04:
      not a containers image directory, don't want to overwrite
      important data"

This is because skopeo(1) will refuse to write to the directory saying
it's not a valid containers image directory.  Specifically, this is the
ErrNotContainerImageDir error from the go.podman.io/image/v5/directory
package [1].

Add a clean-up step to remove the directory before the next attempt to
avoid the issue.

Shell parameter expansion [2] is used to ensure that rm(1) doesn't
recursively delete everything in the host operating system's root
directory [3] due to future programmer errors.

[1] https://pkg.go.dev/go.podman.io/image/v5/directory

[2] https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

[3] https://www.shellcheck.net/wiki/SC2115

containers#1822
containers#1828

Signed-off-by: Rolv Apneseth <rolv.apneseth@gmail.com>
@debarshiray
debarshiray force-pushed the wip/rishi/test-system-libs-helpers-pull-cache-remove-stale-cache branch from 074026c to 6c315e3 Compare July 29, 2026 20:10
@debarshiray
debarshiray merged commit 6c315e3 into containers:main Jul 29, 2026
3 checks passed
@debarshiray
debarshiray deleted the wip/rishi/test-system-libs-helpers-pull-cache-remove-stale-cache branch July 29, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants