Skip to content

Commit

Permalink
add log message for mismatched lshealthcheck counts (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
reshnm authored Sep 12, 2023
1 parent 097c06d commit 36a8328
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controllers/avmonitorregistration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reco
continue
}

logger.Info("add instance to be monitored")
instanceRefsToMonitor = append(instanceRefsToMonitor, lssv1alpha1.ObjectReference{
Name: instance.Name,
Namespace: instance.Namespace,
Expand Down
16 changes: 16 additions & 0 deletions pkg/controllers/healthwatcher/controllger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
"time"

lsv1alpha1 "github.com/gardener/landscaper/apis/core/v1alpha1"
Expand Down Expand Up @@ -213,6 +214,21 @@ func (c *Controller) getLsHealthCheckFromSelfLandscaper(ctx context.Context, nam
c.log.Info(fmt.Sprintf("could not load lshealthcheck from cluster: %s", err.Error()))
setAvailabilityInstanceStatusToFailed(&availabilityInstance, "failed retrieving lshealthcheck cr")
}
if len(lsHealthchecks.Items) != 1 {
if len(lsHealthchecks.Items) > 0 {
lsHealthCheckNames := strings.Builder{}
for _, item := range lsHealthchecks.Items {
if lsHealthCheckNames.Len() > 0 {
lsHealthCheckNames.WriteString(",")
}
lsHealthCheckNames.WriteString(item.Name)

}
c.log.Info("number of lshealthcheck instances is not equal to 1", "lshHealthCheckInstanceCount", len(lsHealthchecks.Items), "lsHealthCheckNames", lsHealthCheckNames.String())
} else {
c.log.Info("number of lshealthcheck instances is not equal to 1", "lshHealthCheckInstanceCount", len(lsHealthchecks.Items))
}
}
transferLsHealthCheckStatusToAvailabilityInstance(&availabilityInstance, lsHealthchecks, c.Config().AvailabilityMonitoring.LSHealthCheckTimeout.Duration)
return availabilityInstance
}
Expand Down

0 comments on commit 36a8328

Please sign in to comment.