Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick: Disable keep-alive for cloud-event connections #3215

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/reconciler/events/cloudevent/cloudeventclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cloudevent

import (
"context"
"net/http"

cloudevents "github.com/cloudevents/sdk-go/v2"
"k8s.io/client-go/rest"
Expand All @@ -35,11 +36,19 @@ type CECKey struct{}
func withCloudEventClient(ctx context.Context, cfg *rest.Config) context.Context {
logger := logging.FromContext(ctx)

p, err := cloudevents.NewHTTP()
// When KeepAlive is enabled the connections are not reused - see
// Bug https://github.com/tektoncd/pipeline/issues/3190. This causes the
// number of connections to keep growing, even if when we limit max idle
// connections in the transport.
// TODO(afrittoli) Re-enable keep alive and ensure connections are reused
// See feature https://github.com/tektoncd/pipeline/issues/3204
var useOnceTransport http.RoundTripper = &http.Transport{
DisableKeepAlives: true,
}

p, err := cloudevents.NewHTTP(cloudevents.WithRoundTripper(useOnceTransport))
if err != nil {
logger.Panicf("Error creating the cloudevents http protocol: %s", err)
return ctx
}

cloudEventClient, err := cloudevents.NewClient(p, cloudevents.WithUUIDs(), cloudevents.WithTimeNow())
Expand Down