Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update patch to use DefaultBackoff #80

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions controllers/routingctrl/delete_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/opendatahub-io/odh-platform/pkg/metadata/labels"
"github.com/opendatahub-io/odh-platform/pkg/routing"
"github.com/opendatahub-io/odh-platform/pkg/unstruct"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
k8slabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -90,8 +91,9 @@ func removeFinalizer(ctx context.Context, cli client.Client, sourceRes *unstruct
if controllerutil.ContainsFinalizer(sourceRes, finalizerName) {
controllerutil.RemoveFinalizer(sourceRes, finalizerName)

if err := cli.Update(ctx, sourceRes); err != nil {
return fmt.Errorf("failed to remove finalizer: %w", err)
if err := unstruct.Patch(ctx, cli, sourceRes); err != nil {
return fmt.Errorf("failed to remove finalizer patching resource %s/%s: %w",
sourceRes.GetNamespace(), sourceRes.GetName(), err)
Comment on lines +95 to +96
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("failed to remove finalizer patching resource %s/%s: %w",
sourceRes.GetNamespace(), sourceRes.GetName(), err)
return fmt.Errorf("failed to remove finalizer from %s (in %s): %w",
sourceRes.GroupVersionKind().String(), sourceRes.GetNamespace(), err)

}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/unstruct/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func IsMarkedForDeletion(target *unstructured.Unstructured) bool {
// Patch updates the specified Kubernetes resource by applying changes from the provided target object.
// In case of conflicts, it will retry using default strategy.
func Patch(ctx context.Context, cli client.Client, target *unstructured.Unstructured) error {
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
currentRes := &unstructured.Unstructured{}
currentRes.SetGroupVersionKind(target.GroupVersionKind())

Expand Down