Skip to content

Commit

Permalink
fix elk client panic issue due to uninitialized waitgroup, ctx
Browse files Browse the repository at this point in the history
Signed-off-by: rksharma95 <[email protected]>
  • Loading branch information
rksharma95 committed Dec 16, 2024
1 parent 8499e6f commit 08635cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion relay-server/elasticsearch/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion relay-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions relay-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 08635cd

Please sign in to comment.