Skip to content

Commit

Permalink
print logs of yurt-manager component in local-up-openyurt (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch authored Mar 21, 2023
1 parent c028c47 commit 283d25d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 3 additions & 5 deletions test/e2e/cmd/init/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/cmd/init/util/kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 283d25d

Please sign in to comment.