Skip to content

Commit 08635cd

Browse files
committed
fix elk client panic issue due to uninitialized waitgroup, ctx
Signed-off-by: rksharma95 <[email protected]>
1 parent 8499e6f commit 08635cd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

relay-server/elasticsearch/adapter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/google/uuid"
1818
kg "github.com/kubearmor/kubearmor-relay-server/relay-server/log"
1919
"github.com/kubearmor/kubearmor-relay-server/relay-server/server"
20+
"golang.org/x/sync/errgroup"
2021
)
2122

2223
var (
@@ -116,7 +117,8 @@ func (ecl *ElasticsearchClient) Start() error {
116117
start = time.Now()
117118
client := ecl.kaClient
118119
ecl.ctx, ecl.cancel = context.WithCancel(context.Background())
119-
120+
client.WgServer = &errgroup.Group{}
121+
client.Context = ecl.ctx
120122
// do healthcheck
121123
if ok := client.DoHealthCheck(); !ok {
122124
return fmt.Errorf("failed to check the liveness of the gRPC server")

relay-server/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/cenkalti/backoff/v4 v4.2.1
1414
github.com/dustin/go-humanize v1.0.1
1515
github.com/elastic/go-elasticsearch/v7 v7.17.10
16-
github.com/golang/protobuf v1.5.4
1716
github.com/google/uuid v1.6.0
1817
github.com/kubearmor/KubeArmor/KubeArmor v0.0.0-20240412061210-e4422dd02342
1918
github.com/kubearmor/KubeArmor/protobuf v0.0.0-20240315075053-fee50c9428b9
@@ -35,6 +34,7 @@ require (
3534
github.com/go-openapi/jsonreference v0.21.0 // indirect
3635
github.com/go-openapi/swag v0.23.0 // indirect
3736
github.com/gogo/protobuf v1.3.2 // indirect
37+
github.com/golang/protobuf v1.5.4 // indirect
3838
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
3939
github.com/google/go-cmp v0.6.0 // indirect
4040
github.com/google/gofuzz v1.2.0 // indirect

relay-server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func main() {
8787
esCl, err := elasticsearch.NewElasticsearchClient(esUrl, endPoint)
8888
if err != nil {
8989
kg.Warnf("Failed to start a Elasticsearch Client")
90+
return
9091
}
9192
go esCl.Start()
9293
defer esCl.Stop()

0 commit comments

Comments
 (0)