@@ -17,6 +17,7 @@ package porch
1717import (
1818 "context"
1919 "fmt"
20+ "regexp"
2021 "sync"
2122
2223 "github.com/nephio-project/porch/pkg/engine"
@@ -97,10 +98,16 @@ type packageReader interface {
9798// listAndWatch implements watch by doing a list, then sending any observed changes.
9899// This is not a compliant implementation of watch, but it is a good-enough start for most controllers.
99100// One trick is that we start the watch _before_ we perform the list, so we don't miss changes that happen immediately after the list.
101+ var contextErrorRegex = regexp .MustCompile (`context (deadline exceeded|canceled)` )
102+
100103func (w * watcher ) listAndWatch (ctx context.Context , r packageReader , filter repository.ListPackageRevisionFilter ) {
101104 if err := w .listAndWatchInner (ctx , r , filter ); err != nil {
102105 // TODO: We need to populate the object on this error
103- klog .Warningf ("sending error to watch stream: %v" , err )
106+ if contextErrorRegex .MatchString (err .Error ()) {
107+ klog .V (3 ).Infof ("sending error to watch stream: %v" , err )
108+ } else {
109+ klog .Warningf ("sending error to watch stream: %v" , err )
110+ }
104111 ev := watch.Event {
105112 Type : watch .Error ,
106113 }
@@ -195,7 +202,7 @@ func (w *watcher) listAndWatchInner(ctx context.Context, r packageReader, filter
195202 w .sendWatchEvent (ev )
196203 }
197204
198- klog .Infof ("watch %p: moving watch into streaming mode after sentAdd %d, sentBacklog %d, sentNewBacklog %d" , w , sentAdd , sentBacklog , sentNewBacklog )
205+ klog .V ( 3 ). Infof ("watch %p: moving watch into streaming mode after sentAdd %d, sentBacklog %d, sentNewBacklog %d" , w , sentAdd , sentBacklog , sentNewBacklog )
199206 w .eventCallback = func (eventType watch.EventType , pr repository.PackageRevision ) bool {
200207 if w .done {
201208 return false
0 commit comments