Skip to content

Commit

Permalink
Fix 503 http error when handling incoming webhook requests (#1747)
Browse files Browse the repository at this point in the history
Incoming webhook request especially involving GitHub Apps with many
installations take minutes, so the existing http handler timeout of 10s
was causing 503 failures. Once increased, OpenShift deployments were
failing with http 504 (Gateway Time-out) because of the default 30s
timeout on the pipelines-as-code-controller route.
  • Loading branch information
enarha authored Sep 3, 2024
1 parent 5c88f74 commit 7bb525f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/openshift/10-routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
annotations:
haproxy.router.openshift.io/timeout: 600s
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: default
Expand Down
7 changes: 6 additions & 1 deletion pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import (

const globalAdapterPort = "8080"

// For incoming webhook requests and GitHub Apps with many installations the handler takes long
// e.g GitHub App with ~400 installations, it takes ~180s. For OpenShift deployments this also
// requires matching timeout on the pipelines-as-code-controller route (default is 30s).
const httpTimeoutHandler = 600 * time.Second

type envConfig struct {
adapter.EnvConfig
}
Expand Down Expand Up @@ -87,7 +92,7 @@ func (l *listener) Start(ctx context.Context) error {
srv := &http.Server{
Addr: ":" + adapterPort,
Handler: http.TimeoutHandler(mux,
10*time.Second, "Listener Timeout!\n"),
httpTimeoutHandler, "Listener Timeout!\n"),
}

enabled, tlsCertFile, tlsKeyFile := l.isTLSEnabled()
Expand Down

0 comments on commit 7bb525f

Please sign in to comment.