From 37da2238cf4b47b166907956cf224e7b0e8726bf Mon Sep 17 00:00:00 2001 From: Xavi Garcia Date: Wed, 3 Jul 2024 18:03:37 +0200 Subject: [PATCH] Deletes `Bundles` after deleting all its `BundleDeployments` When testing https://github.com/rancher/fleet/issues/2586 the `Bundle` reconciler found that the `Bundle` was gone as was trying to delete the same `BundleDeployments` in parallel. Deleting the `Bundle` after deleting all its `BundleDeployments` seems to help to prevent that race condition between both reconcilers Refers to: https://github.com/rancher/fleet/issues/2586 Signed-off-by: Xavi Garcia --- internal/cmd/controller/finalize/finalize.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/cmd/controller/finalize/finalize.go b/internal/cmd/controller/finalize/finalize.go index 9af3a24879..056677c536 100644 --- a/internal/cmd/controller/finalize/finalize.go +++ b/internal/cmd/controller/finalize/finalize.go @@ -50,15 +50,15 @@ func PurgeBundles(ctx context.Context, c client.Client, gitrepo types.Namespaced } for _, bundle := range bundles.Items { - err := c.Delete(ctx, &bundle) - if client.IgnoreNotFound(err) != nil { - return err - } - nn := types.NamespacedName{Namespace: bundle.Namespace, Name: bundle.Name} if err = PurgeBundleDeployments(ctx, c, nn); err != nil { return client.IgnoreNotFound(err) } + + err := c.Delete(ctx, &bundle) + if client.IgnoreNotFound(err) != nil { + return err + } } return nil