Skip to content

Commit

Permalink
Fix restart checking daemonset
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Mar 14, 2024
1 parent 293aa54 commit 4536b3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
5 changes: 3 additions & 2 deletions test/performance/framework/client_pod/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func Update(ctx context.Context, kClient kubernetes.Interface, ns, clientDaemonS
if err != nil {
return false, nil
}
klog.InfoS("Waiting the DaemonSets restart", "DaemonSet", ds)
if ds.Generation != ds.Status.ObservedGeneration {
return false, nil
}
if ds.Status.DesiredNumberScheduled != ds.Status.NumberAvailable {
return false, nil
}
Expand All @@ -98,7 +100,6 @@ func Update(ctx context.Context, kClient kubernetes.Interface, ns, clientDaemonS
}
for i := range podList.Items {
pod := podList.Items[i]
klog.InfoS("Waiting the DaemonSets Pods", "Pod", pod)
if pod.DeletionTimestamp != nil || !podutils.IsPodReady(&pod) {
return false, nil
}
Expand Down
31 changes: 0 additions & 31 deletions test/performance/framework/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ func ScaleRestartAgent(ctx context.Context, ch chan time.Duration, data *ScaleDa
}, ctx.Done())

go func() {
if err := checkPodLog(data, ctx); err != nil {
klog.ErrorS(err, "error when checking scale test client pods log")
return
}
podList, err := data.kubernetesClientSet.CoreV1().Pods(client_pod.ClientPodsNamespace).List(ctx, metav1.ListOptions{LabelSelector: client_pod.ScaleClientPodTemplateName})
if err != nil {
err = fmt.Errorf("error when getting scale test client pods: %w", err)

Check failure on line 84 in test/performance/framework/restart.go

View workflow job for this annotation

GitHub Actions / Golangci-lint (ubuntu-latest)

SA4017: Errorf doesn't have side effects and its return value is ignored (staticcheck)

Check failure on line 84 in test/performance/framework/restart.go

View workflow job for this annotation

GitHub Actions / Golangci-lint (macos-latest)

SA4017: Errorf doesn't have side effects and its return value is ignored (staticcheck)
Expand All @@ -103,29 +99,6 @@ func ScaleRestartAgent(ctx context.Context, ch chan time.Duration, data *ScaleDa
return
}

func checkPodLog(data *ScaleData, ctx context.Context) error {
return wait.Poll(time.Second, 60*time.Second, func() (done bool, err error) {
podList, err := data.kubernetesClientSet.CoreV1().Pods(client_pod.ClientPodsNamespace).List(ctx, metav1.ListOptions{LabelSelector: client_pod.ScaleClientPodTemplateName})
if err != nil {
err = fmt.Errorf("error when getting scale test client pods: %w", err)
return
}
klog.InfoS("Checking Pod log", "Pod Items num", len(podList.Items))
for _, pod := range podList.Items {
req := data.kubernetesClientSet.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &v1.PodLogOptions{
Container: client_pod.ScaleClientPodTemplateName,
})

if _, err = req.Stream(ctx); err != nil {
klog.ErrorS(err, "error when opening stream to retrieve logs for Pod", "namespace", pod.Namespace, "podName", pod.Name)
return false, nil
}
klog.InfoS("Checking Pod log", "Name", pod.Name, "Namespace", pod.Namespace, "Container", client_pod.ScaleClientPodTemplateName)
}
return true, nil
})
}

func getControllerPod(data *ScaleData, ctx context.Context) (*v1.Pod, error) {
controllerPods, err := data.kubernetesClientSet.CoreV1().Pods(metav1.NamespaceSystem).List(ctx, metav1.ListOptions{LabelSelector: "app=antrea,component=antrea-controller"})
if err != nil {
Expand Down Expand Up @@ -172,10 +145,6 @@ func RestartController(ctx context.Context, ch chan time.Duration, data *ScaleDa
}, ctx.Done())

go func() {
if err := checkPodLog(data, ctx); err != nil {
klog.ErrorS(err, "error when checking scale test client pods log")
return
}
controllerPod, err := getControllerPod(data, ctx)

Check failure on line 148 in test/performance/framework/restart.go

View workflow job for this annotation

GitHub Actions / Golangci-lint (ubuntu-latest)

SA4006: this value of `err` is never used (staticcheck)

Check failure on line 148 in test/performance/framework/restart.go

View workflow job for this annotation

GitHub Actions / Golangci-lint (macos-latest)

SA4006: this value of `err` is never used (staticcheck)
podList, err := data.kubernetesClientSet.CoreV1().Pods(client_pod.ClientPodsNamespace).List(ctx, metav1.ListOptions{LabelSelector: client_pod.ScaleClientPodTemplateName})
if err != nil {
Expand Down

0 comments on commit 4536b3c

Please sign in to comment.