Skip to content

Fix configuration timeout defaulting - #15617

Merged
knative-prow[bot] merged 7 commits into
knative:mainfrom
skonto:response_time_fix
Jan 21, 2025
Merged

knative-prow[bot] merged 7 commits into
knative:mainfrom
skonto:response_time_fix

Conversation

@skonto

@skonto skonto commented Nov 15, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #15616

Proposed Changes

  • As per title. We inject the right context for revision config to be properly updated with the latest values.
  • This affects revision-response-start-timeout-seconds, revision-idle-timeout-seconds, so that when they are equal to the revision-timeout-seconds in the defaults cm, they will not be set to 300 (default) at a revision that has no overrides of those values. Instead they are set to nil at the revision (0 at the QP side). Semantically this is correct, since when the timeouts are equal we don't need both anyway.

Release Note

Fixes revision timeout defaulting when identical values are present in timeout settings.

@knative-prow
knative-prow Bot requested review from ReToCode and izabelacg November 15, 2024 11:03
@knative-prow knative-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 15, 2024
@skonto
skonto requested review from dprotaso and removed request for izabelacg November 15, 2024 11:03
@codecov

codecov Bot commented Nov 15, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (b1e9a0c) to head (e644df4).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15617      +/-   ##
==========================================
- Coverage   80.83%   80.83%   -0.01%     
==========================================
  Files         222      222              
  Lines       18035    18070      +35     
==========================================
+ Hits        14578    14606      +28     
- Misses       3087     3092       +5     
- Partials      370      372       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@skonto skonto added this to the v1.17.0 milestone Nov 20, 2024
@skonto

skonto commented Dec 16, 2024

Copy link
Copy Markdown
Contributor Author

@dprotaso gentle ping.

Name: config.DefaultsConfigName,
},
Data: map[string]string{
"revision-timeout-seconds": "423",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was 423 chosen as the timeout value? Consider using a named constant or variable to make the
intent clear and maintain consistency across test files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just picked a number. I will update with a constant.

},
},
},
ctx: func() context.Context {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context setup logic is duplicated between configuration_defaults_test.go and
revision_defaults_test.go. Consider extracting this into a test helper function to improve
maintainability.

@skonto skonto Jan 14, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually they are using a different config store although the func seems similar, which makes things harder because configs are of different types and don't inherit similar methods. I will give it a shot.

@skonto
skonto force-pushed the response_time_fix branch from 610bdc8 to 308d56c Compare January 14, 2025 10:02
@skonto

skonto commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

cc @dprotaso

@skonto

skonto commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

/retest

Comment on lines +73 to +82
configurationConfig := cconfig.FromContext(ctx)
apisConfig := config.Config{}
if configurationConfig != nil && configurationConfig.Defaults != nil {
apisConfig.Defaults = configurationConfig.Defaults.DeepCopy()
}
if configurationConfig != nil && configurationConfig.Features != nil {
apisConfig.Features = configurationConfig.Features.DeepCopy()
}
ctx = config.ToContext(ctx, &apisConfig)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configurationConfig := cconfig.FromContext(ctx)

This will always be nil - the webhook has a config map watcher that updates the api's config store.

@dprotaso dprotaso Jan 16, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a different fix - but I haven't dug into why the default of 300 is being applied - when in fact the default is here and it should be using what's in the config map

nc.RevisionResponseStartTimeoutSeconds = nc.RevisionTimeoutSeconds
if err := cm.Parse(data,
cm.AsInt64("revision-response-start-timeout-seconds", &nc.RevisionResponseStartTimeoutSeconds),
); err != nil {
return nil, err
}

@dprotaso dprotaso Jan 16, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has only been an issue because before when we default we set all the properties - but this one setting is different

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix should be to add the apiconfig.Store into the context using the same key that's in the apiconfig package

eg. here

func (s *Store) ToContext(ctx context.Context) context.Context {

we should call

func ToContext(ctx context.Context, c *Config) context.Context {

Other stores in reconciler could have similar issues

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dprotaso have you checked the description of the root cause here: #15616?

@skonto skonto Jan 20, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will fix.

@skonto
skonto force-pushed the response_time_fix branch from 308d56c to 5df6756 Compare January 20, 2025 12:28
},
},
}, {
name: "run latest with identical timeout defaults",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test exposes the issue.

s.OnConfigChanged(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: autoscalerconfig.ConfigName}})
s.OnConfigChanged(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: config.FeaturesConfigName}})
s.OnConfigChanged(&corev1.ConfigMap{
wc: defaultRevisionContextWithStore(logger, nil, corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: autoscalerconfig.ConfigName}},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble reading the context now cause the helper has tons of args etc.

Can we do the following

  1. In the context helper function initialize all the config maps we need defaults by invoking
s.OnConfigChanged(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: autoscalerconfig.ConfigName}})
s.OnConfigChanged(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: config.FeaturesConfigName}})
s.OnConfigChanged(&corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: config.DefaultsConfigName}})
  1. Pass in the override to this function and call onChanged for the changed configmaps
corev1.ConfigMap{
				ObjectMeta: metav1.ObjectMeta{
					Name: config.DefaultsConfigName,
				},
				Data: map[string]string{
					"revision-timeout-seconds": strconv.Itoa(someTimeoutSeconds),
				},
			}
  1. Don't take in an extra WithContext function just wrap the invocations
wc: apis.WithinCreate(defaultRevisionContextWithStore(...))
  1. defaultRevisionContextWithStore - maybe call it configMapsToContext

@dprotaso

Copy link
Copy Markdown
Member

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2025
@knative-prow

knative-prow Bot commented Jan 21, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, skonto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2025
@dprotaso

Copy link
Copy Markdown
Member

/cherry-pick release-1.16

@knative-prow-robot

Copy link
Copy Markdown
Contributor

@dprotaso: once the present PR merges, I will cherry-pick it on top of release-1.16 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.16

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dprotaso

Copy link
Copy Markdown
Member

/cherry-pick release-1.15

@knative-prow-robot

Copy link
Copy Markdown
Contributor

@dprotaso: once the present PR merges, I will cherry-pick it on top of release-1.15 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow
knative-prow Bot merged commit 6265a8e into knative:main Jan 21, 2025
@knative-prow-robot

Copy link
Copy Markdown
Contributor

@dprotaso: new pull request created: #15721

Details

In response to this:

/cherry-pick release-1.16

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow-robot

Copy link
Copy Markdown
Contributor

@dprotaso: new pull request created: #15722

Details

In response to this:

/cherry-pick release-1.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

revision-response-start-timeout-seconds is set wrongly

5 participants