Skip to content

Support artifacts emitting events#28662

Open
nimdrak wants to merge 1 commit into
containers:mainfrom
nimdrak:support_artifacts_emitting_events
Open

Support artifacts emitting events#28662
nimdrak wants to merge 1 commit into
containers:mainfrom
nimdrak:support_artifacts_emitting_events

Conversation

@nimdrak
Copy link
Copy Markdown
Contributor

@nimdrak nimdrak commented May 7, 2026

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

fix #27260

Added support for `artifact` events to `podman events`. 
Users can now track artifact lifecycle events (`create`, `pull`, `push`, and `remove`) and filter them using the new `artifact=` and `type=artifact` filters. 
Shell auto-completion has also been updated to support these new filters.

@lsm5
Copy link
Copy Markdown
Member

lsm5 commented May 7, 2026

@nimdrak (not a review) rebase on main to get past Mac OS arm64 issue.

@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch 3 times, most recently from 37bb976 to e3766d1 Compare May 8, 2026 05:07
@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from e3766d1 to fab2171 Compare May 8, 2026 05:17
Comment thread libpod/runtime.go Outdated
@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from fab2171 to 44a5293 Compare May 8, 2026 13:52
@packit-as-a-service
Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@mheon mheon added the 6.0 Breaking changes for Podman 6.0 label May 8, 2026
@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from 47ec1f1 to a43532c Compare May 10, 2026 10:51
@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 10, 2026

I checked it works properly in Ubuntu 24.04.4 LTS.

Details
artifact events logging by journald
  • Terminal 1 (Event consumer)
nimdrak@myvm:~/githubs/podman$ ./bin/podman events --filter type=artifact --stream
2026-05-10 08:04:15.362478404 +0000 UTC artifact create sha256:e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318 localhost/my-dummy-artifact:latest
2026-05-10 08:04:18.616582095 +0000 UTC artifact remove sha256:e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318 localhost/my-dummy-artifact:latest
2026-05-10 08:07:39.75674049 +0000 UTC artifact create sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
2026-05-10 08:08:12.235213391 +0000 UTC artifact push sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
2026-05-10 08:08:20.327516781 +0000 UTC artifact remove sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
2026-05-10 08:08:24.074467941 +0000 UTC artifact pull sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
  • terminal 2 (Event producer)
nimdrak@myvm:~/githubs/podman$ echo "hello world" > dummy.txt
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact add localhost/my-dummy-artifact:latest dummy.txt
e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact rm localhost/my-dummy-artifact:latest
e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact add localhost:5000/my-remote-artifact:latest dummy.txt
709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact push --tls-verify=false localhost:5000/my-remote-artifact:latest
Getting image source signatures
Copying blob a948904f2f0f done   |
Copying config 44136fa355 done   |
Writing manifest to image destination
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact rm localhost:5000/my-remote-artifact:latest
709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e
nimdrak@myvm:~/githubs/podman$ ./bin/podman artifact pull --tls-verify=false localhost:5000/my-remote-artifact:latest
Getting image source signatures
Copying blob a948904f2f0f done   |
Copying config 44136fa355 done   |
Writing manifest to image destination
  • journald
nimdrak@myvm:~/githubs/podman$ journalctl SYSLOG_IDENTIFIER=podman PODMAN_TYPE=artifact --no-pager
May 10 08:04:15 myvm podman[51767]: 2026-05-10 08:04:15.362478404 +0000 UTC m=+0.044985116 artifact create sha256:e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318 localhost/my-dummy-artifact:latest
May 10 08:04:18 myvm podman[51795]: 2026-05-10 08:04:18.616582095 +0000 UTC m=+0.034201499 artifact remove sha256:e129f86fc719117f9e66010481eaa7a9cebe017908b0351d00a75f02e15d2318 localhost/my-dummy-artifact:latest
May 10 08:07:39 myvm podman[53081]: 2026-05-10 08:07:39.75674049 +0000 UTC m=+0.034744223 artifact create sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
May 10 08:08:12 myvm podman[53275]: 2026-05-10 08:08:12.235213391 +0000 UTC m=+0.376542417 artifact push sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
May 10 08:08:20 myvm podman[53340]: 2026-05-10 08:08:20.327516781 +0000 UTC m=+0.039227669 artifact remove sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
May 10 08:08:24 myvm podman[53368]: 2026-05-10 08:08:24.074467941 +0000 UTC m=+0.122835886 artifact pull sha256:709f9231102659253af7fdcce566a15669bce800671e502207403f180c85db9e localhost:5000/my-remote-artifact:latest
​
artifact events logging by file
  • Terminal 1 (Event consumer)
