Skip to content

Commit

Permalink
Adding container name to log config
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgammon-mettle committed Dec 23, 2024
1 parent c1834b6 commit 1692125
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/skaffold/k8sjob/logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (l *Logger) streamLogsFromKubernetesJob(ctx context.Context, id, namespace
}
}
var podName string
var containerName string
w, err := clientset.CoreV1().Pods(namespace).Watch(ctx,
metav1.ListOptions{
LabelSelector: labels.Set(map[string]string{"job-name": id, "skaffold.dev/run-id": l.labeller.GetRunID()}).String(),
Expand All @@ -180,6 +181,7 @@ func (l *Logger) streamLogsFromKubernetesJob(ctx context.Context, id, namespace
pod, ok := event.Object.(*corev1.Pod)
if ok {
podName = pod.Name
containerName = pod.Spec.Containers[0].Name
done <- true
break
}
Expand All @@ -195,9 +197,7 @@ func (l *Logger) streamLogsFromKubernetesJob(ctx context.Context, id, namespace
return false, fmt.Errorf("timeout waiting for event from pod of kubernetes job: %s", id)
}

podLogOptions := &corev1.PodLogOptions{
Follow: true,
}
podLogOptions := &corev1.PodLogOptions{Follow: true, Container: containerName}

// Stream the logs
req := clientset.CoreV1().Pods(namespace).GetLogs(podName, podLogOptions)
Expand Down

0 comments on commit 1692125

Please sign in to comment.