Skip to content

Commit

Permalink
Fix K8S log reconnect timestamp tracking (#939)
Browse files Browse the repository at this point in the history
Also reviewed by myself and @shanemcd
  • Loading branch information
TheRealHaoLiu authored Feb 5, 2024
1 parent 9f05dd2 commit 414c76d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ func podRunningAndReady() func(event watch.Event) (bool, error) {
return inner
}

func (kw *kubeUnit) kubeLoggingConnectionHandler(timestamps bool) (io.ReadCloser, error) {
func (kw *kubeUnit) kubeLoggingConnectionHandler(timestamps bool, sinceTime time.Time) (io.ReadCloser, error) {
var logStream io.ReadCloser
var err error
var sinceTime time.Time
podNamespace := kw.pod.Namespace
podName := kw.pod.Name
podOptions := &corev1.PodLogOptions{
Expand Down Expand Up @@ -172,7 +171,7 @@ func (kw *kubeUnit) kubeLoggingNoReconnect(streamWait *sync.WaitGroup, stdout *S
defer streamWait.Done()
podNamespace := kw.pod.Namespace
podName := kw.pod.Name
logStream, err := kw.kubeLoggingConnectionHandler(false)
logStream, err := kw.kubeLoggingConnectionHandler(false, time.Time{})
if err != nil {
return
}
Expand Down Expand Up @@ -228,7 +227,7 @@ func (kw *kubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
break
}

logStream, err := kw.kubeLoggingConnectionHandler(true)
logStream, err := kw.kubeLoggingConnectionHandler(true, sinceTime)
if err != nil {
break
}
Expand Down

0 comments on commit 414c76d

Please sign in to comment.