Skip to content

Commit

Permalink
Merge pull request #2272 from loft-sh/backport/v0.21/pr-2269
Browse files Browse the repository at this point in the history
[v0.21] Merge pull request #2269 from zerbitx/remove-extra-cache-updates
  • Loading branch information
FabianKramm authored Nov 11, 2024
2 parents 6446ff0 + df8be50 commit 0c5dde7
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 15 deletions.
2 changes: 0 additions & 2 deletions pkg/controllers/resources/persistentvolumeclaims/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func recreatePersistentVolumeClaim(ctx *synccontext.SyncContext, virtualClient c
}

// make sure we don't set the resource version during create
ctx.ObjectCache.Virtual().Delete(vPVC)
vPVC = vPVC.DeepCopy()
vPVC.ResourceVersion = ""
vPVC.UID = ""
Expand All @@ -285,6 +284,5 @@ func recreatePersistentVolumeClaim(ctx *synccontext.SyncContext, virtualClient c
return nil, errors.Wrap(err, "create pvc")
}

ctx.ObjectCache.Virtual().Put(vPVC)
return vPVC, nil
}
3 changes: 1 addition & 2 deletions pkg/controllers/resources/pods/ephemeral_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *podSyncer) syncEphemeralContainers(ctx *synccontext.SyncContext, physic

// do the actual update
ctx.Log.Infof("Update ephemeral containers for pod %s/%s", physicalPod.Namespace, physicalPod.Name)
updatedPod, err := physicalClusterClient.CoreV1().Pods(physicalPod.Namespace).UpdateEphemeralContainers(ctx, physicalPod.Name, physicalPod, metav1.UpdateOptions{})
_, err = physicalClusterClient.CoreV1().Pods(physicalPod.Namespace).UpdateEphemeralContainers(ctx, physicalPod.Name, physicalPod, metav1.UpdateOptions{})
if err != nil {
// The api-server will return a 404 when the EphemeralContainers feature is disabled because the `/ephemeralcontainers` subresource
// is missing. Unlike the 404 returned by a missing physicalPod, the status details will be empty.
Expand All @@ -75,6 +75,5 @@ func (s *podSyncer) syncEphemeralContainers(ctx *synccontext.SyncContext, physic
return false, fmt.Errorf("update ephemeral containers: %w", err)
}

ctx.ObjectCache.Host().Put(updatedPod)
return true, nil
}
1 change: 0 additions & 1 deletion pkg/controllers/resources/pods/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,5 @@ func (s *podSyncer) assignNodeToPod(ctx *synccontext.SyncContext, pObj *corev1.P
return err
}

ctx.ObjectCache.Virtual().Put(vPod)
return nil
}
2 changes: 0 additions & 2 deletions pkg/controllers/resources/services/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func recreateService(ctx *synccontext.SyncContext, virtualClient client.Client,
}

// make sure we don't set the resource version during create
ctx.ObjectCache.Virtual().Delete(vService)
vService = vService.DeepCopy()
vService.ResourceVersion = ""
vService.UID = ""
Expand All @@ -257,7 +256,6 @@ func recreateService(ctx *synccontext.SyncContext, virtualClient client.Client,
return err
}

ctx.ObjectCache.Virtual().Put(vService)
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/controllers/resources/volumesnapshotcontents/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func (s *volumeSnapshotContentSyncer) Sync(ctx *synccontext.SyncContext, event *
if err != nil {
return ctrl.Result{}, err
}
ctx.ObjectCache.Virtual().Put(updated)
}

if !equality.Semantic.DeepEqual(event.Virtual.Status, event.Host.Status) {
Expand All @@ -137,7 +136,6 @@ func (s *volumeSnapshotContentSyncer) Sync(ctx *synccontext.SyncContext, event *
if err != nil && !kerrors.IsNotFound(err) {
return ctrl.Result{}, err
}
ctx.ObjectCache.Virtual().Put(updated)
}

return ctrl.Result{RequeueAfter: time.Second}, nil
Expand Down
6 changes: 0 additions & 6 deletions pkg/controllers/resources/volumesnapshots/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ func (s *volumeSnapshotSyncer) SyncToHost(ctx *synccontext.SyncContext, event *s
if err != nil {
return ctrl.Result{}, err
}

ctx.ObjectCache.Virtual().Put(event.Virtual)
}

return patcher.DeleteVirtualObject(ctx, event.Virtual, event.HostOld, "host object was deleted")
Expand Down Expand Up @@ -115,8 +113,6 @@ func (s *volumeSnapshotSyncer) Sync(ctx *synccontext.SyncContext, event *synccon
if err != nil {
return ctrl.Result{}, err
}

ctx.ObjectCache.Virtual().Put(updated)
}

if !equality.Semantic.DeepEqual(event.Virtual.Status, event.Host.Status) {
Expand All @@ -127,8 +123,6 @@ func (s *volumeSnapshotSyncer) Sync(ctx *synccontext.SyncContext, event *synccon
if err != nil && !kerrors.IsNotFound(err) {
return ctrl.Result{}, err
}

ctx.ObjectCache.Virtual().Put(updated)
}

return ctrl.Result{}, nil
Expand Down

0 comments on commit 0c5dde7

Please sign in to comment.