From 08635cd8a2c124af99b70acc8596910c2b159b8b Mon Sep 17 00:00:00 2001 From: rksharma95 Date: Mon, 16 Dec 2024 23:31:47 +0530 Subject: [PATCH] fix elk client panic issue due to uninitialized waitgroup, ctx Signed-off-by: rksharma95 --- relay-server/elasticsearch/adapter.go | 4 +++- relay-server/go.mod | 2 +- relay-server/main.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/relay-server/elasticsearch/adapter.go b/relay-server/elasticsearch/adapter.go index 108cac4..598bda7 100644 --- a/relay-server/elasticsearch/adapter.go +++ b/relay-server/elasticsearch/adapter.go @@ -17,6 +17,7 @@ import ( "github.com/google/uuid" kg "github.com/kubearmor/kubearmor-relay-server/relay-server/log" "github.com/kubearmor/kubearmor-relay-server/relay-server/server" + "golang.org/x/sync/errgroup" ) var ( @@ -116,7 +117,8 @@ func (ecl *ElasticsearchClient) Start() error { start = time.Now() client := ecl.kaClient ecl.ctx, ecl.cancel = context.WithCancel(context.Background()) - + client.WgServer = &errgroup.Group{} + client.Context = ecl.ctx // do healthcheck if ok := client.DoHealthCheck(); !ok { return fmt.Errorf("failed to check the liveness of the gRPC server") diff --git a/relay-server/go.mod b/relay-server/go.mod index 8414ba5..83f3cce 100644 --- a/relay-server/go.mod +++ b/relay-server/go.mod @@ -13,7 +13,6 @@ require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/dustin/go-humanize v1.0.1 github.com/elastic/go-elasticsearch/v7 v7.17.10 - github.com/golang/protobuf v1.5.4 github.com/google/uuid v1.6.0 github.com/kubearmor/KubeArmor/KubeArmor v0.0.0-20240412061210-e4422dd02342 github.com/kubearmor/KubeArmor/protobuf v0.0.0-20240315075053-fee50c9428b9 @@ -35,6 +34,7 @@ require ( github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect diff --git a/relay-server/main.go b/relay-server/main.go index 251f604..2f6cef8 100644 --- a/relay-server/main.go +++ b/relay-server/main.go @@ -87,6 +87,7 @@ func main() { esCl, err := elasticsearch.NewElasticsearchClient(esUrl, endPoint) if err != nil { kg.Warnf("Failed to start a Elasticsearch Client") + return } go esCl.Start() defer esCl.Stop()