[READ-ONLY] Mirror of https://github.com/andrioid/reproduce-cloud-run-bug. Temporary repo. Will remove later.
0

Configure Feed

Select the types of activity you want to include in your feed.

removing gocloud.dev dependency since I can reproduce without it

+42 -29
+1 -1
README.md
··· 22 22 23 23 ``` 24 24 gcloud builds submit --tag eu.gcr.io/redia-internal/reproduce-cloud-run-bug 25 - gcloud beta run deploy --image eu.gcr.io/redia-internal/reproduce-clound-run-bug --platform managed 25 + gcloud beta run deploy --image eu.gcr.io/redia-internal/reproduce-cloud-run-bug --platform managed 26 26 ``` 27 27 28 28 # Reproducing
+41 -28
main.go
··· 27 27 } 28 28 } 29 29 30 - type PooWriter struct{} 30 + // Handler just writes some bytes to a file 31 + func Handler(w http.ResponseWriter, r *http.Request) { 32 + w.Header().Set("Content-Type", "application/octet-stream") 33 + w.Header().Set("Content-Disposition", "inline; filename=\"test.dat\"") 31 34 32 - func (p *PooWriter) Write(b []byte) (int, error) { 33 - return 0, nil 35 + u, err := url.Parse(r.RequestURI) 36 + if err != nil { 37 + http.Error(w, "failed to parse query", http.StatusInternalServerError) 38 + } 39 + size, err := strconv.Atoi(u.Query().Get("size")) 40 + if err != nil { 41 + http.Error(w, "failed to parse size", http.StatusInternalServerError) 42 + } 43 + if size == 0 { 44 + size = 100 45 + } 46 + 47 + // TODO: Replace "A" with poop emoji and divide by 4 48 + for i := 0; i < size*1024*1024; i++ { 49 + w.Write([]byte("A")) 50 + } 51 + return 34 52 } 35 53 36 - func main() { 54 + func listenVanilla() { 55 + args := parseConfig() 56 + fmt.Printf("Vanilla listening on port %d...\n", args.port) 57 + http.HandleFunc("/", Handler) 58 + err := http.ListenAndServe( 59 + fmt.Sprintf(":%d", args.port), 60 + nil, 61 + ) 62 + 63 + if err != nil { 64 + log.Fatal(err) 65 + } 66 + } 37 67 68 + func listenCloud() { 38 69 args := parseConfig() 39 70 // Enable tracing for a small percentage of our requests by default 40 71 var samplingPolicy trace.Sampler ··· 49 80 } 50 81 srv := server.New(http.DefaultServeMux, options) 51 82 52 - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 53 - w.Header().Set("Content-Type", "application/octet-stream") 54 - w.Header().Set("Content-Disposition", "inline; filename=\"test.dat\"") 55 - 56 - u, err := url.Parse(r.RequestURI) 57 - if err != nil { 58 - http.Error(w, "failed to parse query", http.StatusInternalServerError) 59 - } 60 - size, err := strconv.Atoi(u.Query().Get("size")) 61 - if err != nil { 62 - http.Error(w, "failed to parse size", http.StatusInternalServerError) 63 - } 64 - if size == 0 { 65 - size = 100 66 - } 83 + http.HandleFunc("/", Handler) 67 84 68 - for i := 0; i < size*1024*1024; i++ { 69 - w.Write([]byte("A")) 70 - } 71 - return 72 - 73 - //fmt.Fprintf(w, "Hello %d", size) 74 - }) 85 + fmt.Printf("Cloud listening on port %d...\n", args.port) 86 + log.Fatal(srv.ListenAndServe(fmt.Sprintf(":%d", args.port))) 87 + } 75 88 76 - fmt.Printf("Listening on port %d...\n", args.port) 77 - log.Fatal(srv.ListenAndServe(fmt.Sprintf(":%d", args.port))) 89 + func main() { 90 + listenVanilla() 78 91 }