From 90c7da98eab3dc1858019aca6b35e26f0d061f60 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Sun, 5 Jul 2026 22:11:01 +0200 Subject: [PATCH] dont show ccr status if license insufficient --- .gitignore | 3 +++ pkg/es/cluster.go | 35 ++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index e056ce6..ce0e18b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ esctl *.log cpu.profile + +t +single diff --git a/pkg/es/cluster.go b/pkg/es/cluster.go index bb5399b..8895e50 100644 --- a/pkg/es/cluster.go +++ b/pkg/es/cluster.go @@ -17,6 +17,7 @@ along with this program. If not, see . package es import ( + "errors" "fmt" "log/slog" "strings" @@ -118,12 +119,12 @@ func getClusterStatus(conf *cfg.Config) (*apiResponse, error) { all := apiResponse{} + var err error + for i := 0; i < gocount; i++ { r := <-responses - if r.error != nil { - return nil, r.error - } + err = errors.Join(err, r.error) switch r.which { case ResponseHealth: @@ -143,27 +144,31 @@ func getClusterStatus(conf *cfg.Config) (*apiResponse, error) { } } - return &all, nil + return &all, err } func ClusterStatus(conf *cfg.Config) error { res, err := getClusterStatus(conf) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "current license is non-compliant") { return err } slog.Debug("ES result", "cluster health", res.health) - isleader := len(res.ccr.AutoFollowStats.AutoFollowedClusters) == 0 + var isleader bool + var ccrfollowing string - ccrfollowing := "" - if len(res.ccr.AutoFollowStats.AutoFollowedClusters) > 0 { - // is following another cluster - ccrfollowing = fmt.Sprintf("%s (%d/%d)", - res.ccr.AutoFollowStats.AutoFollowedClusters[0].ClusterName, - res.ccr.AutoFollowStats.NumberOfSuccessfulFollowIndices, - res.ccr.AutoFollowStats.NumberOfFailedFollowIndices, - ) + if res.ccr != nil { + isleader = len(res.ccr.AutoFollowStats.AutoFollowedClusters) == 0 + + if len(res.ccr.AutoFollowStats.AutoFollowedClusters) > 0 { + // is following another cluster + ccrfollowing = fmt.Sprintf("%s (%d/%d)", + res.ccr.AutoFollowStats.AutoFollowedClusters[0].ClusterName, + res.ccr.AutoFollowStats.NumberOfSuccessfulFollowIndices, + res.ccr.AutoFollowStats.NumberOfFailedFollowIndices, + ) + } } // look for red indices, if any @@ -200,7 +205,7 @@ func ClusterStatus(conf *cfg.Config) error { {"Long Running Tasks", fmt.Sprintf("%d", longtasks)}, } - if !isleader { + if !isleader && res.ccr != nil { table.Entries = append(table.Entries, [][]string{ {"AutoFollow (success/failed indices)", ccrfollowing}, {"Followed Indices", fmt.Sprintf("%d", len(res.ccr.FollowStats.Indices))},