project-stacker / stacker

Build OCI images natively from a declarative format
https://stackerbuild.io
Apache License 2.0
208 stars 34 forks source link

fix: Wrap use of skopeo to avoid its unwanted side effects. #570

Closed smoser closed 11 months ago

smoser commented 11 months ago

2 things are fixed here.

  1. Running skopeo as root creates /run/containers with 700 permissions. That causes a problem when you run skopeo as root and then run stacker as non-root.

    The error would look like this:

    error: initializing source ... getting username and password: 1 error occurred:

    • reading JSON file "/run/containers/0/auth.json": open /run/containers/0/auth.json: permission denied couldn't import base layer base stackerbuild.io/stacker/pkg/stacker.importContainersImage /stacker-tree/pkg/stacker/base.go:141 stackerbuild.io/stacker/pkg/stacker.GetBase /stacker-tree/pkg/stacker/base.go:49 stackerbuild.io/stacker/pkg/stacker.(Builder).build /stacker-tree/pkg/stacker/build.go:407 stackerbuild.io/stacker/pkg/stacker.(Builder).BuildMultiple /stacker-tree/pkg/stacker/build.go:622 main.doBuild
  2. skopeo copy containers-registry populates ~/.local/share/containers/ This is an unwanted side effect of running the test. Further annoying is that it ends up getting directories with 555 perms on them. That means rm -Rf .local/share/containers/storage/vfs-layers will fail like:

    rm: cannot remove '.local/share/containers/storage/vfs/dir/HASH': Permission denied

    We don't want someone's HOME getting populated with artifacts from stacker test, and there are probably also race conditions here in that we run stacker tests in parallel.

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

codecov[bot] commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a576aa3) 56.36% compared to head (caf4f8c) 57.12%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #570 +/- ## ========================================== + Coverage 56.36% 57.12% +0.75% ========================================== Files 64 64 Lines 7505 7505 ========================================== + Hits 4230 4287 +57 + Misses 2553 2477 -76 - Partials 722 741 +19 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.