Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor c/common pasta branch for testing #21563

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libpod/events/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type Event struct {
Type Type
// Health status of the current container
HealthStatus string `json:"health_status,omitempty"`
// Error code for certain events involving errors.
Error error `json:"error,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

This cannot work with the file logger as you cannot unmarshal into an error interface so it must be changed to a string. And in general I am really not a fan of merging such changes (in an unrelated PR) without any tests nor chance for actual review.
I know we just wanted pasta to get in but that could have just gone it normal way without causing all the extra troubles by simply not merging unverified/untested changes in c/common without thinking how they effect podman.

Also the whole thing is not plumbed in at all, you never set this option from the libimage type so the error is lost and also not plugged into podman the cli nor API which means it will not show any error messages, users only see pull-error $IMAGE right now.

I am aware that your goal was to just get test passing but I write this because this "feature" if far from done and needs tests.


Details
}
Expand Down Expand Up @@ -170,6 +172,8 @@ const (
Prune Status = "prune"
// Pull ...
Pull Status = "pull"
// PullError is an error pulling an image
PullError Status = "pull-error"
// Push ...
Push Status = "push"
// Refresh indicates that the system refreshed the state after a
Expand Down
2 changes: 2 additions & 0 deletions libpod/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ func StringToStatus(name string) (Status, error) {
return Prune, nil
case Pull.String():
return Pull, nil
case PullError.String():
return PullError, nil
case Push.String():
return Push, nil
case Refresh.String():
Expand Down
6 changes: 6 additions & 0 deletions libpod/events/journal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func (e EventJournalD) Write(ee Event) error {
case Image:
m["PODMAN_NAME"] = ee.Name
m["PODMAN_ID"] = ee.ID
if ee.Error != nil {
m["ERROR"] = ee.Error.Error()
}
case Container, Pod:
m["PODMAN_IMAGE"] = ee.Image
m["PODMAN_NAME"] = ee.Name
Expand Down Expand Up @@ -228,6 +231,9 @@ func newEventFromJournalEntry(entry *sdjournal.JournalEntry) (*Event, error) {
newEvent.Network = entry.Fields["PODMAN_NETWORK_NAME"]
case Image:
newEvent.ID = entry.Fields["PODMAN_ID"]
if _, ok := entry.Fields["ERROR"]; ok {
newEvent.Error = errors.New(entry.Fields["ERROR"])
}
}
return &newEvent, nil
}
Expand Down
19 changes: 10 additions & 9 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,16 @@ func (r *Runtime) GetConfig() (*config.Config, error) {

// libimageEventsMap translates a libimage event type to a libpod event status.
var libimageEventsMap = map[libimage.EventType]events.Status{
libimage.EventTypeImagePull: events.Pull,
libimage.EventTypeImagePush: events.Push,
libimage.EventTypeImageRemove: events.Remove,
libimage.EventTypeImageLoad: events.LoadFromArchive,
libimage.EventTypeImageSave: events.Save,
libimage.EventTypeImageTag: events.Tag,
libimage.EventTypeImageUntag: events.Untag,
libimage.EventTypeImageMount: events.Mount,
libimage.EventTypeImageUnmount: events.Unmount,
libimage.EventTypeImagePull: events.Pull,
libimage.EventTypeImagePullError: events.PullError,
libimage.EventTypeImagePush: events.Push,
libimage.EventTypeImageRemove: events.Remove,
libimage.EventTypeImageLoad: events.LoadFromArchive,
libimage.EventTypeImageSave: events.Save,
libimage.EventTypeImageTag: events.Tag,
libimage.EventTypeImageUntag: events.Untag,
libimage.EventTypeImageMount: events.Mount,
libimage.EventTypeImageUnmount: events.Unmount,
}

// libimageEvents spawns a goroutine which will listen for events on
Expand Down
Loading