Skip to content

Commit

Permalink
Read object before compare to avoid wrong cached data (#1216)
Browse files Browse the repository at this point in the history
* Read object before compare to avoid wrong cached data

#1208 Reading the object before checking if historical to avoid reading cached annotation.

* Keep error check close to err assigment

* Change log location to comply with code style requirements
  • Loading branch information
guipal committed May 9, 2023
1 parent 8098953 commit 8f297a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/webhook/webhookreporter.go
Expand Up @@ -72,12 +72,7 @@ func (r *WebhookReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *WebhookReconciler) reconcileReport(reportType client.Object) reconcile.Func {
return func(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
log := r.Logger.WithValues("report", request.NamespacedName)
if ignoreHistoricalReport(reportType) {
log.V(1).Info("Ignoring historical report")
return ctrl.Result{}, nil
}
verb := Update

err := r.Client.Get(ctx, request.NamespacedName, reportType)
if err != nil {
if !errors.IsNotFound(err) {
Expand All @@ -89,6 +84,11 @@ func (r *WebhookReconciler) reconcileReport(reportType client.Object) reconcile.
}
verb = Delete
}

if ignoreHistoricalReport(reportType) {
log.V(1).Info("Ignoring historical report")
return ctrl.Result{}, nil
}

if r.WebhookSendDeletedReports {
msg := WebhookMsg{OperatorObject: reportType, Verb: verb}
Expand Down

0 comments on commit 8f297a8

Please sign in to comment.