Skip to content

Commit

Permalink
Add log statement when deleting SnapshotEnvironmentBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwest committed Oct 18, 2023
1 parent 62f7022 commit 7f1c859
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ func (r *SnapshotEnvironmentBindingReconciler) Reconcile(ctx context.Context, re
},
}
if err := rClient.Get(ctx, client.ObjectKeyFromObject(&application), &application); apierr.IsNotFound(err) {
err = rClient.Delete(ctx, binding)
if err != nil {

if err := rClient.Delete(ctx, &binding); err != nil {
return ctrl.Result{}, fmt.Errorf("unable to delete Binding %s in Namespace %s: %w", binding.Name, binding.Namespace, err)
}
log.Info("deleting SnapshotEnvironmentBinding because referenced Application no longer exists", "applicationName", application.Name)
logutil.LogAPIResourceChangeEvent(binding.Namespace, binding.Name, binding, logutil.ResourceDeleted, log)
return ctrl.Result{}, nil

} else if err != nil {
return ctrl.Result{}, fmt.Errorf("error getting Application %s associated with Binding %s in Namespace %s: %w", binding.Spec.Application, binding.Name, binding.Namespace, err)
}
Expand Down

0 comments on commit 7f1c859

Please sign in to comment.