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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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 @@ -90,7 +91,7 @@
Action: "index",
DocumentID: uuid.New().String(),
Body: bytes.NewReader(data),
OnSuccess: func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem) {

Check warning on line 94 in relay-server/elasticsearch/adapter.go

View workflow job for this annotation

GitHub Actions / go-lint

parameter 'ctx' seems to be unused, consider removing or renaming it as _
atomic.AddUint64(&countSuccessful, 1)
},
OnFailure: func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem, err error) {
Expand All @@ -116,7 +117,8 @@
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
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2021 Authors of KubeArmor

package main

Check warning on line 4 in relay-server/main.go

View workflow job for this annotation

GitHub Actions / go-lint

should have a package comment

import (
"os"
Expand Down Expand Up @@ -56,7 +56,7 @@

//get env
enableEsDashboards := os.Getenv("ENABLE_DASHBOARDS")
esUrl := os.Getenv("ES_URL")

Check warning on line 59 in relay-server/main.go

View workflow job for this annotation

GitHub Actions / go-lint

var esUrl should be esURL
endPoint := os.Getenv("KUBEARMOR_SERVICE")
if endPoint == "" {
endPoint = "localhost:32767"
Expand Down Expand Up @@ -87,6 +87,7 @@
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
Loading