Skip to content

Commit

Permalink
Set DrainconnectionsOnHostRemoval to true for any cluster having heal…
Browse files Browse the repository at this point in the history
…th checks enabled

Signed-off-by: Steve Sloka <[email protected]>
  • Loading branch information
stevesloka committed Mar 3, 2019
1 parent 1f25cdd commit 8326478
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions internal/contour/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import (
"testing"
"time"

"github.com/envoyproxy/go-control-plane/envoy/api/v2"
v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
"github.com/envoyproxy/go-control-plane/envoy/api/v2/cluster"
"github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
"github.com/google/go-cmp/cmp"
ingressroutev1 "github.com/heptio/contour/apis/contour/v1beta1"
"github.com/heptio/contour/internal/envoy"
"github.com/heptio/contour/internal/metrics"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -308,7 +308,8 @@ func TestClusterVisit(t *testing.T) {
},
},
}},
CommonLbConfig: envoy.ClusterCommonLBConfig(),
CommonLbConfig: envoy.ClusterCommonLBConfig(),
DrainConnectionsOnHostRemoval: true,
},
),
},
Expand Down Expand Up @@ -370,7 +371,8 @@ func TestClusterVisit(t *testing.T) {
},
},
}},
CommonLbConfig: envoy.ClusterCommonLBConfig(),
CommonLbConfig: envoy.ClusterCommonLBConfig(),
DrainConnectionsOnHostRemoval: true,
},
),
},
Expand Down
8 changes: 7 additions & 1 deletion internal/envoy/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

"github.com/envoyproxy/go-control-plane/envoy/api/v2"
v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
envoy_cluster "github.com/envoyproxy/go-control-plane/envoy/api/v2/cluster"
"github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
envoy_type "github.com/envoyproxy/go-control-plane/envoy/type"
Expand Down Expand Up @@ -64,6 +64,12 @@ func cluster(service *dag.TCPService) *v2.Cluster {
CommonLbConfig: ClusterCommonLBConfig(),
HealthChecks: edshealthcheck(service),
}

// Drain connections immediately if using healthchecks and the endpoint is known to be removed
if service.HealthCheck != nil {
c.DrainConnectionsOnHostRemoval = true
}

if anyPositive(service.MaxConnections, service.MaxPendingRequests, service.MaxRequests, service.MaxRetries) {
c.CircuitBreakers = &envoy_cluster.CircuitBreakers{
Thresholds: []*envoy_cluster.CircuitBreakers_Thresholds{{
Expand Down

0 comments on commit 8326478

Please sign in to comment.