kubectl: fix sort logic for logs

Use a separate sorting algorithm for kubectl logs that sorts from older
to newer instead of the other way that ActivePods is doing.
This commit is contained in:
Michail Kargakis
2016-06-03 12:12:26 +02:00
parent fc11ca60db
commit 886014b1a3
3 changed files with 44 additions and 7 deletions

View File

@@ -476,12 +476,12 @@ func TestGetFirstPod(t *testing.T) {
{
name: "kubectl logs - two ready pods",
podList: newPodList(2, -1, -1, labelSet),
sortBy: func(pods []*api.Pod) sort.Interface { return controller.ActivePods(pods) },
sortBy: func(pods []*api.Pod) sort.Interface { return controller.ByLogging(pods) },
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "pod-2",
Name: "pod-1",
Namespace: api.NamespaceDefault,
CreationTimestamp: unversioned.Date(2016, time.April, 1, 1, 0, 1, 0, time.UTC),
CreationTimestamp: unversioned.Date(2016, time.April, 1, 1, 0, 0, 0, time.UTC),
Labels: map[string]string{"test": "selector"},
},
Status: api.PodStatus{
@@ -498,7 +498,7 @@ func TestGetFirstPod(t *testing.T) {
{
name: "kubectl logs - one unhealthy, one healthy",
podList: newPodList(2, -1, 1, labelSet),
sortBy: func(pods []*api.Pod) sort.Interface { return controller.ActivePods(pods) },
sortBy: func(pods []*api.Pod) sort.Interface { return controller.ByLogging(pods) },
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "pod-2",