Fix mcp ps uptime: parse StartedAt from podman ps JSON
List() was not extracting the StartedAt field from podman's JSON output, so LiveCheck always returned zero timestamps and the CLI showed "-" for every container's uptime. podman ps --format json includes StartedAt as a Unix timestamp (int64). Parse it into ContainerInfo.Started so the existing LiveCheck → CLI uptime display chain works. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -215,10 +215,11 @@ func (p *Podman) ImageExists(ctx context.Context, image string) (bool, error) {
|
|||||||
|
|
||||||
// podmanPSEntry is a single entry from podman ps --format json.
|
// podmanPSEntry is a single entry from podman ps --format json.
|
||||||
type podmanPSEntry struct {
|
type podmanPSEntry struct {
|
||||||
Names []string `json:"Names"`
|
Names []string `json:"Names"`
|
||||||
Image string `json:"Image"`
|
Image string `json:"Image"`
|
||||||
State string `json:"State"`
|
State string `json:"State"`
|
||||||
Command []string `json:"Command"`
|
Command []string `json:"Command"`
|
||||||
|
StartedAt int64 `json:"StartedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns information about all containers.
|
// List returns information about all containers.
|
||||||
@@ -240,12 +241,16 @@ func (p *Podman) List(ctx context.Context) ([]ContainerInfo, error) {
|
|||||||
if len(e.Names) > 0 {
|
if len(e.Names) > 0 {
|
||||||
name = e.Names[0]
|
name = e.Names[0]
|
||||||
}
|
}
|
||||||
infos = append(infos, ContainerInfo{
|
info := ContainerInfo{
|
||||||
Name: name,
|
Name: name,
|
||||||
Image: e.Image,
|
Image: e.Image,
|
||||||
State: e.State,
|
State: e.State,
|
||||||
Version: ExtractVersion(e.Image),
|
Version: ExtractVersion(e.Image),
|
||||||
})
|
}
|
||||||
|
if e.StartedAt > 0 {
|
||||||
|
info.Started = time.Unix(e.StartedAt, 0)
|
||||||
|
}
|
||||||
|
infos = append(infos, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
return infos, nil
|
return infos, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user