Rename variable

This commit is contained in:
Rob Watson 2022-06-02 19:23:44 +02:00
parent 7e74fb6f08
commit 3639b43260
1 changed files with 7 additions and 7 deletions

View File

@ -163,35 +163,35 @@ func (pw *PodWatcher) removePod(podName string) {
delete(pw.status, podName)
}
func copyPodLogs(ctx context.Context, wg *sync.WaitGroup, clientset KubernetesClient, p *corev1.Pod, container string, dst io.Writer) *streamError {
func copyPodLogs(ctx context.Context, wg *sync.WaitGroup, clientset KubernetesClient, pod *corev1.Pod, container string, dst io.Writer) *streamError {
defer wg.Done()
podLogOpts := corev1.PodLogOptions{
Follow: true,
Container: container,
}
req := clientset.CoreV1().Pods(p.Namespace).GetLogs(p.Name, &podLogOpts)
req := clientset.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts)
logs, err := req.Stream(ctx)
// If one container is still being created, do not treat this as a fatal error.
// We try to verify the error type as strictly as possible.
var statusErr *apierrors.StatusError
if errors.As(err, &statusErr) && statusErr.Status().Reason == metav1.StatusReasonBadRequest && strings.Contains(statusErr.Error(), "ContainerCreating") {
return newRecoverableError(err, p.Name)
return newRecoverableError(err, pod.Name)
} else if err != nil {
return newStreamError(err, p.Name)
return newStreamError(err, pod.Name)
}
defer func() { _ = logs.Close() }()
scanner := bufio.NewScanner(logs)
for scanner.Scan() {
if _, err = dst.Write([]byte("[" + p.Name + "] " + scanner.Text() + nl)); err != nil {
return newStreamError(fmt.Errorf("error writing logs: %v", err), p.Name)
if _, err = dst.Write([]byte("[" + pod.Name + "] " + scanner.Text() + nl)); err != nil {
return newStreamError(fmt.Errorf("error writing logs: %v", err), pod.Name)
}
}
if err := scanner.Err(); err != nil {
return newStreamError(fmt.Errorf("error scanning logs: %v", err), p.Name)
return newStreamError(fmt.Errorf("error scanning logs: %v", err), pod.Name)
}
return nil
}