Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Dorosh <kevin.dorosh@solo.io>
  • Loading branch information
Kevin Dorosh committed Jul 5, 2023
1 parent 929addf commit 0eb683e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
7 changes: 4 additions & 3 deletions pilot/pkg/serviceregistry/kube/controller/ambientindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (c *Controller) setupIndex() *AmbientIndex {
updates := sets.New[model.ConfigKey]()

if event != model.EventAdd {
c.cleanupOldServiceEntryVips(svc, updates)
c.cleanupOldWorkloadEntriesInlinedOnServiceEntry(svc, updates)
}

serviceEntryNamespacedName := types.NamespacedName{
Expand All @@ -445,8 +445,9 @@ func (c *Controller) setupIndex() *AmbientIndex {

// Update indexes
if event == model.EventDelete {
// servicesMap is used when cleaning up old VIPs (e.g. `ServiceEntry.endpoints`) so we must
// delete this after we clean up VIPs
// servicesMap is used when cleaning up old WEs inlined on a SE (i.e., `ServiceEntry.endpoints`)
// so we must delete this after we clean up the old WEs. That way we don't miss any auto-allocated
// VIPs during cleanup on the idx.byWorkloadEntry[networkAddr] map
delete(idx.servicesMap, serviceEntryNamespacedName)
} else {
// servicesMap is used when constructing workloads so it must be up to date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (c *Controller) generateServiceEntryUID(svcEntryNamespace, svcEntryName, ad
return c.clusterID.String() + "/networking.istio.io/ServiceEntry/" + svcEntryNamespace + "/" + svcEntryName + "/" + addr
}

func (c *Controller) cleanupOldServiceEntryVips(svc *model.Service, updates sets.Set[model.ConfigKey]) {
func (c *Controller) cleanupOldWorkloadEntriesInlinedOnServiceEntry(svc *model.Service, updates sets.Set[model.ConfigKey]) {
a := c.ambientIndex
nsName := types.NamespacedName{
Name: svc.Attributes.ServiceEntryName,
Expand All @@ -467,22 +467,6 @@ func (c *Controller) cleanupOldServiceEntryVips(svc *model.Service, updates sets
delete(a.byUID, oldUID)
}
}

// we also need to remove the VIP from any pod that has it (e.g. from service entry `workloadSelector`)
for nwAddr := range a.byPod {
wli, ok := a.byPod[nwAddr]
if !ok {
continue
}
_, found := wli.Services[namespacedHostname(oldServiceEntry.Attributes.Namespace, oldServiceEntry.Hostname.String())]
if found {
updates.Insert(model.ConfigKey{Kind: kind.Address, Name: wli.ResourceName()})
for _, networkAddr := range networkAddressFromWorkload(wli) {
delete(a.byPod, networkAddr)
}
delete(a.byUID[wli.Uid].Services, namespacedHostname(oldServiceEntry.Attributes.Namespace, oldServiceEntry.Hostname.String()))
}
}
}
}

Expand Down

0 comments on commit 0eb683e

Please sign in to comment.