From 33bff734bc07d58f6a5e020ffd6b22141e08bee5 Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Sun, 2 Feb 2020 09:08:35 -0800 Subject: [PATCH 1/2] Ensure lastLogTime never decreases --- pkg/operator/operator/logs.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/operator/operator/logs.go b/pkg/operator/operator/logs.go index b4acfc76e1..c35d3076bb 100644 --- a/pkg/operator/operator/logs.go +++ b/pkg/operator/operator/logs.go @@ -103,6 +103,7 @@ func streamFromCloudWatch(apiName string, podCheckCancel chan struct{}, socket * lastLogStreamRefresh := time.Time{} lastDeploymentRefresh := time.Time{} lastLogTime := time.Now() + lastLogTimeQuery := time.Time{} logStreamNames := strset.New() didShowFetchingMessage := false didFetchLogs := false @@ -167,6 +168,11 @@ func streamFromCloudWatch(apiName string, podCheckCancel chan struct{}, socket * endTime := libtime.ToMillis(time.Now()) + if lastLogTime.Before(lastLogTimeQuery) { + lastLogTime = lastLogTimeQuery + } + lastLogTimeQuery = lastLogTime + logEventsOutput, err := config.AWS.CloudWatchLogs().FilterLogEvents(&cloudwatchlogs.FilterLogEventsInput{ LogGroupName: aws.String(logGroupName), LogStreamNames: aws.StringSlice(logStreamNames.Slice()), From f1e0b59e5fffa25a0be86477a4db197290961680 Mon Sep 17 00:00:00 2001 From: vishal Date: Fri, 14 Feb 2020 14:06:19 -0500 Subject: [PATCH 2/2] Don't subtract poll period every loop --- pkg/operator/operator/logs.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/operator/operator/logs.go b/pkg/operator/operator/logs.go index c35d3076bb..b4f8bb7a24 100644 --- a/pkg/operator/operator/logs.go +++ b/pkg/operator/operator/logs.go @@ -103,7 +103,6 @@ func streamFromCloudWatch(apiName string, podCheckCancel chan struct{}, socket * lastLogStreamRefresh := time.Time{} lastDeploymentRefresh := time.Time{} lastLogTime := time.Now() - lastLogTimeQuery := time.Time{} logStreamNames := strset.New() didShowFetchingMessage := false didFetchLogs := false @@ -159,8 +158,6 @@ func streamFromCloudWatch(apiName string, podCheckCancel chan struct{}, socket * continue } - lastLogTime = lastLogTime.Add(-_pollPeriod) - if !didFetchLogs { lastLogTime = deployment.CreationTimestamp.Time didFetchLogs = true @@ -168,15 +165,10 @@ func streamFromCloudWatch(apiName string, podCheckCancel chan struct{}, socket * endTime := libtime.ToMillis(time.Now()) - if lastLogTime.Before(lastLogTimeQuery) { - lastLogTime = lastLogTimeQuery - } - lastLogTimeQuery = lastLogTime - logEventsOutput, err := config.AWS.CloudWatchLogs().FilterLogEvents(&cloudwatchlogs.FilterLogEventsInput{ LogGroupName: aws.String(logGroupName), LogStreamNames: aws.StringSlice(logStreamNames.Slice()), - StartTime: aws.Int64(libtime.ToMillis(lastLogTime)), + StartTime: aws.Int64(libtime.ToMillis(lastLogTime.Add(-_pollPeriod))), EndTime: aws.Int64(endTime), Limit: aws.Int64(int64(_maxLogLinesPerRequest)), })