Skip to content

stage_binaries.sh: skip package files that are not on disk - #1002

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
tiffanny29631:fixlink
Oct 23, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
tiffanny29631:fixlink

Conversation

@tiffanny29631

@tiffanny29631 tiffanny29631 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Minimal Debian base images (e.g. debian:trixie-slim) drop files via dpkg path-exclude rules in /etc/dpkg/dpkg.cfg.d/, but dpkg -L still lists them. stage_one_package() passes those paths to stage_one_file(), which falls through to cp -lpP and fails. Repro: running the Dockerfile.in staging command (/stage_binaries.sh -o /staging -p base-files ...) inside debian:trixie-slim fails with
cp: cannot stat '/usr/share/lintian/overrides/base-files': No such file or directory
This skips, with a DBG log, package-manifest files that don't exist. Explicit -f/-b paths still go straight to stage_one_file() and fail loudly if missing.
Tested by running the Dockerfile.in staging command on debian:trixie-slim and on another minimal Debian base (both previously failed, now pass), plus a bogus -f path (still fails). shellcheck clean.

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @tiffanny29631!

It looks like this is your first PR to kubernetes/git-sync 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/git-sync has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow
kubernetes-prow Bot requested review from sdowell and stp-ip September 17, 2026 23:55
@kubernetes-prow kubernetes-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 17, 2026
@tiffanny29631 tiffanny29631 changed the title stage_binaries.sh: skip nonexistent paths from minimal base images fix: skip nonexistent paths from minimal base images Sep 19, 2026
Comment thread stage_binaries.sh Outdated
for elem in "${elems[@]}"; do
path="${path}/${elem}"
if [[ ! -e "${staging}${path}" ]]; then
if [[ ! -e "${path}" && ! -L "${path}" ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: stage_one_package() already filters the manifest:

dpkg -L "${pkg}" | grep_allow_nomatch -vE '(/\.|/usr/share/(man|doc|.*-completion))'

Could the filter be updated to include the unnecessary files?


Otherwise:

  1. stage_one_file is also the path for user-requested -f files, so this makes -f /typo/path silently succeed instead of failing the build. Can we keep -f strict in stage_files()?
  2. Nits: return 0 rather than continue (deeper paths can't exist if the prefix doesn't exist), and a debug logging "skipping nonexistent path ..." so this isn't invisible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good points. I've reworked it:

Moved the check into stage_one_package() and reverted the stage_one_file() change, so explicit -f/-b paths still fail on a typo. I verified that -f /typo/path still fails the build.
It now skips the whole file (no per-element loop) and logs via DBG.

On extending the grep filter instead: what gets dropped depends on each image's dpkg path-exclude config. debian:trixie-slim drops /usr/share/lintian, /usr/share/locale, /usr/share/info, etc., and other minimal bases drop different sets, so the filter would need updating for each base. Checking for existence on the dpkg-manifest path handles all of them without touching the user-specified paths.

Minimal Debian base images (e.g. debian:trixie-slim) use dpkg
path-exclude rules (/etc/dpkg/dpkg.cfg.d/) to drop files such as
/usr/share/lintian/*, but `dpkg -L` still lists them.
stage_one_package() hands those paths to stage_one_file(), which falls
through to `cp -lpP` and fails the build:

    cp: cannot stat '/usr/share/lintian/overrides/base-files': No such file or directory

Skip (with a debug log) files from a package manifest that do not exist.
Explicitly requested files (-f) and binaries (-b) still go straight to
stage_one_file() and fail loudly if missing.

Signed-off-by: tiffanny29631 <peip@google.com>
@tiffanny29631 tiffanny29631 changed the title fix: skip nonexistent paths from minimal base images stage_binaries.sh: skip package files that are not on disk Oct 7, 2026
@thockin

thockin commented Oct 23, 2026

Copy link
Copy Markdown
Member

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 23, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thockin, tiffanny29631

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit c5f6bea into kubernetes:master Oct 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants