From fdff52f0cdbef84f4d35aacbe94fc5378b73efa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Th=C3=B6mmes?= Date: Fri, 19 Mar 2021 17:25:19 +0100 Subject: [PATCH] Default PeriodSeconds of the readiness probe to 1 if unset --- pkg/reconciler/revision/resources/deploy_test.go | 1 + pkg/reconciler/revision/resources/queue.go | 11 +++++++++-- pkg/reconciler/revision/resources/queue_test.go | 5 +---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/reconciler/revision/resources/deploy_test.go b/pkg/reconciler/revision/resources/deploy_test.go index ccc964aff659..19c70120ce6f 100644 --- a/pkg/reconciler/revision/resources/deploy_test.go +++ b/pkg/reconciler/revision/resources/deploy_test.go @@ -98,6 +98,7 @@ var ( }}, }, }, + PeriodSeconds: 1, }, SecurityContext: queueSecurityContext, Env: []corev1.EnvVar{{ diff --git a/pkg/reconciler/revision/resources/queue.go b/pkg/reconciler/revision/resources/queue.go index 78b12b6b9c69..89aedfcedf9d 100644 --- a/pkg/reconciler/revision/resources/queue.go +++ b/pkg/reconciler/revision/resources/queue.go @@ -249,8 +249,8 @@ func makeQueueContainer(rev *v1.Revision, cfg *config.Config) (*corev1.Container // After startup we'll directly use the same http health check endpoint the // execprobe would have used (which will then check the user container). - // Unlike the StartupProbe, we don't need to override any of the - // timeouts/periods/thresholds here. + // Unlike the StartupProbe, we don't need to override any of the other settings + // except period here. See below. httpProbe := container.ReadinessProbe.DeepCopy() httpProbe.Handler = corev1.Handler{ HTTPGet: &corev1.HTTPGetAction{ @@ -262,6 +262,13 @@ func makeQueueContainer(rev *v1.Revision, cfg *config.Config) (*corev1.Container }, } + // Default PeriodSeconds to 1 if not set to make for the quickest possible startup + // time. + // TODO(#10973): Remove this once we're on K8s 1.21 + if httpProbe.PeriodSeconds == 0 { + httpProbe.PeriodSeconds = 1 + } + return &corev1.Container{ Name: QueueContainerName, Image: cfg.Deployment.QueueSidecarImage, diff --git a/pkg/reconciler/revision/resources/queue_test.go b/pkg/reconciler/revision/resources/queue_test.go index 1644d722c82e..5dfb83de6f3c 100644 --- a/pkg/reconciler/revision/resources/queue_test.go +++ b/pkg/reconciler/revision/resources/queue_test.go @@ -735,10 +735,7 @@ func TestTCPProbeGeneration(t *testing.T) { }}, }, }, - // The ReadinessProbe does not override the user's probe parameters. - // (The aggressive probing will have happened on startup, now - // we can probe at the user-requested/default interval). - PeriodSeconds: 0, + PeriodSeconds: 1, TimeoutSeconds: 0, SuccessThreshold: 3, }