fix crash

This commit is contained in:
2026-07-17 08:55:48 +02:00
parent 522898f187
commit 6f3ca3243a
2 changed files with 25 additions and 5 deletions

15
TODO.md
View File

@@ -6,3 +6,18 @@
- add datastream support:
https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-stream
- Fix: cluster status word wrapping adds one \n to much:
```console
Bad health shards_availability This cluster has 1 unavailable replica shard.
-> cause Elasticsearch isn't allowed to allocate some shards from these indices to any of the nodes in the
cluster.
-> affected indices foo-t-log-logs-002947
-> suggested action to fix Diagnose the issue by calling the allocation explain API for an index [GET
_cluster/allocation/explain]. Choose a node to which you expect a shard to be allocated, find this
node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from
```

View File

@@ -285,9 +285,11 @@ func IlmExplain(conf *cfg.Config, index string) error {
info := ""
err = json.Unmarshal(ilm.StepInfo["reason"], &info)
if err != nil {
return fmt.Errorf("failed to unmarshal step info: %w", err)
if len(ilm.StepInfo["reason"]) > 0 {
err = json.Unmarshal(ilm.StepInfo["reason"], &info)
if err != nil {
return fmt.Errorf("failed to unmarshal step info: %w", err)
}
}
table.Entries = [][]any{
@@ -299,8 +301,11 @@ func IlmExplain(conf *cfg.Config, index string) error {
{"phase", *ilm.Phase},
{"phase execution", ilmPhaseString(ilm.PhaseExecution.PhaseDefinition, false)},
{"step", *ilm.Step},
{"failed step", *ilm.FailedStep},
{"failed step retry count", ilm.FailedStepRetryCount},
}
if ilm.FailedStep != nil {
table.AddRow("failed step", *ilm.FailedStep)
table.AddRow("failed step retry count", ilm.FailedStepRetryCount)
}
if err := table.Print(); err != nil {