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

use drainer from pkg instead of our own health #3917

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
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
46 changes: 0 additions & 46 deletions pkg/health/probes.go

This file was deleted.

57 changes: 0 additions & 57 deletions pkg/health/probes_test.go

This file was deleted.

12 changes: 8 additions & 4 deletions pkg/kncloudevents/message_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"go.opencensus.io/plugin/ochttp"
"knative.dev/pkg/network/handlers"
"knative.dev/pkg/tracing/propagation/tracecontextb3"
)

Expand All @@ -33,7 +34,6 @@ const (
type HttpMessageReceiver struct {
port int

handler nethttp.Handler
server *nethttp.Server
listener net.Listener
}
Expand All @@ -51,11 +51,12 @@ func (recv *HttpMessageReceiver) StartListen(ctx context.Context, handler nethtt
return err
}

recv.handler = CreateHandler(handler)

drainer := &handlers.Drainer{
Inner: CreateHandler(handler),
}
recv.server = &nethttp.Server{
Addr: recv.listener.Addr().String(),
Handler: recv.handler,
Handler: drainer,
}

errChan := make(chan error, 1)
Expand All @@ -66,6 +67,9 @@ func (recv *HttpMessageReceiver) StartListen(ctx context.Context, handler nethtt
// wait for the server to return or ctx.Done().
select {
case <-ctx.Done():
// As we start to shutdown, disable keep-alives to avoid clients hanging onto connections.
recv.server.SetKeepAlivesEnabled(false)
drainer.Drain()
ctx, cancel := context.WithTimeout(context.Background(), getShutdownTimeout(ctx))
defer cancel()
err := recv.server.Shutdown(ctx)
Expand Down
3 changes: 1 addition & 2 deletions pkg/mtbroker/filter/filter_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
eventinglisters "knative.dev/eventing/pkg/client/listers/eventing/v1beta1"
"knative.dev/eventing/pkg/health"
"knative.dev/eventing/pkg/kncloudevents"
broker "knative.dev/eventing/pkg/mtbroker"
"knative.dev/eventing/pkg/reconciler/sugar/trigger/path"
Expand Down Expand Up @@ -102,7 +101,7 @@ func NewHandler(logger *zap.Logger, triggerLister eventinglisters.TriggerLister,
//
// This method will block until ctx is done.
func (h *Handler) Start(ctx context.Context) error {
return h.receiver.StartListen(ctx, health.WithLivenessCheck(health.WithReadinessCheck(h)))
return h.receiver.StartListen(ctx, h)
}

// 1. validate request
Expand Down
3 changes: 1 addition & 2 deletions pkg/mtbroker/ingress/ingress_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"knative.dev/eventing/pkg/apis/eventing"
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
eventinglisters "knative.dev/eventing/pkg/client/listers/eventing/v1"
"knative.dev/eventing/pkg/health"
"knative.dev/eventing/pkg/kncloudevents"
broker "knative.dev/eventing/pkg/mtbroker"
"knative.dev/eventing/pkg/tracing"
Expand Down Expand Up @@ -97,7 +96,7 @@ func (h *Handler) getChannelAddress(name, namespace string) (string, error) {
}

func (h *Handler) Start(ctx context.Context) error {
return h.Receiver.StartListen(ctx, health.WithLivenessCheck(h))
return h.Receiver.StartListen(ctx, h)
}

func (h *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
Expand Down