This commit is contained in:
2026-07-07 09:22:18 +02:00
parent f10366dbde
commit 24038e36f7
7 changed files with 12 additions and 25 deletions

View File

@@ -44,16 +44,14 @@ func ClusterList(conf *cfg.Config) error {
// check endpoints in parallel to speed things up
for name, cluster := range conf.Clusters {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
online, err := cluster.IsReachable()
mu.Lock()
reachable[name] = clusterReachable{reachable: online, err: err}
mu.Unlock()
}()
})
}
wg.Wait()

View File

@@ -18,6 +18,7 @@ package es
import (
"fmt"
"strings"
"github.com/elastic/go-elasticsearch/v9/typedapi/types"
)
@@ -27,14 +28,14 @@ func esErrorString(err error) string {
switch e := err.(type) {
case *types.ElasticsearchError:
causes := ""
var causes strings.Builder
for _, cause := range e.ErrorCause.RootCause {
causes += fmt.Sprintf("%s\n", *cause.Reason)
causes.WriteString(fmt.Sprintf("%s\n", *cause.Reason))
}
if e.ErrorCause.Reason != nil {
msg = *e.ErrorCause.Reason + ": " + causes
msg = *e.ErrorCause.Reason + ": " + causes.String()
} else {
msg = fmt.Sprintf("http status %d: ", e.Status)
}

View File

@@ -157,11 +157,7 @@ func IlmForecastShow(conf *cfg.Config) error {
var toBeFreed int64 = 0
for _, phase := range phaseData {
age := virtualAge(&phase)
if age < phase.age {
age = phase.age
}
age := max(virtualAge(&phase), phase.age)
if age+within >= phase.minage {
toBeFreed += phase.size
@@ -200,7 +196,7 @@ func getIlmPhaseData(conf *cfg.Config) ([]PhaseData, error) {
var indicesres *indices.Response
var ilmpolicies getlifecycle.Response
for i := 0; i < 3; i++ {
for range 3 {
r := <-responses
if r.error != nil {

View File

@@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"strconv"
"strings"
@@ -448,9 +449,7 @@ func modMappings(mappings []string) (types.TypeMappingVariant, error) {
func modMeta(conf *cfg.Config, meta types.Metadata) (map[string]json.RawMessage, error) {
metadata := map[string]json.RawMessage{}
for key, value := range meta {
metadata[key] = value
}
maps.Copy(metadata, meta)
for _, meta := range conf.Meta {
parts := strings.Split(meta, ":")