Skip to content
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

Respect revision timeout defaults in cm #14600

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/apis/serving/v1/revision_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ func (rs *RevisionSpec) SetDefaults(ctx context.Context) {
rs.TimeoutSeconds = ptr.Int64(cfg.Defaults.RevisionTimeoutSeconds)
}

// Default IdleTimeoutSeconds only in case we have a non-zero default and the latter is not larger than the revision timeout.
// A zero default or a zero value set from the user or a nil value skips timer setup at the QP side.
if rs.IdleTimeoutSeconds == nil {
if cfg.Defaults.RevisionIdleTimeoutSeconds < *rs.TimeoutSeconds && cfg.Defaults.RevisionIdleTimeoutSeconds != 0 {
rs.IdleTimeoutSeconds = ptr.Int64(cfg.Defaults.RevisionIdleTimeoutSeconds)
}
}

// Default ResponseStartTimeoutSeconds only in case we have a non-zero default and the latter is not larger than the revision timeout.
// A zero default or a zero value set from the user or a nil value skips timer setup at the QP side.
if rs.ResponseStartTimeoutSeconds == nil {
if cfg.Defaults.RevisionRequestStartTimeoutSeconds < *rs.TimeoutSeconds && cfg.Defaults.RevisionRequestStartTimeoutSeconds != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

revision-response-start-timeout-seconds is used to initialize RevisionRequestStartTimeoutSeconds so we use that.

	// We default this to what the user has specified
	nc.RevisionRequestStartTimeoutSeconds = nc.RevisionTimeoutSeconds

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

Copy link
Member

Choose a reason for hiding this comment

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

Can we update RevisionRequestStartTimeoutSeconds to match the key name in a subsequent PR?

rs.ResponseStartTimeoutSeconds = ptr.Int64(cfg.Defaults.RevisionRequestStartTimeoutSeconds)
}
}

// Default ContainerConcurrency based on our configmap.
if rs.ContainerConcurrency == nil {
rs.ContainerConcurrency = ptr.Int64(cfg.Defaults.ContainerConcurrency)
Expand Down
34 changes: 34 additions & 0 deletions pkg/apis/serving/v1/revision_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,40 @@ func TestRevisionDefaulting(t *testing.T) {
},
},
},
}, {
name: "all revision timeouts set",
in: &Revision{Spec: RevisionSpec{PodSpec: corev1.PodSpec{Containers: []corev1.Container{{}}}}},
wc: func(ctx context.Context) context.Context {
s := config.NewStore(logger)
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,
},
Data: map[string]string{
"revision-timeout-seconds": "423",
"revision-idle-timeout-seconds": "100",
"revision-response-start-timeout-seconds": "50",
},
})
return s.ToContext(ctx)
},
want: &Revision{
Spec: RevisionSpec{
ContainerConcurrency: ptr.Int64(0),
TimeoutSeconds: ptr.Int64(423),
ResponseStartTimeoutSeconds: ptr.Int64(50),
IdleTimeoutSeconds: ptr.Int64(100),
PodSpec: corev1.PodSpec{
Containers: []corev1.Container{{
Name: config.DefaultUserContainerName,
Resources: defaultResources,
ReadinessProbe: defaultProbe,
}},
},
},
},
}, {
name: "with context, in create, expect ESL set",
in: &Revision{Spec: RevisionSpec{PodSpec: corev1.PodSpec{Containers: []corev1.Container{{}}}}},
Expand Down
Loading