diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index 2c7a6d975..fe067fd43 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -273,8 +273,7 @@ func (c *Controller) updateAppliedCondition(work *workv1alpha1.Work, status meta } updated := &workv1alpha1.Work{} if err = c.Get(context.TODO(), client.ObjectKey{Namespace: work.Namespace, Name: work.Name}, updated); err == nil { - // make a copy, so we don't mutate the shared cache - work = updated.DeepCopy() + work = updated } else { klog.Errorf("Failed to get updated work %s/%s: %v", work.Namespace, work.Name, err) } diff --git a/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go b/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go index 8d154f418..af63e1e31 100644 --- a/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go +++ b/pkg/controllers/federatedresourcequota/federated_resource_quota_status_controller.go @@ -153,8 +153,7 @@ func (c *StatusController) collectQuotaStatus(quota *policyv1alpha1.FederatedRes updated := &policyv1alpha1.FederatedResourceQuota{} if err = c.Get(context.TODO(), client.ObjectKey{Namespace: quota.Namespace, Name: quota.Name}, updated); err == nil { - // make a copy, so we don't mutate the shared cache - quota = updated.DeepCopy() + quota = updated } else { klog.Errorf("Failed to get updated federatedResourceQuota(%s): %v", klog.KObj(quota).String(), err) } diff --git a/pkg/controllers/status/cluster_status_controller.go b/pkg/controllers/status/cluster_status_controller.go index 14734f156..3c7eb4b11 100644 --- a/pkg/controllers/status/cluster_status_controller.go +++ b/pkg/controllers/status/cluster_status_controller.go @@ -269,8 +269,7 @@ func (c *ClusterStatusController) updateStatusIfNeeded(cluster *clusterv1alpha1. updated := &clusterv1alpha1.Cluster{} if err = c.Get(context.TODO(), client.ObjectKey{Namespace: cluster.Namespace, Name: cluster.Name}, updated); err == nil { - // make a copy, so we don't mutate the shared cache - cluster = updated.DeepCopy() + cluster = updated } else { klog.Errorf("Failed to get updated cluster %s: %v", cluster.Name, err) } diff --git a/pkg/controllers/status/work_status_controller.go b/pkg/controllers/status/work_status_controller.go index a208219f2..1daa96411 100644 --- a/pkg/controllers/status/work_status_controller.go +++ b/pkg/controllers/status/work_status_controller.go @@ -336,8 +336,7 @@ func (c *WorkStatusController) reflectStatus(work *workv1alpha1.Work, clusterObj updated := &workv1alpha1.Work{} if err = c.Get(context.TODO(), client.ObjectKey{Namespace: workCopy.Namespace, Name: workCopy.Name}, updated); err == nil { - //make a copy, so we don't mutate the shared cache - workCopy = updated.DeepCopy() + workCopy = updated } else { klog.Errorf("Failed to get updated work %s/%s: %v", workCopy.Namespace, workCopy.Name, err) } diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index d8fa59c71..cae2f553f 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -441,8 +441,7 @@ func (d *DependenciesDistributor) recordDependenciesForIndependentBinding(bindin updated := &workv1alpha2.ResourceBinding{} if err = d.Client.Get(context.TODO(), client.ObjectKey{Namespace: binding.Namespace, Name: binding.Name}, updated); err == nil { - //make a copy, so we don't mutate the shared cache - binding = updated.DeepCopy() + binding = updated } else { klog.Errorf("Failed to get updated binding %s/%s: %v", binding.Namespace, binding.Name, err) } diff --git a/pkg/detector/detector.go b/pkg/detector/detector.go index d550e88da..6fca05159 100644 --- a/pkg/detector/detector.go +++ b/pkg/detector/detector.go @@ -1137,8 +1137,7 @@ func (d *ResourceDetector) CleanupResourceBindingLabels(rb *workv1alpha2.Resourc updated := &workv1alpha2.ResourceBinding{} if err = d.Client.Get(context.TODO(), client.ObjectKey{Namespace: rb.GetNamespace(), Name: rb.GetName()}, updated); err == nil { - //make a copy, so we don't mutate the shared cache - rb = updated.DeepCopy() + rb = updated } else { klog.Errorf("Failed to get updated resource binding %s/%s: %v", rb.GetNamespace(), rb.GetName(), err) } @@ -1162,8 +1161,7 @@ func (d *ResourceDetector) CleanupClusterResourceBindingLabels(crb *workv1alpha2 updated := &workv1alpha2.ClusterResourceBinding{} if err = d.Client.Get(context.TODO(), client.ObjectKey{Name: crb.GetName()}, updated); err == nil { - //make a copy, so we don't mutate the shared cache - crb = updated.DeepCopy() + crb = updated } else { klog.Errorf("Failed to get updated cluster resource binding %s: %v", crb.GetName(), err) } diff --git a/pkg/util/helper/workstatus.go b/pkg/util/helper/workstatus.go index c87842a38..a033c6c05 100644 --- a/pkg/util/helper/workstatus.go +++ b/pkg/util/helper/workstatus.go @@ -79,8 +79,7 @@ func AggregateResourceBindingWorkStatus( updated := &workv1alpha2.ResourceBinding{} if err = c.Get(context.TODO(), client.ObjectKey{Namespace: binding.Namespace, Name: binding.Name}, updated); err == nil { - // make a copy, so we don't mutate the shared cache - binding = updated.DeepCopy() + binding = updated } else { klog.Errorf("Failed to get updated binding %s/%s: %v", binding.Namespace, binding.Name, err) } @@ -138,8 +137,7 @@ func AggregateClusterResourceBindingWorkStatus( updated := &workv1alpha2.ClusterResourceBinding{} if err = c.Get(context.TODO(), client.ObjectKey{Name: binding.Name}, updated); err == nil { - // make a copy, so we don't mutate the shared cache - binding = updated.DeepCopy() + binding = updated } else { klog.Errorf("Failed to get updated binding %s/%s: %v", binding.Namespace, binding.Name, err) }