Remove session-cookie-hash annotation
This commit is contained in:
parent
79c52cf094
commit
d3ac73be79
18 changed files with 22 additions and 189 deletions
|
|
@ -34,11 +34,6 @@ const (
|
|||
|
||||
defaultAffinityCookieName = "INGRESSCOOKIE"
|
||||
|
||||
// This is the algorithm used by nginx to generate a value for the session cookie, if
|
||||
// one isn't supplied and affinity is set to "cookie".
|
||||
annotationAffinityCookieHash = "session-cookie-hash"
|
||||
defaultAffinityCookieHash = "md5"
|
||||
|
||||
// This is used to control the cookie expires, its value is a number of seconds until the
|
||||
// cookie expires
|
||||
annotationAffinityCookieExpires = "session-cookie-expires"
|
||||
|
|
@ -52,7 +47,6 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
affinityCookieHashRegex = regexp.MustCompile(`^(index|md5|sha1)$`)
|
||||
affinityCookieExpiresRegex = regexp.MustCompile(`(^0|-?[1-9]\d*$)`)
|
||||
)
|
||||
|
||||
|
|
@ -67,8 +61,6 @@ type Config struct {
|
|||
type Cookie struct {
|
||||
// The name of the cookie that will be used in case of cookie affinity type.
|
||||
Name string `json:"name"`
|
||||
// The hash that will be used to encode the cookie in case of cookie affinity type
|
||||
Hash string `json:"hash"`
|
||||
// The time duration to control cookie expires
|
||||
Expires string `json:"expires"`
|
||||
// The number of seconds until the cookie expires
|
||||
|
|
@ -90,12 +82,6 @@ func (a affinity) cookieAffinityParse(ing *extensions.Ingress) *Cookie {
|
|||
cookie.Name = defaultAffinityCookieName
|
||||
}
|
||||
|
||||
cookie.Hash, err = parser.GetStringAnnotation(annotationAffinityCookieHash, ing)
|
||||
if err != nil || !affinityCookieHashRegex.MatchString(cookie.Hash) {
|
||||
klog.V(3).Infof("Invalid or no annotation value found in Ingress %v: %v. Setting it to default %v", ing.Name, annotationAffinityCookieHash, defaultAffinityCookieHash)
|
||||
cookie.Hash = defaultAffinityCookieHash
|
||||
}
|
||||
|
||||
cookie.Expires, err = parser.GetStringAnnotation(annotationAffinityCookieExpires, ing)
|
||||
if err != nil || !affinityCookieExpiresRegex.MatchString(cookie.Expires) {
|
||||
klog.V(3).Infof("Invalid or no annotation value found in Ingress %v: %v. Ignoring it", ing.Name, annotationAffinityCookieExpires)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ func TestIngressAffinityCookieConfig(t *testing.T) {
|
|||
|
||||
data := map[string]string{}
|
||||
data[parser.GetAnnotationWithPrefix(annotationAffinityType)] = "cookie"
|
||||
data[parser.GetAnnotationWithPrefix(annotationAffinityCookieHash)] = "sha123"
|
||||
data[parser.GetAnnotationWithPrefix(annotationAffinityCookieName)] = "INGRESSCOOKIE"
|
||||
data[parser.GetAnnotationWithPrefix(annotationAffinityCookieExpires)] = "4500"
|
||||
data[parser.GetAnnotationWithPrefix(annotationAffinityCookieMaxAge)] = "3000"
|
||||
|
|
@ -84,10 +83,6 @@ func TestIngressAffinityCookieConfig(t *testing.T) {
|
|||
t.Errorf("expected cookie as affinity but returned %v", nginxAffinity.Type)
|
||||
}
|
||||
|
||||
if nginxAffinity.Cookie.Hash != "md5" {
|
||||
t.Errorf("expected md5 as session-cookie-hash but returned %v", nginxAffinity.Cookie.Hash)
|
||||
}
|
||||
|
||||
if nginxAffinity.Cookie.Name != "INGRESSCOOKIE" {
|
||||
t.Errorf("expected route as session-cookie-name but returned %v", nginxAffinity.Cookie.Name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue