@@ -87,11 +87,6 @@ func (d dests) MarshalLogObject(enc zapcore.ObjectEncoder) error {
8787 return nil
8888}
8989
90- const (
91- probeTimeout time.Duration = 300 * time .Millisecond
92- defaultProbeFrequency time.Duration = 200 * time .Millisecond
93- )
94-
9590// revisionWatcher watches the podIPs and ClusterIP of the service for a revision. It implements the logic
9691// to supply revisionDestsUpdate events on updateCh
9792type revisionWatcher struct {
@@ -131,13 +126,15 @@ type revisionWatcher struct {
131126 // cover the revision's ready conditions, for example when an exec probe is
132127 // being used.
133128 enableProbeOptimisation bool
129+
130+ probeTimeout time.Duration
134131}
135132
136133func newRevisionWatcher (ctx context.Context , rev types.NamespacedName , protocol pkgnet.ProtocolType ,
137134 updateCh chan <- revisionDestsUpdate , destsCh chan dests ,
138135 transport http.RoundTripper , serviceLister corev1listers.ServiceLister ,
139136 usePassthroughLb bool , meshMode netcfg.MeshCompatibilityMode ,
140- enableProbeOptimisation bool ,
137+ enableProbeOptimisation bool , probeTimeout time. Duration ,
141138 logger * zap.SugaredLogger ,
142139) * revisionWatcher {
143140 ctx , cancel := context .WithCancel (ctx )
@@ -155,6 +152,7 @@ func newRevisionWatcher(ctx context.Context, rev types.NamespacedName, protocol
155152 usePassthroughLb : usePassthroughLb ,
156153 meshMode : meshMode ,
157154 enableProbeOptimisation : enableProbeOptimisation ,
155+ probeTimeout : probeTimeout ,
158156 logger : logger .With (zap .String (logkey .Key , rev .String ())),
159157 }
160158}
@@ -219,7 +217,7 @@ func (rw *revisionWatcher) getDest() (string, error) {
219217}
220218
221219func (rw * revisionWatcher ) probeClusterIP (dest string ) (bool , error ) {
222- ctx , cancel := context .WithTimeout (context .Background (), probeTimeout )
220+ ctx , cancel := context .WithTimeout (context .Background (), rw . probeTimeout )
223221 defer cancel ()
224222 match , _ , err := rw .probe (ctx , dest )
225223 return match , err
@@ -248,7 +246,7 @@ func (rw *revisionWatcher) probePodIPs(ready, notReady sets.Set[string]) (succee
248246 }
249247
250248 // Context used for our probe requests.
251- ctx , cancel := context .WithTimeout (context .Background (), probeTimeout )
249+ ctx , cancel := context .WithTimeout (context .Background (), rw . probeTimeout )
252250 defer cancel ()
253251
254252 // Empty errgroup is used as cancellation on first error is not desired, all probes should be
@@ -459,19 +457,12 @@ type revisionBackendsManager struct {
459457 usePassthroughLb bool
460458 meshMode netcfg.MeshCompatibilityMode
461459 logger * zap.SugaredLogger
460+ probeTimeout time.Duration
462461 probeFrequency time.Duration
463462}
464463
465- // NewRevisionBackendsManager returns a new RevisionBackendsManager with default
466- // probe time out.
467- func newRevisionBackendsManager (ctx context.Context , tr http.RoundTripper , usePassthroughLb bool , meshMode netcfg.MeshCompatibilityMode ) * revisionBackendsManager {
468- return newRevisionBackendsManagerWithProbeFrequency (ctx , tr , usePassthroughLb , meshMode , defaultProbeFrequency )
469- }
470-
471- // newRevisionBackendsManagerWithProbeFrequency creates a fully spec'd RevisionBackendsManager.
472- func newRevisionBackendsManagerWithProbeFrequency (ctx context.Context , tr http.RoundTripper ,
473- usePassthroughLb bool , meshMode netcfg.MeshCompatibilityMode , probeFreq time.Duration ,
474- ) * revisionBackendsManager {
464+ // newRevisionBackendsManager returns a new RevisionBackendsManager with configurable probe settings.
465+ func newRevisionBackendsManager (ctx context.Context , tr http.RoundTripper , usePassthroughLb bool , meshMode netcfg.MeshCompatibilityMode , probeTimeout , probeFreq time.Duration ) * revisionBackendsManager {
475466 rbm := & revisionBackendsManager {
476467 ctx : ctx ,
477468 revisionLister : revisioninformer .Get (ctx ).Lister (),
@@ -482,6 +473,7 @@ func newRevisionBackendsManagerWithProbeFrequency(ctx context.Context, tr http.R
482473 usePassthroughLb : usePassthroughLb ,
483474 meshMode : meshMode ,
484475 logger : logging .FromContext (ctx ),
476+ probeTimeout : probeTimeout ,
485477 probeFrequency : probeFreq ,
486478 }
487479 endpointsInformer := endpointsinformer .Get (ctx )
@@ -565,7 +557,7 @@ func (rbm *revisionBackendsManager) getOrCreateRevisionWatcher(revID types.Names
565557 }
566558
567559 destsCh := make (chan dests )
568- rw := newRevisionWatcher (rbm .ctx , revID , rev .GetProtocol (), rbm .updateCh , destsCh , rbm .transport , rbm .serviceLister , rbm .usePassthroughLb , rbm .meshMode , enableProbeOptimisation , rbm .logger )
560+ rw := newRevisionWatcher (rbm .ctx , revID , rev .GetProtocol (), rbm .updateCh , destsCh , rbm .transport , rbm .serviceLister , rbm .usePassthroughLb , rbm .meshMode , enableProbeOptimisation , rbm .probeTimeout , rbm . logger )
569561 rbm .revisionWatchers [revID ] = rw
570562 go rw .run (rbm .probeFrequency )
571563 return rw , nil
0 commit comments