fix(quadlet): correct replace behavior and prevent duplicates in .app files#27980
fix(quadlet): correct replace behavior and prevent duplicates in .app files#27980amyssnippet wants to merge 1 commit intocontainers:mainfrom
Conversation
|
AFTER amol@Amols-MacBook-Air podman %git status
On branch fix/27977
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pkg/domain/infra/abi/quadlet.go
Untracked files:
(use "git add <file>..." to include in what will be committed)
my_quadlet_dir/
test.container
no changes added to commit (use "git add" and/or "git commit -a")
amol@Amols-MacBook-Air podman %make bin/podman
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
\
-ldflags '-X github.com/containers/podman/v6/libpod/define.gitCommit=b60d234da4266d7ce08b950a68dc2c37844b018c-dirty -X github.com/containers/podman/v6/libpod/define.buildInfo=1769650004 -X github.com/containers/podman/v6/libpod/config._installPrefix=/usr/local -X github.com/containers/podman/v6/libpod/config._etcDir=/etc -X github.com/containers/podman/v6/pkg/systemd/quadlet._binDir=/usr/local/bin -X go.podman.io/image/v5/signature/internal/sequoia.sequoiaLibraryDir='""' -X go.podman.io/common/pkg/config.additionalHelperBinariesDir= ' \
-tags "grpcnotrace libsqlite3 systemd seccomp " \
-o bin/podman ./cmd/podman
test -z "" || chcon -t container_runtime_exec_t bin/podman
amol@Amols-MacBook-Air podman %./bin/podman --version
podman version 6.0.0-dev
amol@Amols-MacBook-Air podman %rm ~/.config/containers/systemd/myservice.container
amol@Amols-MacBook-Air podman %rm ~/.config/containers/systemd/.my_quadlet_dir.app
amol@Amols-MacBook-Air podman %./bin/podman quadlet install my_quadlet_dir
/home/amol/.config/containers/systemd/myservice.container
amol@Amols-MacBook-Air podman %./bin/podman quadlet install --replace my_quadlet_dir
/home/amol/.config/containers/systemd/myservice.container
amol@Amols-MacBook-Air podman %cat ~/.config/containers/systemd/.my_quadlet_dir.app
myservice.container
amol@Amols-MacBook-Air podman %
amol@Amols-MacBook-Air podman %
amol@Amols-MacBook-Air podman % |
|
i guess this solves pr solves the issue completely. if any comments then let me know. Thanks! |
|
Thanks for your contribution. It would be great to add tests for these two cases. For the first one, you could extend https://github.com/containers/podman/blob/main/test/system/253-podman-quadlet.bats#L467. I think the only change needed there to reproduce the issue is ensuring the first For the second issue, maybe you can use the very same test with --replace and simply check the .app file? You can run the tests using |
a8a85ea to
9209f87
Compare
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
0dafcde to
b17664b
Compare
|
@jankaluza i guess you changes are made, so have a look. and i am stuck at the ci checks failures, i am not sure why its happening. i am very doubtful to this failures |
8c974c0 to
b98984e
Compare
|
@jankaluza everything good now?? |
|
hi @jankaluza , i have reviewed both the ci failures very carefully and thats flaky not related to my quadlet changes. i am telling the reasons here
my observation tells these are flaky, whats your opinion, and my working style also suggests to report these flaky tests as issue in the repo and solve them in a new pr so that code doesnt broke. what should i do, guide me, Thanks! |
|
i did all the changes you recommended still there are failing checks |
|
I think this looks fine. There is still a possibility for a small race in @containers/podman-maintainers , what do you think? I think we did lot of work on this PR and its ready for a review from maintainer now :-). |
mheon
left a comment
There was a problem hiding this comment.
LGTM. Test looks good, thank you.
Restarted the flake.
Luap99
left a comment
There was a problem hiding this comment.
@amyssnippet Can you please squash the commits into logical chunks (one commit should be fine), there should be no fixup commits or anything as part of the PR as we merge commits as is and like this it makes no sense right now to look at commits one by one.
(Note I did not do an actual review of the changes)
0b73808 to
9e867f8
Compare
|
@Luap99 i squashed all commits into a single commit, the failure is a consistent version mismatch issue. The golangci-lint v2.6.0 was built with Go 1.25, but some files in the codebase require Go 1.26 features, causing the panic. |
5eac1bf to
ec3edeb
Compare
|
@Luap99 and @jankaluza any updates?? |
|
@amyssnippet , the test fails with AWS issue. I think the solution to that is to rebase the PR against the latest |
Yeah sure |
5b5ef0d to
fb8ee14
Compare
|
Honny1
left a comment
There was a problem hiding this comment.
Overall, the code looks good, but I have one suspicion.
I am not sure about adding comments for every single change. This is just my personal opinion, as I prefer a clean code approach, though the information about TOCTOU is great.
Regarding the CI: please rebase on main and drop the commit that edits the Makefile.
…race condition and better permission handling Signed-off-by: Amol Yadav <amyssnipet@yahoo.com>
|
@Honny1 now?? |
Honny1
left a comment
There was a problem hiding this comment.
LGTM, once CI passes.
The CI is failing:
time="2026-03-01T09:07:58-06:00" level=info msg="using commit range: 559dce7bf836cf78458cff3aa1410517b4003825..HEAD"
* 0e5daa47e5 "fixed: quadlet.go with simple check for duplicates and a func to fix race condition and better permission handling" ... FAIL
- FAIL - commit subject exceeds 90 characters
1 commits to fix

Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
git commit -s). (If needed, usegit commit -s --amend). The author email must match the sign-off email address. See CONTRIBUTING.md for more information.Fixes: #27960in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Description
This PR fixes two issues with
podman quadlet install:podman quadlet installwould blindly append entries to the hidden.apptracking files. Repeated installations (especially with--replace) caused the same container file to be listed multiple times in the.appfile. I added a check to ensure idempotency.--replace, the destination file was opened withoutO_TRUNC. If the new quadlet file was shorter than the existing one, trailing data from the old file would persist (e.g.,Restart=always+old_garbage). I added theos.O_TRUNCflag to ensure a clean overwrite.Does this PR introduce a user-facing change?
fixes: #27960