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

Adjust ContainerStats for Podmod 4.6.0 responses #278

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions api/container_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func (c *API) ContainerStats(ctx context.Context, name string) (Stats, error) {
return stats, ContainerNotFound
}

// Since podman 4.6.0, a 200 response with `container is stopped` is returned for stopped containers.
var errResponse Error
if _ = json.Unmarshal(body, &errResponse); errResponse.Cause == "container is stopped" {
return stats, ContainerNotFound
}

err = json.Unmarshal(body, &stats)
if err != nil {
return stats, err
Expand Down
6 changes: 6 additions & 0 deletions api/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1543,3 +1543,9 @@ type Version struct {
Built int64
OsArch string
}

type Error struct {
Cause string `json:"cause"`
Message string `json:"message"`
Response int `json:"response"`
}