Skip to content

Revision timeoutSecond should only apply until the first byte of the response #2582

@tanzeeb

Description

@tanzeeb

Expected Behavior

When I deploy an application with the timeoutSeconds, I expect the timeout to only apply from when the request is sent until the response response begins.

Actual Behavior

When I deploy an application with the timeoutSeconds set, eg. "45s", I the timeout applies from when the request is sent until the response response ends.

Steps to Reproduce the Problem

  1. Modify the knative/serving/test/test_images/timeout application as follows:
func handler(w http.ResponseWriter, r *http.Request) {
	before, _ := strconv.Atoi(r.URL.Query().Get("before"))
	after, _ := strconv.Atoi(r.URL.Query().Get("after"))
	time.Sleep(time.Duration(before) * time.Second)
        fmt.Fprintf(w, "Begin after %d seconds", before)
        time.Sleep(time.Duration(after) * time.Second)
	fmt.Fprintf(w, "End after %d seconds", after)
}
  1. Deploy with the following service.yaml:
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: timeout
  namespace: default
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          timeoutSeconds: "30s"
          container:
            image: github.com/knative/serving/test/test_images/timeout
  1. Curl the service a query parameter less than the timeout ?before=15&after=45. This will fail, but should not fail.
  2. Curl the service a query parameter less than the timeout ?before=45&after=15. This will fail, and should fail.

Additional Info

The current implementation uses http.TimeoutHandler, which will buffer the entire request. This poses problems for streaming requests, eg. gRPC in #2539.

cc @tcnghia @mattmoor @evankanderson

Metadata

Metadata

Labels

area/APIAPI objects and controllersarea/networkingkind/bugCategorizes issue or PR as related to a bug.kind/specDiscussion of how a feature should be exposed to customers.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions