1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 13:23:07 +01:00

fix: Removes streams from k8s. See #3646 (#3647)

This commit is contained in:
Amir Raminfar
2025-02-19 09:28:34 -08:00
committed by GitHub
parent 49881c2dfe
commit 77bfb43b6d

View File

@@ -164,25 +164,14 @@ func (k *K8sClient) FindContainer(ctx context.Context, id string) (container.Con
func (k *K8sClient) ContainerLogs(ctx context.Context, id string, since time.Time, stdType container.StdType) (io.ReadCloser, error) { func (k *K8sClient) ContainerLogs(ctx context.Context, id string, since time.Time, stdType container.StdType) (io.ReadCloser, error) {
namespace, podName, containerName := parsePodContainerID(id) namespace, podName, containerName := parsePodContainerID(id)
stream := "" var lines int64 = 500
switch stdType {
case container.STDOUT:
stream = "Stdout"
case container.STDERR:
stream = "Stderr"
case container.STDALL:
stream = "All"
default:
return nil, fmt.Errorf("unknown stream type %s", stdType)
}
opts := &corev1.PodLogOptions{ opts := &corev1.PodLogOptions{
Container: containerName, Container: containerName,
Follow: true, Follow: true,
Previous: false, Previous: false,
Timestamps: true, Timestamps: true,
SinceTime: &metav1.Time{Time: since}, SinceTime: &metav1.Time{Time: since},
Stream: &stream, TailLines: &lines,
} }
return k.Clientset.CoreV1().Pods(namespace).GetLogs(podName, opts).Stream(ctx) return k.Clientset.CoreV1().Pods(namespace).GetLogs(podName, opts).Stream(ctx)
@@ -191,24 +180,11 @@ func (k *K8sClient) ContainerLogs(ctx context.Context, id string, since time.Tim
func (k *K8sClient) ContainerLogsBetweenDates(ctx context.Context, id string, start time.Time, end time.Time, stdType container.StdType) (io.ReadCloser, error) { func (k *K8sClient) ContainerLogsBetweenDates(ctx context.Context, id string, start time.Time, end time.Time, stdType container.StdType) (io.ReadCloser, error) {
namespace, podName, containerName := parsePodContainerID(id) namespace, podName, containerName := parsePodContainerID(id)
stream := ""
switch stdType {
case container.STDOUT:
stream = "Stdout"
case container.STDERR:
stream = "Stderr"
case container.STDALL:
stream = "All"
default:
return nil, fmt.Errorf("unknown stream type %s", stdType)
}
opts := &corev1.PodLogOptions{ opts := &corev1.PodLogOptions{
Container: containerName, Container: containerName,
Follow: false, Follow: false,
Timestamps: true, Timestamps: true,
SinceTime: &metav1.Time{Time: start}, SinceTime: &metav1.Time{Time: start},
Stream: &stream,
} }
return k.Clientset.CoreV1().Pods(namespace).GetLogs(podName, opts).Stream(ctx) return k.Clientset.CoreV1().Pods(namespace).GetLogs(podName, opts).Stream(ctx)