Skip to content

Commit

Permalink
daemon: service is deleted in cache when deleting endpints
Browse files Browse the repository at this point in the history
Fixes: #29580

Signed-off-by: xyz-li <hui0787411@163.com>
  • Loading branch information
xyz-li committed Dec 4, 2023
1 parent 5ef0f10 commit 6e30e0b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/maps/lbmap/lbmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,7 @@ func (lbmap *LBBPFMap) upsertServiceProto(p *datapathTypes.UpsertServiceParams,
return fmt.Errorf("Unable to update reverse NAT %+v => %+v: %s", revNATKey, revNATValue, err)
}

if err := updateMasterService(svcKey, svcVal.New().(ServiceValue), len(backends), int(p.ID), p.Type, p.ExtLocal, p.IntLocal, p.NatPolicy,
p.SessionAffinity, p.SessionAffinityTimeoutSec, p.CheckSourceRange, p.L7LBProxyPort, p.LoopbackHostport); err != nil {
deleteRevNatLocked(revNATKey)
return fmt.Errorf("Unable to update service %+v: %s", svcKey, err)
}

// It must be executed before updateMasterService, or the service in cache will be deleted.
if backendsOk {
for i := slot; i <= p.PrevBackendsCount; i++ {
svcKey.SetBackendSlot(i)
Expand All @@ -146,6 +141,12 @@ func (lbmap *LBBPFMap) upsertServiceProto(p *datapathTypes.UpsertServiceParams,
}
}

if err := updateMasterService(svcKey, svcVal.New().(ServiceValue), len(backends), int(p.ID), p.Type, p.ExtLocal, p.IntLocal, p.NatPolicy,
p.SessionAffinity, p.SessionAffinityTimeoutSec, p.CheckSourceRange, p.L7LBProxyPort, p.LoopbackHostport); err != nil {
deleteRevNatLocked(revNATKey)
return fmt.Errorf("Unable to update service %+v: %s", svcKey, err)
}

return nil
}

Expand Down

0 comments on commit 6e30e0b

Please sign in to comment.