Add terminal attribute to request hash. (#4292)

Add a terminal attribute to request hash policy.

Think about a case where customers want to hash on a cookie if it's present but if it's not present, do best-effort sticky based on something like IP so the customer has a stable hash.

This "terminal" allows request hashing to have the ability of "if A not working, fallback to B.", which also saves time to generate the hash.

Changes:
* Add a terminal attribute to HashMethod, which shortcircuit the hash generating process if a policy is marked terminal and there is a hash computed already.

Signed-off-by: Xin Zhuang stevenzzz@google.com

Description: Add terminal attribute to request hash.
Risk Level: Low
Testing: unit tests.

Mirrored from https://github.com/envoyproxy/envoy @ ee710d0a92b476cc3d7a0f99f11b62675d1a4e01
pull/620/head
data-plane-api(CircleCI) 6 years ago
parent a29483497d
commit baebf39fb2
  1. 25
      envoy/api/v2/route/route.proto

@ -585,6 +585,27 @@ message RouteAction {
// Connection properties hash policy.
ConnectionProperties connection_properties = 3;
}
// The flag that shortcircuits the hash computing. This field provides a
// 'fallback' style of configuration: "if a terminal policy doesn't work,
// fallback to rest of the policy list", it saves time when the terminal
// policy works.
//
// If true, and there is already a hash computed, ignore rest of the
// list of hash polices.
// For example, if the following hash methods are configured:
//
// ========= ========
// specifier terminal
// ========= ========
// Header A true
// Header B false
// Header C false
// ========= ========
//
// The generateHash process ends if policy "header A" generates a hash, as
// it's a terminal policy.
bool terminal = 4;
}
// Specifies a list of hash policies to use for ring hash load balancing. Each
@ -596,7 +617,9 @@ message RouteAction {
// hash policies fail to generate a hash, no hash will be produced for
// the route. In this case, the behavior is the same as if no hash policies
// were specified (i.e. the ring hash load balancer will choose a random
// backend).
// backend). If a hash policy has the "terminal" attribute set to true, and
// there is already a hash generated, the hash is returned immediately,
// ignoring the rest of the hash policy list.
repeated HashPolicy hash_policy = 15;
// Indicates that a HTTP/1.1 client connection to this particular route is allowed to

Loading…
Cancel
Save