Merge pull request #3341 from Shopify/canary_upstream

Add canary annotation and alternative backends for traffic shaping
This commit is contained in:
k8s-ci-robot 2018-11-06 12:22:16 -08:00 committed by GitHub
commit 17cad51e47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 859 additions and 23 deletions

View file

@ -6,7 +6,10 @@ local _M = balancer_resty:new({ factory = resty_chash, name = "chash" })
function _M.new(self, backend)
local nodes = util.get_nodes(backend.endpoints)
local o = { instance = self.factory:new(nodes), hash_by = backend["upstream-hash-by"] }
local o = {
instance = self.factory:new(nodes),
hash_by = backend["upstream-hash-by"],
}
setmetatable(o, self)
self.__index = self
return o

View file

@ -102,6 +102,9 @@ function _M.after_balance(_)
end
function _M.sync(self, backend)
self.traffic_shaping_policy = backend.trafficShapingPolicy
self.alternative_backends = backend.alternativeBackends
local changed = not util.deep_compare(self.peers, backend.endpoints)
if not changed then
return
@ -115,7 +118,9 @@ function _M.sync(self, backend)
end
function _M.new(self, backend)
local o = { peers = backend.endpoints }
local o = {
peers = backend.endpoints,
}
setmetatable(o, self)
self.__index = self
return o

View file

@ -10,6 +10,9 @@ function _M.new(self, o)
end
function _M.sync(self, backend)
self.traffic_shaping_policy = backend.trafficShapingPolicy
self.alternative_backends = backend.alternativeBackends
local nodes = util.get_nodes(backend.endpoints)
local changed = not util.deep_compare(self.instance.nodes, nodes)
if not changed then

View file

@ -6,7 +6,9 @@ local _M = balancer_resty:new({ factory = resty_roundrobin, name = "round_robin"
function _M.new(self, backend)
local nodes = util.get_nodes(backend.endpoints)
local o = { instance = self.factory:new(nodes) }
local o = {
instance = self.factory:new(nodes),
}
setmetatable(o, self)
self.__index = self
return o