diff --git a/images/dvcr-artifact/cmd/dvcr-cleaner/cmd/gc.go b/images/dvcr-artifact/cmd/dvcr-cleaner/cmd/gc.go index b827981abb..4e62233214 100644 --- a/images/dvcr-artifact/cmd/dvcr-cleaner/cmd/gc.go +++ b/images/dvcr-artifact/cmd/dvcr-cleaner/cmd/gc.go @@ -146,6 +146,14 @@ func autoCleanupHandler(cmd *cobra.Command, args []string) error { errs = multierror.Append(errs, cleanupErr) } + // Testing: sleep and print errors if present. + time.Sleep(time.Second * 30) + err = errs.ErrorOrNil() + if err != nil { + fmt.Printf("Error while cleaning up stale images after cleanup: %v\n", err) + } + // Testing end. + result := map[string]any{ "result": "success", "startedAt": started, diff --git a/images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/internal/life_cycle.go b/images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/internal/life_cycle.go index 6f5a428616..00295f00c3 100644 --- a/images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/internal/life_cycle.go +++ b/images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/internal/life_cycle.go @@ -88,7 +88,10 @@ func (h LifeCycleHandler) Handle(ctx context.Context, req reconcile.Request, dep // Put full result JSON into annotation on deployment. annotations.AddAnnotation(deploy, annotations.AnnDVCRGarbageCollectionResult, h.dvcrService.GetGarbageCollectionResult(secret)) // It is now possible to delete a secret. - return reconcile.Result{}, h.dvcrService.DeleteGarbageCollectionSecret(ctx) + // Test: add delay to catch race condition delete secret -> hook change values -> helm apply new version of deploy/dvcr. + err = h.dvcrService.DeleteGarbageCollectionSecret(ctx) + time.Sleep(time.Second * 10) + return reconcile.Result{}, err } if h.dvcrService.IsGarbageCollectionStarted(secret) {