@@ -51,7 +51,7 @@ public KubernetesPodLogService(
51
51
if ( podLogs . Outputs . Any ( ) )
52
52
{
53
53
var nextSinceTime = podLogs . Outputs . Max ( o => o . Occurred ) ;
54
- scriptPodSinceTimeStore . UpdateSinceTime ( scriptTicket , nextSinceTime ) ;
54
+ scriptPodSinceTimeStore . UpdatePodLogsSinceTime ( scriptTicket , nextSinceTime ) ;
55
55
56
56
//We can use our EOS marker to detect completion quicker than the Pod status
57
57
if ( podLogs . ExitCode != null )
@@ -72,7 +72,7 @@ public KubernetesPodLogService(
72
72
73
73
async Task < ( IReadOnlyCollection < ProcessOutput > Outputs , long NextSequenceNumber , int ? ExitCode ) > GetPodLogs ( )
74
74
{
75
- var sinceTime = scriptPodSinceTimeStore . GetSinceTime ( scriptTicket ) ;
75
+ var sinceTime = scriptPodSinceTimeStore . GetPodLogsSinceTime ( scriptTicket ) ;
76
76
try
77
77
{
78
78
return await GetPodLogsWithSinceTime ( sinceTime ) ;
@@ -103,7 +103,7 @@ public KubernetesPodLogService(
103
103
104
104
async Task < IEnumerable < ProcessOutput > > GetPodEvents ( ScriptTicket scriptTicket , string podName , CancellationToken cancellationToken )
105
105
{
106
- var sinceTime = scriptPodSinceTimeStore . GetSinceTime ( scriptTicket ) ;
106
+ var sinceTime = scriptPodSinceTimeStore . GetPodEventsSinceTime ( scriptTicket ) ;
107
107
108
108
var allEvents = await eventService . FetchAllEventsAsync ( KubernetesConfig . Namespace , podName , cancellationToken ) ;
109
109
if ( allEvents is null )
@@ -112,18 +112,26 @@ async Task<IEnumerable<ProcessOutput>> GetPodEvents(ScriptTicket scriptTicket, s
112
112
}
113
113
114
114
var relevantEvents = allEvents . Items
115
- . Select ( e=> ( e , EventHelpers . GetEarliestTimestampInEvent ( e ) ) )
116
- . Where ( x => x . Item2 . HasValue )
117
- . Select ( x => ( x . e , new DateTimeOffset ( x . Item2 ! . Value , TimeSpan . Zero ) ) )
118
- . OrderBy ( x => x . Item2 )
119
- . SkipWhile ( e => e . Item2 < sinceTime ) ;
115
+ . Select ( e=> ( Event : e , Occurred : EventHelpers . GetLatestTimestampInEvent ( e ) ) )
116
+ . Where ( x => x . Occurred . HasValue )
117
+ . Select ( x => ( x . Event , Occurred : new DateTimeOffset ( x . Occurred ! . Value , TimeSpan . Zero ) ) )
118
+ . OrderBy ( x => x . Occurred )
119
+ . SkipWhile ( e => e . Occurred <= sinceTime ) ;
120
120
121
- return relevantEvents . Select ( ( x ) =>
121
+ var events = relevantEvents . Select ( ( x ) =>
122
122
{
123
123
var ( ev , occurred ) = x ;
124
- return new ProcessOutput ( ProcessOutputSource . Debug , $ "{ ev . Reason } - { ev . Message } ", occurred ) ;
124
+ return new ProcessOutput ( ProcessOutputSource . Debug , $ "{ ev . Reason } | { ev . Message } (Count: { ev . Count } ) ", occurred ) ;
125
125
} )
126
126
. ToArray ( ) ;
127
+
128
+ if ( events . Any ( ) )
129
+ {
130
+ //update the events since time, so we don't get duplicate events
131
+ scriptPodSinceTimeStore . UpdatePodEventsSinceTime ( scriptTicket , events . Max ( o => o . Occurred ) ) ;
132
+ }
133
+
134
+ return events ;
127
135
}
128
136
129
137
async Task < Stream ? > GetLogStream ( string podName , DateTimeOffset ? sinceTime , CancellationToken cancellationToken )
0 commit comments