From 7c10b561264afd70fa4dc44ea9f5ef2eef649af5 Mon Sep 17 00:00:00 2001 From: leoporoli Date: Wed, 16 Oct 2024 09:22:14 -0300 Subject: [PATCH] fix: fallback to baseline in GetNetIngresses (#7) * fix fallback to baseline in GetNetIngresses * fix after lint warnings --- kardinal/topology/topology.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kardinal/topology/topology.go b/kardinal/topology/topology.go index aced8fd..5ef189f 100644 --- a/kardinal/topology/topology.go +++ b/kardinal/topology/topology.go @@ -63,6 +63,16 @@ func (clusterTopology *ClusterTopology) GetServiceByVersion(namespace string, na return nil } +func (clusterTopology *ClusterTopology) GetBaselineFlowService(namespace string, name string) *Service { + for _, service := range clusterTopology.Services { + if service.Namespace == namespace && service.ServiceID == name && !service.IsManaged { + return service + } + } + + return nil +} + func (clusterTopology *ClusterTopology) UpdateWithFlow( clusterGraph graph.Graph[ServiceHash, *Service], flowId string, @@ -365,13 +375,8 @@ func (clusterTopology *ClusterTopology) GetNetIngresses() ([]*net.Ingress, []*co for _, pathOriginal := range ruleOriginal.HTTP.Paths { target := clusterTopology.GetServiceByVersion(namespace, pathOriginal.Backend.Service.Name, activeFlowID) // fallback to baseline if backend not found at the active flow - // OPERATOR-TODO - // the baseline topology (or prod topology) flow ID and flow version are equal to the namespace these three should use same value //TODO this doesn't apply for the current approach - // TODO with Kardinal-Kontrol the baselineFlowVersion and namespace where equal because Kontrol modify the Service's metadata like the 'version' label - // TODO we need to find a way to get the real version, not modified - baselineFlowVersion := namespace if target == nil { - target = clusterTopology.GetServiceByVersion(namespace, pathOriginal.Backend.Service.Name, baselineFlowVersion) + target = clusterTopology.GetBaselineFlowService(namespace, pathOriginal.Backend.Service.Name) } if target != nil { path := *pathOriginal.DeepCopy()