Prevent clovisor from unable to create qdisc / filter from previous 93/66693/1
authorStephen Wong <stephen.kf.wong@gmail.com>
Mon, 28 Jan 2019 08:19:11 +0000 (08:19 +0000)
committerStephen Wong <stephen.kf.wong@gmail.com>
Mon, 28 Jan 2019 08:22:28 +0000 (08:22 +0000)
instance dying abnormally (qdisc deletion is part of exit callback for
pod under monitoring, but if clovisor exits abnormally, qdisc would not
be deleted, which cause the restarted new clovisor pod unable to load
BPF code to the pods under monitoring)

Change-Id: I5620f34e7f05805e203d1cfda9a8f7a1d42fd4f5
Signed-off-by: Stephen Wong <stephen.kf.wong@gmail.com>
clover/clovisor/bin/clovisor
clover/clovisor/build-docker
clover/clovisor/libclovisor/clovisor_bcc.go

index d35f90e..240e0bc 100755 (executable)
Binary files a/clover/clovisor/bin/clovisor and b/clover/clovisor/bin/clovisor differ
index 4f776ec..99668d7 100755 (executable)
@@ -14,7 +14,7 @@ if [ -z "$1" ]
 fi
 cp bin/clovisor .
 docker build --build-arg TARGET_KERNEL_VER=$kernel_ver -t clovisor .
-docker tag clovisor localhost:5000/clovisor
-docker push localhost:5000/clovisor
-#docker tag clovisor s3wong/clovisor
-#docker push s3wong/clovisor
+#docker tag clovisor localhost:5000/clovisor
+#docker push localhost:5000/clovisor
+docker tag clovisor s3wong/clovisor
+docker push s3wong/clovisor
index e2d9cd8..ab5bc33 100644 (file)
@@ -509,6 +509,22 @@ func ClovisorNewPodInit(k8s_client *ClovisorK8s,
 
     session_table := bcc.NewTable(bpf_mod.TableId("sessions"), bpf_mod)
 
+    // check if qdisc clsact filter for this interface already exists
+    link, err := netlink.LinkByIndex(ifindex)
+    if err != nil {
+        fmt.Println(err)
+    } else {
+        qdiscs, err := netlink.QdiscList(link)
+        if err == nil {
+            for _, qdisc := range qdiscs {
+                if qdisc.Type() == "clsact" {
+                    netlink.QdiscDel(qdisc)
+                    break
+                }
+            }
+        }
+    }
+
     attrs := netlink.QdiscAttrs {
         LinkIndex: ifindex,
         Handle: netlink.MakeHandle(0xffff, 0),