quadlet: prevent duplicate systemd units from subdirectories#28135
quadlet: prevent duplicate systemd units from subdirectories#28135Veector40 wants to merge 1 commit intocontainers:mainfrom
Conversation
When running `podman quadlet install`, the installer did not check for existing quadlets with the same name in subdirectories of the install path. This could lead to duplicate quadlet files and conflicting systemd units. This patch adds a WalkDir check to identify if a quadlet file already exists in any subdirectory of the target install directory. If it does: - Without `--replace`, it refuses to overwrite and throws an error. - With `--replace`, it cleans up the duplicate from the subdirectory before writing the new file to the expected install directory. Added a system BATS test to ensure quadlet installation correctly detects, fails, or replaces nested duplicates. Fixes: containers#28118 Signed-off-by: Victor Koycheff <victorkoycheff@gmail.com>
|
Note that this will conflict with #27980. Just something to be aware of. |
|
What if there are already two duplicates before you start the I'm also not completely persuaded that removing files with the same name from the more or less random subdirectories is a good idea. I'm afraid we could remove some file by a mistake. Maybe it could be better to simply detect this situation and say human intervention is needed? Anyway, let's wait what does other think. Do not change your code yet, let's wait for another review :-). |
|
The test failure in APIv2 needs to be fixed. |
|
Thank you for the clarification. I’ve updated the logic to correctly handle the directory paths, and I’ve verified that both the existing API tests and the new BATS cases are passing locally now. I don't want to jump the gun, so I’m going to hold off on pushing or touching anything else until I get your guidance on how to proceed. |
When running
podman quadlet install, the installer did not check for existing quadlets with the same name in subdirectories of the install path. This could lead to duplicate quadlet files and conflicting systemd units.This patch adds a WalkDir check to identify if a quadlet file already exists in any subdirectory of the target install directory. If it does:
--replace, it refuses to overwrite and throws an error.--replace, it cleans up the duplicate from the subdirectory before writing the new file to the expected install directory.Added a system BATS test to ensure quadlet installation correctly detects, fails, or replaces nested duplicates.
Fixes: #28118
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?