Skip to content

Commit 9fec783

Browse files
committed
Log mvcc revision compaction as warning
1 parent da5b90a commit 9fec783

File tree

1 file changed

+11
-2
lines changed
  • staging/src/k8s.io/apiserver/pkg/storage/etcd3

1 file changed

+11
-2
lines changed

staging/src/k8s.io/apiserver/pkg/storage/etcd3/watcher.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ func (wc *watchChan) sync() error {
191191
return nil
192192
}
193193

194+
// logWatchChannelErr checks whether the error is about mvcc revision compaction which is regarded as warning
195+
func logWatchChannelErr(err error) {
196+
if !strings.Contains(err.Error(), "mvcc: required revision has been compacted") {
197+
klog.Errorf("watch chan error: %v", err)
198+
} else {
199+
klog.Warningf("watch chan error: %v", err)
200+
}
201+
}
202+
194203
// startWatching does:
195204
// - get current objects if initialRev=0; set initialRev to current rev
196205
// - watch on given key and send events to process.
@@ -211,14 +220,14 @@ func (wc *watchChan) startWatching(watchClosedCh chan struct{}) {
211220
if wres.Err() != nil {
212221
err := wres.Err()
213222
// If there is an error on server (e.g. compaction), the channel will return it before closed.
214-
klog.Errorf("watch chan error: %v", err)
223+
logWatchChannelErr(err)
215224
wc.sendError(err)
216225
return
217226
}
218227
for _, e := range wres.Events {
219228
parsedEvent, err := parseEvent(e)
220229
if err != nil {
221-
klog.Errorf("watch chan error: %v", err)
230+
logWatchChannelErr(err)
222231
wc.sendError(err)
223232
return
224233
}

0 commit comments

Comments
 (0)