Skip to content

Commit

Permalink
Remove CL Item ContentVersion short circuit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bryan Venteicher committed Jan 8, 2025
1 parent bde56e4 commit 56e758e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 56e758e

Please sign in to comment.