diff --git a/pkg/envoy/cluster.go b/pkg/envoy/cluster.go index b5c50d3..c576575 100644 --- a/pkg/envoy/cluster.go +++ b/pkg/envoy/cluster.go @@ -84,7 +84,7 @@ func (c *Cluster) createCluster(params ClusterParams) *api.Cluster { connectTimeout = time.Duration(params.ConnectTimeout) * time.Second } else { // set default if defined if c.DefaultsParams.ConnectTimeout > 0 { - connectTimeout = time.Duration(params.ConnectTimeout) * time.Second + connectTimeout = time.Duration(c.DefaultsParams.ConnectTimeout) * time.Second } } diff --git a/pkg/envoy/xds_test.go b/pkg/envoy/xds_test.go index d7a20f6..db4d57e 100644 --- a/pkg/envoy/xds_test.go +++ b/pkg/envoy/xds_test.go @@ -1430,7 +1430,7 @@ func TestRuleWithDefaults(t *testing.T) { return } x := NewXDS(s, "", "") - ObjectFileNames := []string{"test-cluster-connection-timeout.yaml", "test-cluster-1.yaml", "test-defaults.yaml"} + ObjectFileNames := []string{"test-cluster-connection-timeout.yaml", "test-cluster-1.yaml", "test-defaults.yaml", "test-prefixrewrite.yaml"} for _, filename := range ObjectFileNames { newItems, err := x.putObject(filename) if err != nil { @@ -1456,6 +1456,9 @@ func TestRuleWithDefaults(t *testing.T) { if cluster.Name == "test-cluster" && cluster.ConnectTimeout.Seconds != 15 { t.Errorf("Cluster Connect timeout is not 15 (got %d)", cluster.ConnectTimeout.Seconds) } + if cluster.Name == "test-prefixrewrite" && cluster.ConnectTimeout.Seconds != 15 { + t.Errorf("Cluster Connect timeout is not 15 (got %d)", cluster.ConnectTimeout.Seconds) + } } if len(checks) != 2 { t.Errorf("Clusters not found")