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

remove ipsByNs cache #130

Merged
merged 1 commit into from
Oct 1, 2024
Merged
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
22 changes: 5 additions & 17 deletions containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ type Container struct {
delaysLock sync.Mutex

listens map[netaddr.IPPort]map[uint32]*ListenDetails
ipsByNs map[string][]netaddr.IP

connectsSuccessful map[AddrPair]*ConnectionStats // dst:actual_dst -> count
connectsFailed map[netaddr.IPPort]int64 // dst -> count
Expand Down Expand Up @@ -164,7 +163,6 @@ func NewContainer(id ContainerID, cg *cgroup.Cgroup, md *ContainerMetadata, host
delaysByPid: map[uint32]Delays{},

listens: map[netaddr.IPPort]map[uint32]*ListenDetails{},
ipsByNs: map[string][]netaddr.IP{},

connectsSuccessful: map[AddrPair]*ConnectionStats{},
connectsFailed: map[netaddr.IPPort]int64{},
Expand Down Expand Up @@ -486,16 +484,12 @@ func (c *Container) onListenOpen(pid uint32, addr netaddr.IPPort, safe bool) {
return
}
defer ns.Close()
nsId := ns.UniqueId()
ips, ok := c.ipsByNs[nsId]
if !ok {
if ips, err = proc.GetNsIps(ns); err != nil {
klog.Warningln(err)
} else {
klog.Infof("got IPs %s for %s", ips, nsId)
c.ipsByNs[nsId] = ips
}
ips, err := proc.GetNsIps(ns)
if err != nil {
klog.Warningln(err)
return
}
klog.Infof("got IPs %s for %s", ips, ns.UniqueId())
details.NsIPs = ips
}
}
Expand Down Expand Up @@ -1024,12 +1018,6 @@ func (c *Container) gc(now time.Time) {
seenNamespaces[p.NetNsId()] = true
}

for ns := range c.ipsByNs {
if !seenNamespaces[ns] {
delete(c.ipsByNs, ns)
}
}

c.revalidateListens(now, listens)

for srcDst, conn := range c.connectionsActive {
Expand Down