From 56e758eff8f750961b84eb8d70e22509a5d4fa77 Mon Sep 17 00:00:00 2001 From: Bryan Venteicher Date: Wed, 8 Jan 2025 11:34:20 -0600 Subject: [PATCH] Remove CL Item ContentVersion short circuit To avoid repeated CL Item sync tasks, we'll compare the item and image cached content versions, and skip fetching the OVF envelope if they match. But since we've added fields to the image Status (like Disks[]) in v1a3, those new fields won't be updated until the item changes. The big hammer for this is to just remove the check instead of including another internal version in the cached version. Short term, this will cause an increase in the number of sync tasks, but the existing OVF cache will reduce that somewhat. There is a larger WIP in this area that will fix this bug without the increase in sync tasks. --- .../clustercontentlibraryitem_controller.go | 6 +----- .../clustercontentlibraryitem_controller_unit_test.go | 2 +- .../contentlibraryitem/contentlibraryitem_controller.go | 6 +----- .../contentlibraryitem_controller_unit_test.go | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller.go b/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller.go index b88079a37..67c1f2a98 100644 --- a/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller.go +++ b/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller.go @@ -317,10 +317,6 @@ func (r *Reconciler) setUpCVMIFromCCLItem(ctx *pkgctx.ClusterContentLibraryItemC func (r *Reconciler) syncImageContent(ctx *pkgctx.ClusterContentLibraryItemContext) error { cclItem := ctx.CCLItem cvmi := ctx.CVMI - latestVersion := cclItem.Status.ContentVersion - if cvmi.Status.ProviderContentVersion == latestVersion { - return nil - } err := r.VMProvider.SyncVirtualMachineImage(ctx, cclItem, cvmi) if err != nil { @@ -329,7 +325,7 @@ func (r *Reconciler) syncImageContent(ctx *pkgctx.ClusterContentLibraryItemConte vmopv1.VirtualMachineImageNotSyncedReason, "Failed to sync to the latest content version from provider") } else { - cvmi.Status.ProviderContentVersion = latestVersion + cvmi.Status.ProviderContentVersion = cclItem.Status.ContentVersion } // Sync the image's type, OS information and capabilities to the resource's diff --git a/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller_unit_test.go b/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller_unit_test.go index 4433d1980..f27f3cc7c 100644 --- a/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller_unit_test.go +++ b/controllers/contentlibrary/clustercontentlibraryitem/clustercontentlibraryitem_controller_unit_test.go @@ -255,7 +255,7 @@ func unitTestsReconcile() { }) }) - When("ClusterVirtualMachineImage resource is created and already up-to-date", func() { + XWhen("ClusterVirtualMachineImage resource is created and already up-to-date", func() { JustBeforeEach(func() { cvmi := &vmopv1.ClusterVirtualMachineImage{ diff --git a/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller.go b/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller.go index 9d9d950e5..c36b4f862 100644 --- a/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller.go +++ b/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller.go @@ -285,10 +285,6 @@ func (r *Reconciler) setUpVMIFromCLItem(ctx *pkgctx.ContentLibraryItemContext) e func (r *Reconciler) syncImageContent(ctx *pkgctx.ContentLibraryItemContext) error { clItem := ctx.CLItem vmi := ctx.VMI - latestVersion := clItem.Status.ContentVersion - if vmi.Status.ProviderContentVersion == latestVersion { - return nil - } err := r.VMProvider.SyncVirtualMachineImage(ctx, clItem, vmi) if err != nil { @@ -297,7 +293,7 @@ func (r *Reconciler) syncImageContent(ctx *pkgctx.ContentLibraryItemContext) err vmopv1.VirtualMachineImageNotSyncedReason, "Failed to sync to the latest content version from provider") } else { - vmi.Status.ProviderContentVersion = latestVersion + vmi.Status.ProviderContentVersion = clItem.Status.ContentVersion } // Sync the image's type, OS information and capabilities to the resource's diff --git a/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller_unit_test.go b/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller_unit_test.go index 56d7ca54a..bb21fd8ac 100644 --- a/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller_unit_test.go +++ b/controllers/contentlibrary/contentlibraryitem/contentlibraryitem_controller_unit_test.go @@ -232,7 +232,7 @@ func unitTestsReconcile() { }) }) - When("VirtualMachineImage resource is created and already up-to-date", func() { + XWhen("VirtualMachineImage resource is created and already up-to-date", func() { JustBeforeEach(func() { vmi := &vmopv1.VirtualMachineImage{