Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix aeraki memory leak when node info update #399

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions internal/controller/istio/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ func (c *Controller) Run(stop <-chan struct{}) {
go c.configCache.Run(stop)
go func() {
c.connectIstio()
for {
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
time.Sleep(30 * time.Minute)
c.reconnectIstio()
}
}()
}

Expand Down Expand Up @@ -125,9 +121,10 @@ func (c *Controller) connectIstio() {
sm, err := c.newSecretManager()
if err != nil {
controllerLog.Errorf("failed to create SecretManager %s %v", c.options.IstiodAddr, err)
} else {
config.SecretManager = sm
time.Sleep(5 * time.Second)
continue
shencurl521 marked this conversation as resolved.
Show resolved Hide resolved
}
config.SecretManager = sm
}
c.xdsMCP, err = adsc.New(c.options.IstiodAddr, &config)
if err != nil {
Expand All @@ -139,6 +136,7 @@ func (c *Controller) connectIstio() {
c.xdsMCP.Store = configController
if err = c.xdsMCP.Run(); err != nil {
controllerLog.Errorf("adsc: failed running %v", err)
c.closeConnection()
time.Sleep(5 * time.Second)
continue
}
Expand Down
4 changes: 4 additions & 0 deletions internal/xds/cache_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ func (c *CacheMgr) initNode(_ string) {
c.pushChannel <- istiomodel.EventUpdate
}

func (c *CacheMgr) clearNode(node string) {
c.routeCache.ClearSnapshot(node)
}

func (c *CacheMgr) hasNode(node string) bool {
if _, err := c.routeCache.GetSnapshot(node); err != nil {
return false
Expand Down
1 change: 1 addition & 0 deletions internal/xds/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (cb *callbacks) OnStreamOpen(_ context.Context, id int64, typ string) error
}
func (cb *callbacks) OnStreamClosed(id int64, node *core.Node) {
xdsLog.Infof("node %s stream %d closed\n", node.Id, id)
cb.cacheMgr.clearNode(node.Id)
}

func (cb *callbacks) OnDeltaStreamOpen(_ context.Context, id int64, typ string) error {
Expand Down
1 change: 1 addition & 0 deletions internal/xds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type cacheMgr interface {
initNode(node string)
hasNode(node string) bool
cache() cachev3.SnapshotCache
clearNode(node string)
}

// Server serves xDS resources to Envoy sidecars
Expand Down
Loading