Code change:
count := 0 for { <-timer.C <del> n, err := w.Write([]byte("w")) </del> <ins> n, err := w.Write(responseBody[count : count+1]) </ins> if err != nil { return } flusher.Flush() count += n <del> if count == watchExpectSendBytes { </del> <ins> if count == len(responseBody) { </ins> return } } }) <del> mux := http.NewServeMux() mux.Handle(urlNormal, WithProbabilisticGoaway(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { </del> <ins> getHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { </ins> w.WriteHeader(http.StatusOK) <del> w.Write([]byte("hello")) </del> <ins> w.Write(responseBody) </ins> return <del> }), 0)) mux.Handle(urlWatch, WithProbabilisticGoaway(watchHandler, 0)) mux.Handle(urlGoaway, WithProbabilisticGoaway(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { </del> <ins> }) postHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { reqBody, err := ioutil.ReadAll(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } if !reflect.DeepEqual(requestPostBody, reqBody) { http.Error(w, fmt.Sprintf("expect request body: %s, got: %s", requestPostBody, reqBody), http.StatusBadRequest) return } </ins> w.WriteHeader(http.StatusOK) <del> w.Write([]byte("hello")) </del> <ins> w.Write(responseBody) </ins> return <del> }), 1)) </del> <ins> }) mux := http.NewServeMux() mux.Handle(urlGet, WithProbabilisticGoaway(getHandler, 0)) mux.Handle(urlPost, WithProbabilisticGoaway(postHandler, 0)) mux.Handle(urlWatch, WithProbabilisticGoaway(watchHandler, 0)) mux.Handle(urlGetWithGoaway, WithProbabilisticGoaway(getHandler, 1)) mux.Handle(urlPostWithGoaway, WithProbabilisticGoaway(postHandler, 1)) </ins> mux.Handle(urlWatchWithGoaway, WithProbabilisticGoaway(watchHandler, 1)) s := httptest.NewUnstartedServer(mux)

Related discussion:
text: What happened: We enabled feature in our large-scale cluster, and we found client(Kubelet) may got error(500 http code response) like after received GOAWAY frame. I had already re-produce this bug and open an in golang repo. So far I think this bug only occur with a small probability when client request server in high concurrency use a same httpclient instance, and it's a golang sdk bug in http client. Before I solved this issue, I suggest do NOT enable GOAWAY() feature. As it's a golang sdk bug(currently I known and doubt) in http client, revert GOAWAY feature(codes) is not necessary.
cc
/sig api-machinery
Thanks for the report.
Based on not setting the field, I think it defaults that way, so that's good. We will leave the option and filter so that when golang updates its client, we will have a simple way to turn it on and execute it.
Sure. I am trying to fix the golang http client issue and will update progress at . After golang http client issue fixed, I will add more concurrent test cases to see if there are any other bugs may occur by GOAWAY feature. BTW, we still enable GOAWAY feature in our production cluster, because there is no any evidence told us this error will influence SLO, as all most components(kubelet, controller-manager, scheduler) is controller work mode and will re-try after got error. /assign
Golang version or required, which will release at 07/01/2020.
Kubernetes v1.19(or master branch) now is using golang 1.15, and golang 1.15 has fixed the issue. And is on going. Let me add more test cases to ensure the error will not happen again.
I think we should re-open this issue because of . /re-open