@@ -167,7 +167,10 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
167
167
ect .items [namespacedName ] = change
168
168
}
169
169
170
- if t := getLastChangeTriggerTime (endpoints .Annotations ); ! t .IsZero () {
170
+ // In case of Endpoints deletion, the LastChangeTriggerTime annotation is
171
+ // by-definition coming from the time of last update, which is not what
172
+ // we want to measure. So we simply ignore it in this cases.
173
+ if t := getLastChangeTriggerTime (endpoints .Annotations ); ! t .IsZero () && current != nil {
171
174
ect .lastChangeTriggerTimes [namespacedName ] = append (ect .lastChangeTriggerTimes [namespacedName ], t )
172
175
}
173
176
@@ -222,7 +225,12 @@ func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.E
222
225
223
226
if changeNeeded {
224
227
metrics .EndpointChangesPending .Inc ()
225
- if t := getLastChangeTriggerTime (endpointSlice .Annotations ); ! t .IsZero () {
228
+ // In case of Endpoints deletion, the LastChangeTriggerTime annotation is
229
+ // by-definition coming from the time of last update, which is not what
230
+ // we want to measure. So we simply ignore it in this cases.
231
+ // TODO(wojtek-t, robscott): Address the problem for EndpointSlice deletion
232
+ // when other EndpointSlice for that service still exist.
233
+ if t := getLastChangeTriggerTime (endpointSlice .Annotations ); ! t .IsZero () && ! removeSlice {
226
234
ect .lastChangeTriggerTimes [namespacedName ] =
227
235
append (ect .lastChangeTriggerTimes [namespacedName ], t )
228
236
}
0 commit comments