Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
fix: fallback to baseline in GetNetIngresses (#7)
Browse files Browse the repository at this point in the history
* fix fallback to baseline in GetNetIngresses

* fix after lint warnings
  • Loading branch information
leoporoli authored Oct 16, 2024
1 parent e7a3b53 commit 7c10b56
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions kardinal/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7c10b56

Please sign in to comment.