Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(binding): disable deepcopy for list action #5813

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/controllers/binding/binding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/client-go/dynamic"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -190,7 +191,7 @@ func (c *ResourceBindingController) newOverridePolicyFunc() handler.MapFunc {
}

bindingList := &workv1alpha2.ResourceBindingList{}
if err := c.Client.List(ctx, bindingList); err != nil {
if err := c.Client.List(ctx, bindingList, &client.ListOptions{UnsafeDisableDeepCopy: ptr.To(true)}); err != nil {
klog.Errorf("Failed to list resourceBindings, error: %v", err)
return nil
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/dependenciesdistributor/dependencies_distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/retry"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -170,8 +171,10 @@ func (d *DependenciesDistributor) reconcileResourceTemplate(key util.QueueKey) e
klog.V(4).Infof("DependenciesDistributor start to reconcile object: %s", resourceTemplateKey)
bindingList := &workv1alpha2.ResourceBindingList{}
err := d.Client.List(context.TODO(), bindingList, &client.ListOptions{
Namespace: resourceTemplateKey.Namespace,
LabelSelector: labels.Everything()})
Namespace: resourceTemplateKey.Namespace,
LabelSelector: labels.Everything(),
UnsafeDisableDeepCopy: ptr.To(true),
})
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/overridemanager/overridemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -126,7 +127,7 @@ func (o *overrideManagerImpl) ApplyOverridePolicies(rawObj *unstructured.Unstruc
func (o *overrideManagerImpl) applyClusterOverrides(rawObj *unstructured.Unstructured, cluster *clusterv1alpha1.Cluster) (*AppliedOverrides, error) {
// get all cluster-scoped override policies
policyList := &policyv1alpha1.ClusterOverridePolicyList{}
if err := o.Client.List(context.TODO(), policyList, &client.ListOptions{}); err != nil {
if err := o.Client.List(context.TODO(), policyList, &client.ListOptions{UnsafeDisableDeepCopy: ptr.To(true)}); err != nil {
klog.Errorf("Failed to list cluster override policies, error: %v", err)
return nil, err
}
Expand Down Expand Up @@ -164,7 +165,7 @@ func (o *overrideManagerImpl) applyClusterOverrides(rawObj *unstructured.Unstruc
func (o *overrideManagerImpl) applyNamespacedOverrides(rawObj *unstructured.Unstructured, cluster *clusterv1alpha1.Cluster) (*AppliedOverrides, error) {
// get all namespace-scoped override policies
policyList := &policyv1alpha1.OverridePolicyList{}
if err := o.Client.List(context.TODO(), policyList, &client.ListOptions{Namespace: rawObj.GetNamespace()}); err != nil {
if err := o.Client.List(context.TODO(), policyList, &client.ListOptions{Namespace: rawObj.GetNamespace(), UnsafeDisableDeepCopy: ptr.To(true)}); err != nil {
klog.Errorf("Failed to list override policies from namespace: %s, error: %v", rawObj.GetNamespace(), err)
return nil, err
}
Expand Down