From 7ba3e8d94eb84a3441a9c7008cc3c4ed5cf8db90 Mon Sep 17 00:00:00 2001 From: GLYASAI Date: Mon, 17 Dec 2018 18:32:46 +0800 Subject: [PATCH] [DEL] remove CHash --- db/model/gateway.go | 3 --- worker/appm/conversion/gateway.go | 12 ++++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/db/model/gateway.go b/db/model/gateway.go index 0b51a1515..472d150e0 100644 --- a/db/model/gateway.go +++ b/db/model/gateway.go @@ -46,9 +46,6 @@ var HTTPToHTTPS RuleExtensionKey = "httptohttps" // LBType load balancer type var LBType RuleExtensionKey = "lb-type" -// CHash consistent hashing -var CHash RuleExtensionKey = "chash" - // RuleExtension contains rule extensions for http rule or tcp rule type RuleExtension struct { Model diff --git a/worker/appm/conversion/gateway.go b/worker/appm/conversion/gateway.go index cf52fa392..3827900c7 100644 --- a/worker/appm/conversion/gateway.go +++ b/worker/appm/conversion/gateway.go @@ -347,9 +347,17 @@ func (a *AppServiceBuild) applyHTTPRule(rule *model.HTTPRule, port *model.Tenant } annos[parser.GetAnnotationWithPrefix("force-ssl-redirect")] = "true" case string(model.LBType): + if strings.HasPrefix(extension.Value, "upstream-hash-by") { + s := strings.Split(extension.Value, ":") + if len(s) < 2 { + logrus.Warningf("invalid extension value for upstream-hash-by: %s", extension.Value) + break + } + annos[parser.GetAnnotationWithPrefix("upstream-hash-by")] = s[1] + break + } annos[parser.GetAnnotationWithPrefix("lb-type")] = extension.Value - case string(model.CHash): - annos[parser.GetAnnotationWithPrefix("upstream-hash-by")] = extension.Value + default: logrus.Warnf("Unexpected RuleExtension Key: %s", extension.Key) }