kubelet e2e: defer the close to after the error check

fixes a potential crash
This commit is contained in:
Ryan Phillips 2019-09-04 10:01:52 -05:00
parent 975d0736b3
commit 6b18285cd2

View File

@ -168,10 +168,10 @@ var _ = framework.KubeDescribe("Kubelet", func() {
gomega.Eventually(func() error { gomega.Eventually(func() error {
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream() rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream()
defer rc.Close()
if err != nil { if err != nil {
return err return err
} }
defer rc.Close()
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
buf.ReadFrom(rc) buf.ReadFrom(rc)
hostsFileContent := buf.String() hostsFileContent := buf.String()