From 9da0ade91424c02c9ac320076280c0c43fb26170 Mon Sep 17 00:00:00 2001 From: Oilbeater Date: Fri, 23 Mar 2018 19:08:42 +0800 Subject: [PATCH] fix: empty ingress path (#2244) If the origin ingress rule has no field `path`, the default value will be an empty string which will cause issues when rendering template as other place will use `/` as the default value. Set the default value of path to `/` when retrieve ingress rules from api-server. Thie will fix https://github.com/kubernetes/ingress-nginx/issues/1980 --- internal/ingress/controller/store/store.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/ingress/controller/store/store.go b/internal/ingress/controller/store/store.go index a45a5d57b..facf079fa 100644 --- a/internal/ingress/controller/store/store.go +++ b/internal/ingress/controller/store/store.go @@ -111,6 +111,7 @@ const ( DeleteEvent EventType = "DELETE" // ConfigurationEvent event associated when a configuration object is created or updated ConfigurationEvent EventType = "CONFIGURATION" + slash = "/" ) // Event holds the context of an event @@ -516,7 +517,7 @@ func (s k8sStore) GetService(key string) (*apiv1.Service, error) { return s.listers.Service.ByKey(key) } -// GetSecret returns an Ingress using the namespace and name as key +// GetIngress returns an Ingress using the namespace and name as key func (s k8sStore) GetIngress(key string) (*extensions.Ingress, error) { return s.listers.Ingress.ByKey(key) } @@ -530,7 +531,13 @@ func (s k8sStore) ListIngresses() []*extensions.Ingress { if !class.IsValid(ing) { continue } - + for ri, rule := range ing.Spec.Rules { + for pi, path := range rule.HTTP.Paths { + if path.Path == "" { + ing.Spec.Rules[ri].HTTP.Paths[pi].Path = slash + } + } + } ingresses = append(ingresses, ing) }