diff --git a/test/e2e/cmd/init/converter.go b/test/e2e/cmd/init/converter.go index 028f7177f66..80c00c7e92a 100644 --- a/test/e2e/cmd/init/converter.go +++ b/test/e2e/cmd/init/converter.go @@ -153,18 +153,16 @@ func (c *ClusterConverter) deployYurthub() error { } // print logs of yurt-manager - labelSelector, logErr := metav1.ParseToLabelSelector("app.kubernetes.io/name=yurt-manager") - if logErr != nil { - return err - } podList, logErr := c.ClientSet.CoreV1().Pods("kube-system").List(context.TODO(), metav1.ListOptions{ - LabelSelector: labelSelector.String(), + LabelSelector: labels.SelectorFromSet(map[string]string{"app.kubernetes.io/name": "yurt-manager"}).String(), }) if logErr != nil { + klog.Errorf("failed to get yurt-manager pod, %v", logErr) return err } if len(podList.Items) == 0 { + klog.Errorf("yurt-manager pod doesn't exist") return err } if logErr = kubeutil.PrintPodLog(c.ClientSet, &podList.Items[0], os.Stderr); logErr != nil { diff --git a/test/e2e/cmd/init/util/kubernetes/util.go b/test/e2e/cmd/init/util/kubernetes/util.go index c2b638957fc..2c158c2b110 100644 --- a/test/e2e/cmd/init/util/kubernetes/util.go +++ b/test/e2e/cmd/init/util/kubernetes/util.go @@ -256,7 +256,12 @@ func RunJobAndCleanup(cliSet kubeclientset.Interface, job *batchv1.Job, timeout, func PrintPodLog(client kubeclientset.Interface, pod *corev1.Pod, w io.Writer) error { klog.Infof("start to print logs for pod(%s/%s):", pod.Namespace, pod.Name) req := client.CoreV1().Pods(pod.GetNamespace()).GetLogs(pod.Name, &corev1.PodLogOptions{}) - return kubectllogs.DefaultConsumeRequest(req, w) + if err := kubectllogs.DefaultConsumeRequest(req, w); err != nil { + klog.Errorf("failed to print logs for pod(%s/%s), %v", pod.Namespace, pod.Name, err) + return err + } + + return nil } // RunServantJobs launch servant jobs on specified nodes and wait all jobs to finish.