dont show ccr status if license insufficient

This commit is contained in:
2026-07-05 22:11:01 +02:00
parent a07f38e945
commit 90c7da98ea
2 changed files with 23 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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))},