Skip to content

Commit

Permalink
Fixes #104 (#217)
Browse files Browse the repository at this point in the history
exposed outlierDetection configuration through GTP

Signed-off-by: Shriram Sharma <shriram_sharma@intuit.com>
  • Loading branch information
shriramsharma committed May 19, 2022
1 parent 35de918 commit 059a0d5
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 69 deletions.
129 changes: 102 additions & 27 deletions admiral/pkg/apis/admiral/model/globalrouting.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions admiral/pkg/apis/admiral/model/globalrouting.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ option go_package = "model";
// weight: 10
// - region: us-east2
// weight: 90
// outlier_detection:
// base_ejection_time: 180
// consecutive_gateway_errors: 100
// interval: 60
//
// ```

Expand Down Expand Up @@ -74,6 +78,19 @@ message TrafficPolicy {
//REQUIRED: dnsPrefix that will be prefixed for the service names being generated with this traffic policy
//Ex: dnsPrefix = west => generated service name = west.stage.servicename.global
string dnsPrefix = 4;

message OutlierDetection {
//REQUIRED: Minimum duration of time in seconds, the endpoint will be ejected
int64 base_ejection_time = 1;
//REQUIRED: No. of consecutive failures in specified interval after which the endpoint will be ejected
uint32 consecutive_gateway_errors = 2;
//REQUIRED: Time interval between ejection sweep analysis
int64 interval = 3;
}

//OPTIONAL: to configure the outlierDetection in DestinationRule
OutlierDetection outlier_detection = 5;

}

message TrafficGroup {
Expand Down
31 changes: 27 additions & 4 deletions admiral/pkg/clusters/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import (
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const ROLLOUT_POD_HASH_LABEL string = "rollouts-pod-template-hash"
const (
ROLLOUT_POD_HASH_LABEL string = "rollouts-pod-template-hash"
DefaultBaseEjectionTime int64 = 300
DefaultConsecutiveGatewayErrors uint32 = 50
DefaultInterval int64 = 60
)

type ServiceEntryHandler struct {
RemoteRegistry *RemoteRegistry
Expand Down Expand Up @@ -106,9 +111,27 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP
func getOutlierDetection(se *v1alpha32.ServiceEntry, locality string, gtpTrafficPolicy *model.TrafficPolicy) *v1alpha32.OutlierDetection {

outlierDetection := &v1alpha32.OutlierDetection{
BaseEjectionTime: &types.Duration{Seconds: 300},
ConsecutiveGatewayErrors: &types.UInt32Value{Value: uint32(50)},
Interval: &types.Duration{Seconds: 60},
BaseEjectionTime: &types.Duration{Seconds: DefaultBaseEjectionTime},
ConsecutiveGatewayErrors: &types.UInt32Value{Value: DefaultConsecutiveGatewayErrors},
Interval: &types.Duration{Seconds: DefaultInterval},
}

if gtpTrafficPolicy != nil && gtpTrafficPolicy.OutlierDetection != nil {
if gtpTrafficPolicy.OutlierDetection.BaseEjectionTime > 0 {
outlierDetection.BaseEjectionTime = &types.Duration{
Seconds: gtpTrafficPolicy.OutlierDetection.BaseEjectionTime,
}
}
if gtpTrafficPolicy.OutlierDetection.ConsecutiveGatewayErrors > 0 {
outlierDetection.ConsecutiveGatewayErrors = &types.UInt32Value{
Value: gtpTrafficPolicy.OutlierDetection.ConsecutiveGatewayErrors,
}
}
if gtpTrafficPolicy.OutlierDetection.Interval > 0 {
outlierDetection.Interval = &types.Duration{
Seconds: gtpTrafficPolicy.OutlierDetection.Interval,
}
}
}

//Scenario 1: Only one endpoint present and is local service (ends in svc.cluster.local) - no outlier detection (optimize this for headless services in future?)
Expand Down
Loading

0 comments on commit 059a0d5

Please sign in to comment.