Skip to content

Commit

Permalink
fix: retry all status updates due to controller contention
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
  • Loading branch information
TylerGillson committed Nov 16, 2023
1 parent 8609147 commit da81af2
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions pkg/validationresult/validation_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,23 @@ func HandleNewValidationResult(c client.Client, vr *v1alpha1.ValidationResult, l
return err
}

var err error
nn := ktypes.NamespacedName{Name: vr.Name, Namespace: vr.Namespace}

// Update the ValidationResult's status
for i := 0; i < constants.StatusUpdateRetries; i++ {
if err := c.Get(context.Background(), nn, vr); err != nil {
l.V(0).Error(err, "failed to get ValidationResult", "name", nn.Name, "namespace", nn.Namespace)
return err
}

Check warning on line 63 in pkg/validationresult/validation_result.go

View check run for this annotation

Codecov / codecov/patch

pkg/validationresult/validation_result.go#L61-L63

Added lines #L61 - L63 were not covered by tests

// Update the ValidationResult's status
vr.Status = v1alpha1.ValidationResultStatus{
State: v1alpha1.ValidationInProgress,
}
if err := c.Status().Update(context.Background(), vr); err != nil {
l.V(1).Info(
"warning: failed to update ValidationResult status", "name", vr.Name, "namespace", vr.Namespace, "error", err.Error(),
)
vr.Status = v1alpha1.ValidationResultStatus{State: v1alpha1.ValidationInProgress}
err = c.Status().Update(context.Background(), vr)
if err == nil {
return nil
}
l.V(1).Info("warning: failed to update ValidationResult status", "name", vr.Name, "namespace", vr.Namespace, "error", err.Error())
}

return nil
return err
}

// SafeUpdateValidationResult updates the overall validation result, ensuring
Expand Down

0 comments on commit da81af2

Please sign in to comment.