From a7e16f1a71b2e62d5e222f408268d49af31612d8 Mon Sep 17 00:00:00 2001 From: lostbean Date: Thu, 26 Sep 2024 07:44:48 -0300 Subject: [PATCH] fix check correct ingress ref --- kontrol-service/engine/flow/render.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kontrol-service/engine/flow/render.go b/kontrol-service/engine/flow/render.go index 03a16f2..6728f23 100644 --- a/kontrol-service/engine/flow/render.go +++ b/kontrol-service/engine/flow/render.go @@ -56,13 +56,17 @@ func RenderClusterResources(clusterTopology *resolved.ClusterTopology, namespace targeIngressServices := lo.Uniq( lo.FlatMap(clusterTopology.Ingress.Ingresses, func(ing net.Ingress, _ int) []string { return lo.FlatMap(ing.Spec.Rules, func(rule net.IngressRule, _ int) []string { - return lo.Map(rule.HTTP.Paths, func(path net.HTTPIngressPath, _ int) string { + return lo.FilterMap(rule.HTTP.Paths, func(path net.HTTPIngressPath, _ int) (string, bool) { // TODO: we are ignoring the namespace from the path, should we? targetNS := namespace if ing.Namespace != "" { targetNS = string(ing.Namespace) } - return fmt.Sprintf("%s/%s", targetNS, string(path.Backend.Resource.Name)) + if path.Backend.Service == nil { + logrus.Errorf("Ingress %v has a nil backend service", ing.Name) + return "", false + } + return fmt.Sprintf("%s/%s", targetNS, string(path.Backend.Service.Name)), true }) }) }))