Skip to content

Commit

Permalink
Merge pull request kubernetes#82010 from verb/range-kubectl
Browse files Browse the repository at this point in the history
Update kubectl polymorphic logs helper for ephemeral containers
  • Loading branch information
k8s-ci-robot committed Aug 29, 2019
2 parents cd9519f + 66d0778 commit bdea3c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ func logsForObjectWithClient(clientset corev1client.CoreV1Interface, object, opt
}
ret = append(ret, currRet...)
}
for _, c := range t.Spec.EphemeralContainers {
currOpts := opts.DeepCopy()
currOpts.Container = c.Name
currRet, err := logsForObjectWithClient(clientset, t, currOpts, timeout, false)
if err != nil {
return nil, err
}
ret = append(ret, currRet...)
}

return ret, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func TestLogsForObject(t *testing.T) {
{Name: "c1"},
{Name: "c2"},
},
EphemeralContainers: []corev1.EphemeralContainer{
{
EphemeralContainerCommon: corev1.EphemeralContainerCommon{Name: "e1"},
},
},
},
},
opts: &corev1.PodLogOptions{},
Expand All @@ -80,6 +85,7 @@ func TestLogsForObject(t *testing.T) {
getLogsAction("test", &corev1.PodLogOptions{Container: "initc2"}),
getLogsAction("test", &corev1.PodLogOptions{Container: "c1"}),
getLogsAction("test", &corev1.PodLogOptions{Container: "c2"}),
getLogsAction("test", &corev1.PodLogOptions{Container: "e1"}),
},
},
{
Expand Down Expand Up @@ -215,18 +221,22 @@ func TestLogsForObject(t *testing.T) {
continue
}

for i := range test.actions {
var i int
for i = range test.actions {
if len(fakeClientset.Actions()) < i {
t.Errorf("%s: action %d does not exists in actual actions: %#v",
t.Errorf("%s: expected action %d does not exists in actual actions: %#v",
test.name, i, fakeClientset.Actions())
continue
}
got := fakeClientset.Actions()[i]
want := test.actions[i]
if !reflect.DeepEqual(got, want) {
t.Errorf("%s: unexpected action: %s", test.name, diff.ObjectDiff(got, want))
t.Errorf("%s: unexpected diff for action: %s", test.name, diff.ObjectDiff(got, want))
}
}
for i++; i < len(fakeClientset.Actions()); i++ {
t.Errorf("%s: actual action %d does not exist in expected: %v", test.name, i, fakeClientset.Actions()[i])
}
}
}

Expand Down

0 comments on commit bdea3c0

Please sign in to comment.