-
Notifications
You must be signed in to change notification settings - Fork 459
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
sort the list result for ps,sandboxes,images #171
Conversation
test case
|
cmd/crictl/container.go
Outdated
@@ -524,6 +536,7 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error { | |||
if err != nil { | |||
return err | |||
} | |||
sort.Sort(containerByName(r.Containers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems docker ps sorts output via createdAt , could you also sort the output this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course. done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not studied the docker source code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should be containerByCreated
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -30,6 +31,20 @@ import ( | |||
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" | |||
) | |||
|
|||
type sandboxBySort []*pb.PodSandbox | |||
|
|||
func (a sandboxBySort) Len() int { return len(a) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also sort sandbox by created time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to compare CreatAt first?
Is it more usable that putting all in one place that belong to one user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only compare CreatAt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. I think you are right.
cmd/crictl/image.go
Outdated
@@ -35,6 +36,20 @@ const ( | |||
truncatedImageIDLen = 13 | |||
) | |||
|
|||
type imageBySort []*pb.Image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have created time for image. :( I think it's fine to sort by tag/digest for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why compare digest first? I think we care more about tag, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ithink digest is immutable. repotag can be modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
cmd/crictl/container.go
Outdated
@@ -524,6 +536,7 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error { | |||
if err != nil { | |||
return err | |||
} | |||
sort.Sort(containerByName(r.Containers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should be containerByCreated
now.
cmd/crictl/image.go
Outdated
@@ -105,6 +120,7 @@ var listImageCommand = cli.Command{ | |||
if err != nil { | |||
return fmt.Errorf("listing images failed: %v", err) | |||
} | |||
sort.Sort(imageBySort(r.Images)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageByRef
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -30,6 +31,20 @@ import ( | |||
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" | |||
) | |||
|
|||
type sandboxBySort []*pb.PodSandbox | |||
|
|||
func (a sandboxBySort) Len() int { return len(a) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. I think you are right.
fix kubernetes-sigs#168 Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
/lgtm |
fix #168
Signed-off-by: yanxuean yan.xuean@zte.com.cn