nimdrak@myvm:~/githubs/podman$ ./bin/podman events --events-backend=file --filter type=artifact --stream
2026-05-10 08:17:19.430368461 +0000 UTC artifact create sha256:9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa localhost/my-dummy-artifact:latest
2026-05-10 08:17:23.34843931 +0000 UTC artifact remove sha256:9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa localhost/my-dummy-artifact:latest
2026-05-10 08:17:39.251438949 +0000 UTC artifact create sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113 localhost:5000/my-remote-artifact:latest
2026-05-10 08:17:46.042360071 +0000 UTC artifact push sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113 localhost:5000/my-remote-artifact:latest
2026-05-10 08:17:52.300771186 +0000 UTC artifact remove sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113 localhost:5000/my-remote-artifact:latest
2026-05-10 08:17:56.420169787 +0000 UTC artifact pull sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113 localhost:5000/my-remote-artifact:latest

  • Terminal 2 (Event producer)
nimdrak@myvm:~/githubs/podman$./bin/podman --events-backend=file artifact add localhost/my-dummy-artifact:latest dummy.txt
9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa
nimdrak@myvm:~/githubs/podman$ ./bin/podman --events-backend=file artifact rm localhost/my-dummy-artifact:latest
9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa
nimdrak@myvm:~/githubs/podman$
./bin/podman --events-backend=file artifact add localhost:5000/my-remote-artifact:latest dummy.txt
7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113
nimdrak@myvm:~/githubs/podman$ ./bin/podman --events-backend=file artifact push --tls-verify=false localhost:5000/my-remote-artifact:latest
Getting image source signatures
Copying blob a948904f2f0f done   |
Copying config 44136fa355 done   |
Writing manifest to image destination
nimdrak@myvm:~/githubs/podman$ ./bin/podman --events-backend=file artifact rm localhost:5000/my-remote-artifact:latest
7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113
nimdrak@myvm:~/githubs/podman$ ./bin/podman --events-backend=file artifact pull --tls-verify=false localhost:5000/my-remote-artifact:latest
Getting image source signatures
Copying blob a948904f2f0f done   |
Copying config 44136fa355 done   |
Writing manifest to image destination

  • file
nimdrak@myvm:~/githubs/podman$ cat /run/user/$(id -u)/libpod/tmp/events/events.log
{"ID":"sha256:9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa","Name":"localhost/my-dummy-artifact:latest","Status":"create","Time":"2026-05-10T08:17:19.430368461Z","Type":"artifact","Attributes":null}
{"ID":"sha256:9756266a0faac1f4111fdde53437973a4f2a37d0028ef199ea40c7f6ce0aabfa","Name":"localhost/my-dummy-artifact:latest","Status":"remove","Time":"2026-05-10T08:17:23.34843931Z","Type":"artifact","Attributes":null}
{"ID":"sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113","Name":"localhost:5000/my-remote-artifact:latest","Status":"create","Time":"2026-05-10T08:17:39.251438949Z","Type":"artifact","Attributes":null}
{"ID":"sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113","Name":"localhost:5000/my-remote-artifact:latest","Status":"push","Time":"2026-05-10T08:17:46.042360071Z","Type":"artifact","Attributes":null}
{"ID":"sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113","Name":"localhost:5000/my-remote-artifact:latest","Status":"remove","Time":"2026-05-10T08:17:52.300771186Z","Type":"artifact","Attributes":null}
{"ID":"sha256:7781504b0470888a0543d513fcde7b86a53ae70ee58c42f34b9b8e35ddfa7113","Name":"localhost:5000/my-remote-artifact:latest","Status":"pull","Time":"2026-05-10T08:17:56.420169787Z","Type":"artifact","Attributes":null}
​

@nimdrak nimdrak marked this pull request as ready for review May 10, 2026 10:58
@nimdrak nimdrak changed the title [WIP] Support artifacts emitting events Support artifacts emitting events May 10, 2026
@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 11, 2026

I think the failed remote tests are unrelated to this PR.

@Luap99
Copy link
Copy Markdown
Member

Luap99 commented May 11, 2026

[+0985s] [FAIL] Podman events [It] podman events for artifacts
[+0985s] /var/tmp/go/src/github.com/containers/podman/test/e2e/events_test.go:342

This is your new test so they cannot be unrelated.

I think is the main problem via this "broken" multiple channel event architecture and why we need the interface...
The service writes events in the background depending on scheduling so even though the remote command exited the service is still running and may or may not have written the event.

@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from a43532c to 1c97af3 Compare May 12, 2026 00:25
@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 12, 2026

This is your new test so they cannot be unrelated.
I think is the main problem via this "broken" multiple channel event architecture and why we need the interface...
The service writes events in the background depending on scheduling so even though the remote command exited the service is still running and may or may not have written the event.

You're right, the timing issue between the service and the remote command was the culprit. I've applied Eventually to handle the async events. Thanks for pointing that out!

Regarding the 'broken' event architecture, I agree that a proper interface is the right way to go. I’d like to be part of that refactoring process. If you have a specific design in mind or an existing issue for it, please let me know.

Comment thread libpod/runtime.go Outdated

eventChannel := store.EventChannel()

go func() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like it could be refactored to be shared between this and libimageEvents

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.

Good point! How about this approach? fb462d9
I deduplicated the common logic by extracting it into a generic function in events.go.

@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from 50f427c to fb462d9 Compare May 13, 2026 05:19
@packit-as-a-service
Copy link
Copy Markdown

tmt tests failed for commit fb462d9. @lsm5, @psss, @thrix please check.

@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 13, 2026

The recent test failures were triggered by my changes. I believe this comes from a timing issue during the initialization between runtime.newEventer and configureStore (which initializes the libimage channel). It appears the original code also had this latent race condition.

To resolve this without a massive overhaul of the current architecture, I considered three options:
(1) Checking if the eventer is initialized before writing to it.
(2) Enforcing a strict initialization order for the eventer, libruntimeEvents, and libartifactEvents.
(3) Using lazy initialization (sync.Once) when accessing the eventer.
...

Rather than refactoring the entire channel architecture in this PR (as I understand a larger refactoring is planned soon), I opted for (1) as the simplest immediate fix. I have updated the code accordingly.

@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from fb462d9 to b03c100 Compare May 13, 2026 06:49
@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 13, 2026

testing-farm:fedora-44-x86_64:podman-fedora failed but it said

This can be an infrastructure problem, check status page for known outages.

@mheon
Copy link
Copy Markdown
Member

mheon commented May 13, 2026

We really need to get those marked as allowed-failure

@mheon
Copy link
Copy Markdown
Member

mheon commented May 13, 2026

LGTM

@Luap99
Copy link
Copy Markdown
Member

Luap99 commented May 13, 2026

please squash the commits, docs/test and so on should be part of the same commit, it also not great for reviews to have a refactor commit last when I already looked at the now again removed code by that refactor. Normally the refactor should be the first commit but I am fine if you also sqash down everything into one commit.

- libpod/events.go & libpod/runtime.go: Added the `Artifact` event type.
  Refactored and deduplicated event forwarding logic by introducing
  `spawnEventForwarder[T any]`, replacing separate goroutine loops for
  images and artifacts. Implemented graceful shutdown and resolved eventer
  initialization race conditions.
- libpod/events: Implemented event filtering by name/ID, updated journald
  and logfile readers/writers for artifact events, and added `Artifact` to
  `ToHumanReadable` formatting.
- cmd/podman: Added shell auto-completion for `artifact=` and `type=artifact` filters.
- docs/test: Documented the `artifact` event type, statuses, and filters in
  `podman-events.1.md`. Added an end-to-end test in `events_test.go` to verify
  event emissions.

Signed-off-by: Byounguk Lee <nimdrak@gmail.com>
@nimdrak nimdrak force-pushed the support_artifacts_emitting_events branch from b03c100 to a82cdef Compare May 13, 2026 23:38
@nimdrak
Copy link
Copy Markdown
Contributor Author

nimdrak commented May 13, 2026

Sorry for the confusion during the review. I agree that the refactor should have come first and that docs/tests belong in the same commit. I've squashed everything into a single commit now. I'll structure the commits more carefully next time. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.0 Breaking changes for Podman 6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Artifacts] Podman artifacts should support emitting events

4 participants