Skip to content

Commit e7afb49

Browse files
authored
Fix benchmark system runner no shard available error (#2225)
Ignore no_shard_available_action_exception in benchmark system runner
1 parent 2c31b48 commit e7afb49

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

internal/benchrunner/runners/common/elasticsearch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"context"
99
"encoding/json"
1010
"fmt"
11+
"net/http"
12+
"strings"
1113

1214
"github.com/elastic/elastic-package/internal/elasticsearch"
1315
"github.com/elastic/elastic-package/internal/logger"
@@ -24,6 +26,12 @@ func CountDocsInDataStream(ctx context.Context, esapi *elasticsearch.API, dataSt
2426
}
2527
defer resp.Body.Close()
2628

29+
if resp.StatusCode == http.StatusServiceUnavailable && strings.Contains(resp.String(), "no_shard_available_action_exception") {
30+
// Index is being created, but no shards are available yet.
31+
// See https://github.com/elastic/elasticsearch/issues/65846
32+
return 0, nil
33+
}
34+
2735
if resp.IsError() {
2836
return 0, fmt.Errorf("failed to get hits count: %s", resp.String())
2937
}

internal/benchrunner/runners/system/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (c *collector) collectMetricsPreviousToStop(ctx context.Context) {
323323
func (c *collector) collectTotalHits(ctx context.Context) int {
324324
totalHits, err := common.CountDocsInDataStream(ctx, c.esAPI, c.datastream)
325325
if err != nil {
326-
logger.Debugf("could not total hits: %w", err)
326+
logger.Debugf("could not get total hits: %s", err)
327327
}
328328
return totalHits
329329
}

0 commit comments

Comments
 (0)