Browse Source

`pid-to-container` map revalidation

Anton Petruhin 4 years ago
parent
commit
3266fed4a5
1 changed files with 15 additions and 0 deletions
  1. 15 0
      containers/registry.go

+ 15 - 0
containers/registry.go

@@ -99,6 +99,21 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 	for {
 		select {
 		case now := <-gcTicker.C:
+			for pid, c := range r.containersByPid {
+				cg, err := proc.ReadCgroup(pid)
+				if err != nil {
+					delete(r.containersByPid, pid)
+					if c != nil {
+						c.onProcessExit(pid, false)
+					}
+					continue
+				}
+				if c != nil && cg.Id != c.cgroup.Id {
+					delete(r.containersByPid, pid)
+					c.onProcessExit(pid, false)
+				}
+			}
+
 			for id, c := range r.containersById {
 				if !c.Dead(now) {
 					continue