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

Kubernetes-commit: bdea3c0
  • Loading branch information
k8s-publishing-bot committed Aug 29, 2019
2 parents 1712169 + c5bce98 commit 7a7de59
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ require (
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
gopkg.in/yaml.v2 v2.2.2
gotest.tools v2.2.0+incompatible // indirect
k8s.io/api v0.0.0-20190829034738-40d3837b7e3d
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
k8s.io/cli-runtime v0.0.0-20190828120509-9a5048624be8
k8s.io/client-go v0.0.0-20190828235140-8248d0a0e61a
k8s.io/component-base v0.0.0-20190829035035-ac1d987bcbab
k8s.io/api v0.0.0-20190829194742-eb06f43765d3
k8s.io/apimachinery v0.0.0-20190829154700-508c689428e4
k8s.io/cli-runtime v0.0.0-20190829195939-729e37b0deac
k8s.io/client-go v0.0.0-20190829155211-065c7aba1f3f
k8s.io/component-base v0.0.0-20190829160041-be152a771707
k8s.io/klog v0.4.0
k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058
k8s.io/metrics v0.0.0-20190828120413-207193cd263a
Expand All @@ -56,11 +56,11 @@ replace (
golang.org/x/sys => golang.org/x/sys v0.0.0-20190209173611-3b5209105503
golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
golang.org/x/time => golang.org/x/time v0.0.0-20161028155119-f51c12702a4d
k8s.io/api => k8s.io/api v0.0.0-20190829034738-40d3837b7e3d
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190828120509-9a5048624be8
k8s.io/client-go => k8s.io/client-go v0.0.0-20190828235140-8248d0a0e61a
k8s.io/api => k8s.io/api v0.0.0-20190829194742-eb06f43765d3
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190829154700-508c689428e4
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190829195939-729e37b0deac
k8s.io/client-go => k8s.io/client-go v0.0.0-20190829155211-065c7aba1f3f
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190828114452-79369ab2ae19
k8s.io/component-base => k8s.io/component-base v0.0.0-20190829035035-ac1d987bcbab
k8s.io/component-base => k8s.io/component-base v0.0.0-20190829160041-be152a771707
k8s.io/metrics => k8s.io/metrics v0.0.0-20190828120413-207193cd263a
)
10 changes: 5 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20190829034738-40d3837b7e3d/go.mod h1:Ik8tfB+q7IZDY6j3l3XfCxTl8s2knJz66H5FNYIj4oI=
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e/go.mod h1:OOC7vMsHyCzra5xu6r1bRXkXMH76iww9BeHOAAJof4U=
k8s.io/cli-runtime v0.0.0-20190828120509-9a5048624be8/go.mod h1:MHPTyiuwsje/STRmczOtmp/++9c9zUm/UZj3jBQuMMA=
k8s.io/client-go v0.0.0-20190828235140-8248d0a0e61a/go.mod h1:P6tyglhf3epZgAuvfPuTrCjtREWjhdpB0DOmwEbwv/A=
k8s.io/api v0.0.0-20190829194742-eb06f43765d3/go.mod h1:87temCTGeJAq22HWTJDnKM9cT6PpMADm5DqxEe3uRnk=
k8s.io/apimachinery v0.0.0-20190829154700-508c689428e4/go.mod h1:OOC7vMsHyCzra5xu6r1bRXkXMH76iww9BeHOAAJof4U=
k8s.io/cli-runtime v0.0.0-20190829195939-729e37b0deac/go.mod h1:/prHxT5vPcOwlCFxzAfH10i40j1ta2rMlDQOmKWzOTk=
k8s.io/client-go v0.0.0-20190829155211-065c7aba1f3f/go.mod h1:OTl/HIPWX8UHQQEslKfnYiXsTUfdVT1omr+YXmbJCI0=
k8s.io/code-generator v0.0.0-20190828114452-79369ab2ae19/go.mod h1:DcZnH9wu/rlc2W9W82F8WPyJRR2mJVZGNE1cA/Qn6zQ=
k8s.io/component-base v0.0.0-20190829035035-ac1d987bcbab/go.mod h1:/+hHhZ8jfT5kDPmcYuJs9yWNDf2zLeNH6h0NPXP3y5M=
k8s.io/component-base v0.0.0-20190829160041-be152a771707/go.mod h1:bAfLerY9PEE9mAANE1bydHRWmLL0Ql9gB3HG/39Vws4=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
Expand Down
9 changes: 9 additions & 0 deletions pkg/polymorphichelpers/logsforobject.go
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
16 changes: 13 additions & 3 deletions pkg/polymorphichelpers/logsforobject_test.go
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 7a7de59

Please sign in to comment.