Skip to content

Commit

Permalink
timeout validation; configurable SO_PRIORITY
Browse files Browse the repository at this point in the history
  • Loading branch information
phylake committed Mar 25, 2020
1 parent cd84f21 commit 29b8f3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions ADOBE_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ v{C major}.{C minor}.{C fix}-{A major}.{A minor}.{A fix}-adobe

# Log

## v1.1.0-2.6.0-adobe

- invalidate IRs with idle timeouts <= 0
- conditionally set SO_PRIORITY = 6

## v1.1.0-2.5.0-adobe

- set SO_PRIORITY = 6
Expand Down
15 changes: 14 additions & 1 deletion internal/dag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,14 +986,24 @@ func (b *Builder) processIngressRoutes(sw *ObjectStatusWriter, ir *ingressroutev
if d, err := ptypes.Duration(&route.IdleTimeout.Duration); err == nil {
if d > time.Hour {
r.IdleTimeout = ptypes.DurationProto(time.Hour)
} else if d <= 0 {
sw.SetInvalid("route %q: idle timeout can not be disabled", route.Match)
return
} else {
r.IdleTimeout = &route.IdleTimeout.Duration
}
}
}

if route.Timeout != nil {
r.Timeout = &route.Timeout.Duration
if d, err := ptypes.Duration(&route.Timeout.Duration); err == nil {
if d < 0 {
sw.SetInvalid("route %q: timeout value must be >= 0", route.Match)
return
} else {
r.Timeout = &route.Timeout.Duration
}
}
}

for _, service := range route.Services {
Expand Down Expand Up @@ -1032,6 +1042,9 @@ func (b *Builder) processIngressRoutes(sw *ObjectStatusWriter, ir *ingressroutev
if d, err := ptypes.Duration(&service.IdleTimeout.Duration); err == nil {
if d > time.Hour {
c.IdleTimeout = ptypes.DurationProto(time.Hour)
} else if d <= 0 {
sw.SetInvalid("route: %q service %q: idle timeout can not be disabled", route.Match, service.Name)
return
} else {
c.IdleTimeout = &service.IdleTimeout.Duration
}
Expand Down
19 changes: 13 additions & 6 deletions internal/envoy/listener_adobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ func socketOptions() (opts []*envoy_api_v2_core.SocketOption) {

opts = make([]*envoy_api_v2_core.SocketOption, 0)

opts = append(opts, &envoy_api_v2_core.SocketOption{
Level: SOL_SOCKET,
Name: SO_PRIORITY,
Value: &envoy_api_v2_core.SocketOption_IntValue{6},
State: envoy_api_v2_core.SocketOption_STATE_PREBIND,
})
if enabled, err := strconv.ParseBool(os.Getenv("SO_PRIORITY")); enabled && err == nil {
opts = append(opts, &envoy_api_v2_core.SocketOption{
Level: SOL_SOCKET,
Name: SO_PRIORITY,
Value: &envoy_api_v2_core.SocketOption_IntValue{6},
State: envoy_api_v2_core.SocketOption_STATE_PREBIND,
})
}

if enabled, err := strconv.ParseBool(os.Getenv("TCP_KEEPALIVE_ENABLED")); enabled && err == nil {

Expand Down Expand Up @@ -106,5 +108,10 @@ func socketOptions() (opts []*envoy_api_v2_core.SocketOption) {
})
}
}

if len(opts) == 0 {
opts = nil
}

return
}

0 comments on commit 29b8f3d

Please sign in to comment.