-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add configurable probe timeout and frequency for activator #16250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bindrad
wants to merge
2
commits into
knative:main
Choose a base branch
from
bindrad:conf-activator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,11 +87,6 @@ func (d dests) MarshalLogObject(enc zapcore.ObjectEncoder) error { | |
| return nil | ||
| } | ||
|
|
||
| const ( | ||
| probeTimeout time.Duration = 300 * time.Millisecond | ||
| defaultProbeFrequency time.Duration = 200 * time.Millisecond | ||
| ) | ||
|
|
||
| // revisionWatcher watches the podIPs and ClusterIP of the service for a revision. It implements the logic | ||
| // to supply revisionDestsUpdate events on updateCh | ||
| type revisionWatcher struct { | ||
|
|
@@ -131,13 +126,15 @@ type revisionWatcher struct { | |
| // cover the revision's ready conditions, for example when an exec probe is | ||
| // being used. | ||
| enableProbeOptimisation bool | ||
|
|
||
| probeTimeout time.Duration | ||
| } | ||
|
|
||
| func newRevisionWatcher(ctx context.Context, rev types.NamespacedName, protocol pkgnet.ProtocolType, | ||
| updateCh chan<- revisionDestsUpdate, destsCh chan dests, | ||
| transport http.RoundTripper, serviceLister corev1listers.ServiceLister, | ||
| usePassthroughLb bool, meshMode netcfg.MeshCompatibilityMode, | ||
| enableProbeOptimisation bool, | ||
| enableProbeOptimisation bool, probeTimeout time.Duration, | ||
| logger *zap.SugaredLogger, | ||
| ) *revisionWatcher { | ||
| ctx, cancel := context.WithCancel(ctx) | ||
|
|
@@ -155,6 +152,7 @@ func newRevisionWatcher(ctx context.Context, rev types.NamespacedName, protocol | |
| usePassthroughLb: usePassthroughLb, | ||
| meshMode: meshMode, | ||
| enableProbeOptimisation: enableProbeOptimisation, | ||
| probeTimeout: probeTimeout, | ||
| logger: logger.With(zap.String(logkey.Key, rev.String())), | ||
| } | ||
| } | ||
|
|
@@ -219,7 +217,7 @@ func (rw *revisionWatcher) getDest() (string, error) { | |
| } | ||
|
|
||
| func (rw *revisionWatcher) probeClusterIP(dest string) (bool, error) { | ||
| ctx, cancel := context.WithTimeout(context.Background(), probeTimeout) | ||
| ctx, cancel := context.WithTimeout(context.Background(), rw.probeTimeout) | ||
| defer cancel() | ||
| match, _, err := rw.probe(ctx, dest) | ||
| return match, err | ||
|
|
@@ -248,7 +246,7 @@ func (rw *revisionWatcher) probePodIPs(ready, notReady sets.Set[string]) (succee | |
| } | ||
|
|
||
| // Context used for our probe requests. | ||
| ctx, cancel := context.WithTimeout(context.Background(), probeTimeout) | ||
| ctx, cancel := context.WithTimeout(context.Background(), rw.probeTimeout) | ||
| defer cancel() | ||
|
|
||
| // Empty errgroup is used as cancellation on first error is not desired, all probes should be | ||
|
|
@@ -459,19 +457,12 @@ type revisionBackendsManager struct { | |
| usePassthroughLb bool | ||
| meshMode netcfg.MeshCompatibilityMode | ||
| logger *zap.SugaredLogger | ||
| probeTimeout time.Duration | ||
| probeFrequency time.Duration | ||
|
Comment on lines
+460
to
461
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where and when is probeFrequency changed on a per revision basis? If we're not changing things per-revision we can save ourselves all this extra code plumbing these fields down and maybe just use the constants that can be overridden by the env var |
||
| } | ||
|
|
||
| // NewRevisionBackendsManager returns a new RevisionBackendsManager with default | ||
| // probe time out. | ||
| func newRevisionBackendsManager(ctx context.Context, tr http.RoundTripper, usePassthroughLb bool, meshMode netcfg.MeshCompatibilityMode) *revisionBackendsManager { | ||
| return newRevisionBackendsManagerWithProbeFrequency(ctx, tr, usePassthroughLb, meshMode, defaultProbeFrequency) | ||
| } | ||
|
|
||
| // newRevisionBackendsManagerWithProbeFrequency creates a fully spec'd RevisionBackendsManager. | ||
| func newRevisionBackendsManagerWithProbeFrequency(ctx context.Context, tr http.RoundTripper, | ||
| usePassthroughLb bool, meshMode netcfg.MeshCompatibilityMode, probeFreq time.Duration, | ||
| ) *revisionBackendsManager { | ||
| // newRevisionBackendsManager returns a new RevisionBackendsManager with configurable probe settings. | ||
| func newRevisionBackendsManager(ctx context.Context, tr http.RoundTripper, usePassthroughLb bool, meshMode netcfg.MeshCompatibilityMode, probeTimeout, probeFreq time.Duration) *revisionBackendsManager { | ||
| rbm := &revisionBackendsManager{ | ||
| ctx: ctx, | ||
| revisionLister: revisioninformer.Get(ctx).Lister(), | ||
|
|
@@ -482,6 +473,7 @@ func newRevisionBackendsManagerWithProbeFrequency(ctx context.Context, tr http.R | |
| usePassthroughLb: usePassthroughLb, | ||
| meshMode: meshMode, | ||
| logger: logging.FromContext(ctx), | ||
| probeTimeout: probeTimeout, | ||
| probeFrequency: probeFreq, | ||
| } | ||
| endpointsInformer := endpointsinformer.Get(ctx) | ||
|
|
@@ -565,7 +557,7 @@ func (rbm *revisionBackendsManager) getOrCreateRevisionWatcher(revID types.Names | |
| } | ||
|
|
||
| destsCh := make(chan dests) | ||
| rw := newRevisionWatcher(rbm.ctx, revID, rev.GetProtocol(), rbm.updateCh, destsCh, rbm.transport, rbm.serviceLister, rbm.usePassthroughLb, rbm.meshMode, enableProbeOptimisation, rbm.logger) | ||
| rw := newRevisionWatcher(rbm.ctx, revID, rev.GetProtocol(), rbm.updateCh, destsCh, rbm.transport, rbm.serviceLister, rbm.usePassthroughLb, rbm.meshMode, enableProbeOptimisation, rbm.probeTimeout, rbm.logger) | ||
| rbm.revisionWatchers[revID] = rw | ||
| go rw.run(rbm.probeFrequency) | ||
| return rw, nil | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like more flexibility here to provide a golang duration string and parse it using https://pkg.go.dev/time#ParseDuration to prase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise not having the unit in the name is confusing