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(adapter): fix elk client panic issue due to uninitialized waitgroup, ctx #64

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

rksharma95
Copy link
Contributor

@rksharma95 rksharma95 commented Dec 16, 2024

{"level":"info","ts":"2024-12-16 15:17:16.180767","caller":"log/logger.go:54","msg":"Created a relay server (:32767)"}
{"level":"info","ts":"2024-12-16 15:17:16.180927","caller":"log/logger.go:49","msg":"Started to serve gRPC-based log feeds"}
{"level":"info","ts":"2024-12-16 15:17:16.180945","caller":"log/logger.go:49","msg":"Started to receive log feeds from each node"}
{"level":"info","ts":"2024-12-16 15:17:16.182049","caller":"log/logger.go:49","msg":"Initialized the Kubernetes client"}
{"level":"info","ts":"2024-12-16 15:17:16.185508","caller":"log/logger.go:54","msg":"Added a new client (f12f3795-2e9f-4181-bf6a-2c5d26093aa6, policy) for WatchAlerts"}
{"level":"info","ts":"2024-12-16 15:17:16.185648","caller":"log/logger.go:54","msg":"Added a new client (b70fb7af-10a7-488f-bf63-eca88e583699, system) for WatchLogs"}
{"level":"info","ts":"2024-12-16 15:17:16.186195","caller":"log/logger.go:54","msg":"Checked the liveness of the gRPC server"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1a287fc]

goroutine 63 [running]:
golang.org/x/sync/errgroup.(*Group).Go(0x0, 0xc000652030)
        /go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:70 +0x1c
github.com/kubearmor/kubearmor-relay-server/relay-server/elasticsearch.(*ElasticsearchClient).Start(0xc000506740)
        /usr/src/kubearmor-relay-server/relay-server/elasticsearch/adapter.go:126 +0x13f
created by main.main in goroutine 1
        /usr/src/kubearmor-relay-server/relay-server/main.go:91 +0x388

after fix:

{"level":"info","ts":"2024-12-17 15:57:28.345659","caller":"log/logger.go:54","msg":"Created a relay server (:32767)"}
{"level":"info","ts":"2024-12-17 15:57:28.345760","caller":"log/logger.go:49","msg":"Started to serve gRPC-based log feeds"}
{"level":"info","ts":"2024-12-17 15:57:28.345771","caller":"log/logger.go:49","msg":"Started to receive log feeds from each node"}
{"level":"info","ts":"2024-12-17 15:57:28.348915","caller":"log/logger.go:49","msg":"Initialized the Kubernetes client"}
{"level":"info","ts":"2024-12-17 15:57:28.361226","caller":"log/logger.go:54","msg":"Checked the liveness of KubeArmor's gRPC service (192.168.29.159:32767)"}
{"level":"info","ts":"2024-12-17 15:57:28.361289","caller":"log/logger.go:49","msg":"Started to watch messages from 192.168.29.159:32767"}
{"level":"info","ts":"2024-12-17 15:57:28.361300","caller":"log/logger.go:49","msg":"Started to watch alerts from 192.168.29.159:32767"}
{"level":"info","ts":"2024-12-17 15:57:28.361310","caller":"log/logger.go:49","msg":"Started to watch logs from 192.168.29.159:32767"}
{"level":"warn","ts":"2024-12-17 15:58:51.449813","caller":"log/logger.go:79","msg":"failed to receive a log (192.168.29.159:32767) rpc error: code = Unavailable desc = error reading from server: EOF"}
{"level":"info","ts":"2024-12-17 15:58:51.449880","caller":"log/logger.go:54","msg":"Destroyed the client (192.168.29.159:32767)"}
{"level":"warn","ts":"2024-12-17 15:58:51.450228","caller":"log/logger.go:84","msg":"Failed to call WatchMessages (192.168.29.159:32767) err=rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp 192.168.29.159:32767: connect: connection refused\"\n"}
{"level":"warn","ts":"2024-12-17 15:58:51.600931","caller":"log/logger.go:84","msg":"Failed to call WatchMessages (192.168.29.159:32767) err=rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp 192.168.29.159:32767: connect: connection refused\"\n"}
{"level":"warn","ts":"2024-12-17 15:58:56.601869","caller":"log/logger.go:84","msg":"Failed to call WatchMessages (192.168.29.159:32767) err=rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp 192.168.29.159:32767: connect: connection refused\"\n"}
{"level":"warn","ts":"2024-12-17 15:59:01.603038","caller":"log/logger.go:84","msg":"Failed to call WatchMessages (192.168.29.159:32767) err=rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp 192.168.29.159:32767: connect: connection refused\"\n"}
{"level":"warn","ts":"2024-12-17 15:59:06.603929","caller":"log/logger.go:84","msg":"Failed to call WatchMessages (192.168.29.159:32767) err=rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing: dial tcp 192.168.29.159:32767: connect: connection refused\"\n"}
{"level":"info","ts":"2024-12-17 15:59:15.242529","caller":"log/logger.go:54","msg":"Checked the liveness of KubeArmor's gRPC service (192.168.29.159:32767)"}
{"level":"info","ts":"2024-12-17 15:59:15.242574","caller":"log/logger.go:49","msg":"Started to watch messages from 192.168.29.159:32767"}
{"level":"info","ts":"2024-12-17 15:59:15.242583","caller":"log/logger.go:49","msg":"Started to watch alerts from 192.168.29.159:32767"}
{"level":"info","ts":"2024-12-17 15:59:15.242592","caller":"log/logger.go:49","msg":"Started to watch logs from 192.168.29.159:32767"}
^C{"level":"info","ts":"2024-12-17 16:04:40.105355","caller":"log/logger.go:49","msg":"Terminated the gRPC service"}
{"level":"info","ts":"2024-12-17 16:04:40.105413","caller":"log/logger.go:49","msg":"Destroyed the relay server"}
{"level":"info","ts":"2024-12-17 16:04:40.105449","caller":"log/logger.go:54","msg":"Stopped kubearmor receiver"}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
2024/12/17 16:04:42 Sucessfuly indexed [13] documents in 7m13.758s (0.029970628783791885 docs/sec)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Copy link
Member

@daemon1024 daemon1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check other parts of the code? what's the below for loop for? how are client disconnects handled.

@rksharma95 rksharma95 force-pushed the fix-elk-client branch 2 times, most recently from ce541fb to da1a1ba Compare December 17, 2024 10:45
Copy link
Member

@daemon1024 daemon1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@rksharma95 rksharma95 merged commit 6ce5eeb into kubearmor:main Dec 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants