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

ps: get network data in batch mode #17197

Merged
merged 1 commit into from
Jan 24, 2023
Merged
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
23 changes: 13 additions & 10 deletions pkg/ps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"time"

libnetworkTypes "github.com/containers/common/libnetwork/types"
"github.com/containers/podman/v4/libpod"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/domain/entities"
Expand Down Expand Up @@ -134,6 +135,8 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
startedTime time.Time
exitedTime time.Time
cgroup, ipc, mnt, net, pidns, user, uts string
portMappings []libnetworkTypes.PortMapping
networks []string
)

batchErr := ctr.Batch(func(c *libpod.Container) error {
Expand Down Expand Up @@ -167,6 +170,16 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
return fmt.Errorf("unable to obtain container pid: %w", err)
}

portMappings, err = c.PortMappings()
if err != nil {
return err
}

networks, err = c.Networks()
if err != nil {
return err
}

if !opts.Size && !opts.Namespace {
return nil
}
Expand Down Expand Up @@ -203,16 +216,6 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
return entities.ListContainer{}, batchErr
}

portMappings, err := ctr.PortMappings()
if err != nil {
return entities.ListContainer{}, err
}

networks, err := ctr.Networks()
if err != nil {
return entities.ListContainer{}, err
}

ps := entities.ListContainer{
AutoRemove: ctr.AutoRemove(),
Command: conConfig.Command,
Expand Down