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

Improve crictl inspect[pi] commands to allow filtering #1553

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

saschagrunert
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

The commands now allow filtering based on various fields or just to inspect all pods, containers or images.

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

Added filtering flags for `crictl` `inspect`, `inspectp` and `inspecti`. If no filter is provided, then the commands will now inspect all containers, pods or images.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 6, 2024
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 6, 2024
@saschagrunert saschagrunert force-pushed the inspect-filter branch 2 times, most recently from b0d297a to 87dd0c4 Compare August 6, 2024 10:35
@saschagrunert
Copy link
Member Author

@kubernetes-sigs/cri-tools-maintainers PTAL

@saschagrunert saschagrunert force-pushed the inspect-filter branch 2 times, most recently from ffe0cc4 to a2d56b8 Compare August 6, 2024 14:45
return fmt.Errorf("listing images: %w", err)
}
for _, img := range r.GetImages() {
ids = append(ids, img.GetId())
Copy link
Member

Choose a reason for hiding this comment

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

do we need to deduplicate here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd say no, because right now it behaves in the same way to output two images when doing something like:

sudo crictl inspecti 324bc02ae1231 324bc02ae1231

@@ -322,7 +374,7 @@ var listPodCommand = &cli.Command{
if err != nil {
return err
}
if err = ListPodSandboxes(runtimeClient, opts); err != nil {
if err = OutputPodSandboxes(runtimeClient, opts); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

if filtered by reference, what image reference will the output use as a main one? My understanding is that even with the filter, the output may show different reference as a "main" name of an image and tag one filtered by in a list of alternative names. Is it right? I wonder this is actually the case and whether we can either improve output or make it clear in docs so not to confuse users

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, pods are not filterable by reference, are we speaking about crictl inspecti? My main goal was to mimic closely as possible the existing crictl pods, ps and images subcommand flags to avoid confusion.

@@ -322,7 +374,7 @@ var listPodCommand = &cli.Command{
if err != nil {
return err
}
if err = ListPodSandboxes(runtimeClient, opts); err != nil {
if err = OutputPodSandboxes(runtimeClient, opts); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

in case of various filters, potential improvement over time may be to show filter-specific additional column. For since it may be time passed since that value in the filter, for example. This is just a nit.

The commands now allow filtering based on various fields or just to
inspect all pods, containers or image.

Signed-off-by: Sascha Grunert <[email protected]>
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: saschagrunert, SergeyKanzhelev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit d85c569 into kubernetes-sigs:master Aug 7, 2024
29 checks passed
@saschagrunert saschagrunert deleted the inspect-filter branch August 7, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants