Skip to content

Commit

Permalink
Tidy and refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
julz committed Feb 12, 2021
1 parent 68a53d2 commit 793f0f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/revision/resources/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ func TestMakePodSpec(t *testing.T) {
),
}),
}, {
name: "propertes allowed by the webhook are passed through",
name: "properties allowed by the webhook are passed through",
rev: revision("bar", "foo",
withContainers([]corev1.Container{{
Name: servingContainerName,
Expand Down
27 changes: 13 additions & 14 deletions pkg/reconciler/revision/resources/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,24 @@ func makeQueueContainer(rev *v1.Revision, cfg *config.Config) (*corev1.Container
// During startup we want to poll the container faster than Kubernetes will
// allow, so we use an ExecProbe which starts immediately and then polls
// every 25ms. We encode the original probe as JSON in an environment
// variable for this exec probe to use.
startupProbe := container.ReadinessProbe.DeepCopy()
applyReadinessProbeDefaultsForExec(startupProbe, userPort)
probeJSON, err := readiness.EncodeProbe(startupProbe)
// variable for this probe to use.
userProbe := container.ReadinessProbe.DeepCopy()
applyReadinessProbeDefaultsForExec(userProbe, userPort)
execProbe := makeExecProbe(userProbe)
userProbeJSON, err := readiness.EncodeProbe(userProbe)
if err != nil {
return nil, fmt.Errorf("failed to serialize readiness probe: %w", err)
}

// After startup we'll directly use the same QP http health check the
// After startup we'll directly use the same http health check endpoint the
// execprobe would have used (which will then check the user container).
// This maintains the behaviour of incorporating user-container readiness
// in QP readiness.
readinessProbe := container.ReadinessProbe.DeepCopy()
readinessProbe.Handler = corev1.Handler{
// Unlike the StartupProbe, we don't need to override any of the
// timeouts/periods/thresholds here.
httpProbe := container.ReadinessProbe.DeepCopy()
httpProbe.Handler = corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Port: intstr.FromInt(int(servingPort.ContainerPort)),
HTTPHeaders: []corev1.HTTPHeader{{
// Adding this header causes the Queue Proxy to perform a
// health check of itself and the user container.
Name: network.ProbeHeaderName,
Value: queue.Name,
}},
Expand All @@ -290,8 +289,8 @@ func makeQueueContainer(rev *v1.Revision, cfg *config.Config) (*corev1.Container
Image: cfg.Deployment.QueueSidecarImage,
Resources: createQueueResources(cfg.Deployment, rev.GetAnnotations(), container),
Ports: ports,
StartupProbe: makeExecProbe(startupProbe),
ReadinessProbe: readinessProbe,
StartupProbe: execProbe,
ReadinessProbe: httpProbe,
SecurityContext: queueSecurityContext,
Env: []corev1.EnvVar{{
Name: "SERVING_NAMESPACE",
Expand Down Expand Up @@ -369,7 +368,7 @@ func makeQueueContainer(rev *v1.Revision, cfg *config.Config) (*corev1.Container
Value: metrics.Domain(),
}, {
Name: "SERVING_READINESS_PROBE",
Value: probeJSON,
Value: userProbeJSON,
}, {
Name: "ENABLE_PROFILING",
Value: strconv.FormatBool(cfg.Observability.EnableProfiling),
Expand Down

0 comments on commit 793f0f9

Please # to comment.