Skip to content

Commit

Permalink
fix panic when checking if es/nats event target is active (minio#9587)
Browse files Browse the repository at this point in the history
  • Loading branch information
poornas authored May 13, 2020
1 parent 94f1a1d commit 2ecf5ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/event/target/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func (target *ElasticsearchTarget) IsActive() (bool, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

if target.client == nil {
client, err := newClient(target.args)
if err != nil {
return false, err
}
target.client = client
}
_, code, err := target.client.Ping(target.args.URL.String()).HttpHeadOnly(true).Do(ctx)
if err != nil {
if elastic.IsConnErr(err) || elastic.IsContextErr(err) || xnet.IsNetworkOrHostDown(err) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/event/target/nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (target *NSQTarget) HasQueueStore() bool {

// IsActive - Return true if target is up and active
func (target *NSQTarget) IsActive() (bool, error) {
if target.producer != nil {
if target.producer == nil {
producer, err := nsq.NewProducer(target.args.NSQDAddress.String(), target.config)
if err != nil {
return false, err
Expand Down

0 comments on commit 2ecf5ba

Please sign in to comment.