operator: Do not update status after setting degraded condition (#9511)

pull/9486/head
Robert Jacob 3 years ago committed by GitHub
parent 2c57d2e2b9
commit 9f19c384e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      operator/CHANGELOG.md
  2. 17
      operator/controllers/loki/lokistack_controller.go

@ -1,5 +1,6 @@
## Main
- [9511](https://github.com/grafana/loki/pull/9511) **xperimental**: Do not update status after setting degraded condition
- [9405](https://github.com/grafana/loki/pull/9405) **periklis**: Add support for configuring HTTP server timeouts
- [9378](https://github.com/grafana/loki/pull/9378) **aminesnow**: Add zone aware API spec validation
- [9408](https://github.com/grafana/loki/pull/9408) **JoaoBraveCoding**: Add PodAntiAffinity overwrites per component

@ -5,6 +5,7 @@ import (
"errors"
"time"
"github.com/ViaQ/logerr/v2/kverrors"
"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
"github.com/grafana/loki/operator/controllers/loki/internal/management/state"
@ -154,14 +155,14 @@ func (r *LokiStackReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
if r.FeatureGates.BuiltInCertManagement.Enabled {
err = handlers.CreateOrRotateCertificates(ctx, r.Log, req, r.Client, r.Scheme, r.FeatureGates)
if res, derr := handleDegradedError(ctx, r.Client, req, err); derr != nil {
return res, derr
if err != nil {
return handleDegradedError(ctx, r.Client, req, err)
}
}
err = handlers.CreateOrUpdateLokiStack(ctx, r.Log, req, r.Client, r.Scheme, r.FeatureGates)
if res, derr := handleDegradedError(ctx, r.Client, req, err); derr != nil {
return res, derr
if err != nil {
return handleDegradedError(ctx, r.Client, req, err)
}
err = status.Refresh(ctx, r.Client, req, time.Now())
@ -177,7 +178,7 @@ func handleDegradedError(ctx context.Context, c client.Client, req ctrl.Request,
if errors.As(err, &degraded) {
err = status.SetDegradedCondition(ctx, c, req, degraded.Message, degraded.Reason)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{}, kverrors.Wrap(err, "error setting degraded condition")
}
return ctrl.Result{
@ -185,11 +186,7 @@ func handleDegradedError(ctx context.Context, c client.Client, req ctrl.Request,
}, nil
}
if err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{}, nil
return ctrl.Result{}, err
}
// SetupWithManager sets up the controller with the Manager.

Loading…
Cancel
Save