GoogleCloudPlatform / GoogleCloudPlatform/k8s-stackdriver
[P0] event-exporter: use watchlist + bookmarks to avoid expensive initial list
- Dominant language
- Go
- Stars
- 409
- Forks
- 236
- Avg merge
- 2h 34m
- Merged PRs (30d)
- 9
Description
## Problem
Initial list of Events is expensive for large clusters. Even though the current watcher clears `list.Items` to avoid local buffering, the apiserver still has to produce and transmit the full list before the watch starts. This delays readiness and increases API load when event volume is high.
## Proposed optimization
Use watchlist semantics (SendInitialEvents + watch bookmarks) so the initial state is streamed over watch and ends with a bookmark. This avoids large list bursts and provides a clean sync point for the watcher.
## Notes / references
- Watchlist and bookmarks in ListOptions: https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes
- `metav1.ListOptions`: `AllowWatchBookmarks`, `SendInitialEvents`, `ResourceVersionMatch=NotOlderThan`
- client-go reflector already supports watchlist mode (see `k8s.io/client-go/tools/cache/reflector.go`)
## Acceptance criteria
- Event watcher uses watchlist for initial sync and handles bookmark completion.
- Startup time and apiserver request volume are reduced vs. full list on large clusters.
- Fallback to list/watch remains in place for clusters that do not support watchlist.
Contributor guide
Assessment
This issue has not been assessed yet.