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 benchmark system runner no shard available error #2225

Merged
merged 5 commits into from
Nov 14, 2024
Merged
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
8 changes: 8 additions & 0 deletions internal/benchrunner/runners/common/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"

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

if resp.StatusCode == http.StatusServiceUnavailable && strings.Contains(resp.String(), "no_shard_available_action_exception") {
// Index is being created, but no shards are available yet.
// See https://github.com/elastic/elasticsearch/issues/65846
return 0, nil
}

if resp.IsError() {
return 0, fmt.Errorf("failed to get hits count: %s", resp.String())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/benchrunner/runners/system/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (c *collector) collectMetricsPreviousToStop(ctx context.Context) {
func (c *collector) collectTotalHits(ctx context.Context) int {
totalHits, err := common.CountDocsInDataStream(ctx, c.esAPI, c.datastream)
if err != nil {
logger.Debugf("could not total hits: %w", err)
logger.Debugf("could not get total hits: %s", err)
}
return totalHits
}
Expand Down