merbridge icon indicating copy to clipboard operation
merbridge copied to clipboard

Error when trying to run Merbridge in debug mode (VScode)

Open abhayakyy opened this issue 1 year ago • 4 comments

Bug Description

    • The error when trying to run the code base in the main branch using "dlv" is
Build Error: go build -o /home/xxx/github/merbridge/app/__debug_bin -gcflags all=-N -l .
# istio.io/istio/pilot/pkg/config/memory
../../../go/pkg/mod/istio.io/[email protected]/pilot/pkg/config/memory/controller.go:36:17: undefined: atomic.Bool
note: module requires Go 1.19
# istio.io/istio/pilot/pkg/config/kube/ingress
../../../go/pkg/mod/istio.io/[email protected]/pilot/pkg/config/kube/ingress/controller.go:100:17: undefined: atomic.Bool
note: module requires Go 1.19 (exit status 2)

Go Version is set using GVM 
Go version =>  go version go1.19 linux/amd64
Make version => GNU Make 4.3 (Built for x86_64-pc-linux-gnu)
    • Running command "go run -exec sudo ./app/main.go" gives the following error
[ -f bpf/mb_connect.c ] && make -C bpf load || make -C bpf load-from-obj
make[1]: Entering directory '/home/xxx/github/merbridge/bpf'
clang -O2 -g  -Wall -target bpf -I/usr/include/x86_64-linux-gnu  -DMESH=1 -DENABLE_IPV4=1 -DENABLE_IPV6=0 -DUSE_RECONNECT -c mb_connect.c -o mb_connect.o
make[1]: clang: No such file or directory
make[1]: *** [Makefile:79: mb_connect.o] Error 127
make[1]: Leaving directory '/home/xxx/github/merbridge/bpf'
make[1]: Entering directory '/home/xxx/github/merbridge/bpf'
sudo mount -t bpf bpf /sys/fs/bpf
sudo mkdir -p /sys/fs/bpf/tc/globals
[ -f /sys/fs/bpf/cookie_original_dst ] || sudo bpftool map create /sys/fs/bpf/cookie_original_dst type lru_hash key 8 value 24 entries 65535 name cookie_original_dst
sudo: bpftool: command not found
make[1]: *** [Makefile:91: load-map-cookie_original_dst] Error 1
make[1]: Leaving directory '/home/xxx/github/merbridge/bpf'
make: *** [Makefile:3: load] Error 2
Error: failed to load ebpf programs: unexpected exit code: 2, err: exit status 2
Usage:
  mbctl [flags]

Flags:
      --cni-bin-dir string      /opt/cni/bin mount path (default "/host/opt/cni/bin")
      --cni-config-dir string   /etc/cni/net.d mount path (default "/host/etc/cni/net.d")
      --cni-mode                Enable Merbridge CNI plugin
  -d, --debug                   Debug mode
      --enable-hot-restart      enable hot restart
  -h, --help                    help for mbctl
      --host-proc string        /proc mount path (default "/host/proc")
      --host-var-run string     /var/run mount path (default "/host/var/run")
  -k, --kind                    Enable when Kubernetes is running in Kind
      --kubeconfig string       Kubernetes configuration file
      --kubecontext string      The name of the kube config context to use
  -m, --mode string             Service mesh mode, current support istio, linkerd and kuma (default "istio")
  -r, --use-reconnect           Use re-connect mode for same-node acceleration (default true)

exit status 1

Version

$uname -a 
Linux xxx 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

istioctl version 
1.15.3

abhayakyy avatar Nov 06 '22 11:11 abhayakyy

It looks like you don't have clang and bpftool installed on your system.

kebe7jun avatar Nov 06 '22 11:11 kebe7jun

For vscode, you should change the go version of vscode used to 1.19(try google).

kebe7jun avatar Nov 06 '22 12:11 kebe7jun

installing these fixed the issue but now I am getting this error

2022-11-06T14:07:52.281386Z error klog pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:169: Failed to watch *v1.Pod: failed to list *v1.Pod: Get "https://127.0.0.1:45007/api/v1/pods?fieldSelector=spec.nodeName%3Droy&limit=500&resourceVersion=0": dial tcp 127.0.0.1:45007: connect: connection refused

Do I need a running k8s cluster with istio installed on it ?

abhayakyy avatar Nov 06 '22 14:11 abhayakyy

installing these fixed the issue but now I am getting this error

2022-11-06T14:07:52.281386Z error klog pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:169: Failed to watch *v1.Pod: failed to list *v1.Pod: Get "https://127.0.0.1:45007/api/v1/pods?fieldSelector=spec.nodeName%3Droy&limit=500&resourceVersion=0": dial tcp 127.0.0.1:45007: connect: connection refused

Do I need a running k8s cluster with istio installed on it ?

Yes, you need to install a Kubernetes cluster with Istio locally. You can either try Kind to create a new cluster and make sure the root user can access it directly via kubectl, or set the KUBECONFIG environment variable manually.

kebe7jun avatar Nov 07 '22 01:11 kebe7jun