Skip to content

Commit

Permalink
Fix panic in test
Browse files Browse the repository at this point in the history
Signed-off-by: Kateryna Nezdolii <kateryna.nezdolii@docker.com>
  • Loading branch information
nezdolik committed Jan 28, 2025
1 parent 7e6e73b commit 026c6c4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/xds/translator/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,25 @@ func buildXdsCluster(args *xdsClusterArgs) *clusterv3.Cluster {
dnsLookupFamily = clusterv3.Cluster_ALL
}
}
panicThreshold := &xdstype.Percent{
Value: float64(50),
}
if args.healthCheck.PanicThreshold != nil {
panicThreshold.Value = float64(*args.healthCheck.PanicThreshold)
}

cluster := &clusterv3.Cluster{
Name: args.name,
DnsLookupFamily: dnsLookupFamily,
CommonLbConfig: &clusterv3.Cluster_CommonLbConfig{
LocalityConfigSpecifier: &clusterv3.Cluster_CommonLbConfig_LocalityWeightedLbConfig_{
LocalityWeightedLbConfig: &clusterv3.Cluster_CommonLbConfig_LocalityWeightedLbConfig{},
},
HealthyPanicThreshold: panicThreshold,
},
PerConnectionBufferLimitBytes: buildBackandConnectionBufferLimitBytes(args.backendConnection),
}

// 50% is the Envoy default value for panic threshold. No need to explicitly set it in this case.
if args.healthCheck != nil && args.healthCheck.PanicThreshold != nil && *args.healthCheck.PanicThreshold != 50 {
cluster.CommonLbConfig.HealthyPanicThreshold = &xdstype.Percent{
Value: float64(*args.healthCheck.PanicThreshold),
}
}

cluster.ConnectTimeout = buildConnectTimeout(args.timeout)

// Initialize TrackClusterStats if any metrics are enabled
Expand Down

0 comments on commit 026c6c4

Please sign in to comment.