<#7037 fix: Track ResourceVersion in TaskAction wa...
# flyte-github
a
#7037 fix: Track ResourceVersion in TaskAction watcher to prevent duplicate ADDED events Pull request opened by majiayu000 Fixes #6988 Changes Track ResourceVersion across watch reconnects to prevent duplicate ADDED events when the Kubernetes watch connection drops and re-establishes. Root cause:
doWatch()
creates watches without passing ResourceVersion, so the API server replays all existing resources as ADDED events on reconnect. Fix: 1. Added
lastResourceVersion
field to
ActionsClient
struct 2. In `doWatch()`: read
lastResourceVersion
under RLock and pass it in
metav1.ListOptions.ResourceVersion
when creating the watch 3. In `handleWatchEvent()`: update
lastResourceVersion
from
taskAction.ResourceVersion
under write Lock 4. Handle
watch.Error
events: on 410 Gone, reset
lastResourceVersion
to
""
(triggers fresh list); on other errors, preserve version for retry Thread safety uses the existing
mu sync.RWMutex
. Test Plan • `TestHandleWatchEvent_UpdatesResourceVersion`: verify ResourceVersion is extracted and stored from watch events • `TestDoWatch_PassesResourceVersionOnReconnect`: verify stored version is passed in ListOptions on reconnect • `TestDoWatch_HandlesGoneError`: verify 410 Gone resets to empty string • `TestDoWatch_PreservesResourceVersionOnOtherErrors`: verify non-Gone errors preserve version All tests pass with
-race
flag. •
main
• #6583 • fix: Track ResourceVersion in TaskAction watcher to prevent duplicate ADDED events 👈 flyteorg/flyte