Skip to content

fix: recurse checkIsEmptyDir with correct path and nested emptiness detection#2102

Open
carterpewpew wants to merge 1 commit intokubernetes:mainfrom
carterpewpew:fix/checkisemptydir-uses
Open

fix: recurse checkIsEmptyDir with correct path and nested emptiness detection#2102
carterpewpew wants to merge 1 commit intokubernetes:mainfrom
carterpewpew:fix/checkisemptydir-uses

Conversation

@carterpewpew
Copy link
Copy Markdown

@carterpewpew carterpewpew commented Apr 27, 2026

What type of PR is this?

/kind bug

What this PR does / why we need it:

checkIsEmptyDir (used by isConfigFile) had two recursion bugs:

  1. It recursed with child name instead of filepath.Join(parent, child), and
  2. It ignored nested recursion boolean results.

This change fixes both, so nested non-empty directories are correctly classified as non-empty and are not skipped due to bad recursion paths. Tests added for nested directory root classification in isConfigFile, fixture-based nested directory checks, and hermetic tempdir nested empty/non-empty cases.

Which issue(s) this PR fixes:

Special notes for your reviewer:

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 27, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @carterpewpew!

It looks like this is your first PR to kubernetes/kompose 🎉. 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/kompose 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. 😃

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: carterpewpew
Once this PR has been reviewed and has the lgtm label, please assign cdrage for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot requested review from TessaIO and cdrage April 27, 2026 04:23
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 27, 2026
When traversing subdirectories, join the parent path with the child name so checks run against the real tree instead of the process CWD. Propagate non-empty nested directories so directories with only nested files are not treated as empty.

This affects isConfigFile for directory bind mounts and configMap handling.

Tests: add fixture case for deep nested file, plus hermetic tempdir cases.

Signed-off-by: Jathavedhan M <jathavedhan.m@ibm.com>
@carterpewpew carterpewpew force-pushed the fix/checkisemptydir-uses branch from 5e74482 to e6eb58a Compare April 29, 2026 07:35
@carterpewpew carterpewpew changed the title fix: recurse checkIsEmptyDir with correct path and nested result fix: recurse checkIsEmptyDir with correct path and nested emptiness detection Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants