From 8843749bf26162879dcf960927942efd9120c736 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Tue, 15 Mar 2022 14:17:42 +0800 Subject: [PATCH 1/2] bugfix: enqueue the resource binding that has been scheduled to member clusters Signed-off-by: lihanbo --- .../dependencies_distributor.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index 60462266f..d34321ca1 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -163,7 +163,7 @@ func (d *DependenciesDistributor) Reconcile(key util.QueueKey) error { klog.Error("invalid key") return fmt.Errorf("invalid key") } - klog.Infof("DependenciesDistributor start to reconcile object: %s", clusterWideKey) + klog.V(4).Infof("DependenciesDistributor start to reconcile object: %s", clusterWideKey) bindingObjectList, err := d.resourceBindingLister.ByNamespace(clusterWideKey.Namespace).List(labels.Everything()) if err != nil { @@ -191,6 +191,7 @@ func (d *DependenciesDistributor) Reconcile(key util.QueueKey) error { continue } + klog.V(4).Infof("resource binding(%s/%s) is matched for resource(%s/%s)", binding.Namespace, binding.Name, clusterWideKey.Namespace, clusterWideKey.Name) bindingKey, err := detector.ClusterWideKeyFunc(binding) if err != nil { klog.Errorf("failed to generate cluster wide key for binding %s/%s: %v", binding.Namespace, binding.Name, err) @@ -256,11 +257,13 @@ func (d *DependenciesDistributor) OnResourceBindingUpdate(oldObj, newObj interfa } if oldBindingObject.Generation == newBindingObject.Generation { + klog.V(4).Infof("Dropping resource binding(%s/%s) as the Generation is not changed.", newBindingObject.Namespace, newBindingObject.Name) return } - // prevent newBindingObject from the queue if it's not in Scheduled condition - if !helper.IsBindingScheduled(&newBindingObject.Status) { + // prevent newBindingObject from the queue if it's not scheduled yet. + if len(oldBindingObject.Spec.Clusters) == 0 && len(newBindingObject.Spec.Clusters) == 0 { + klog.V(4).Infof("Dropping resource binding(%s/%s) as it is not scheduled yet.", newBindingObject.Namespace, newBindingObject.Name) return } @@ -308,6 +311,7 @@ func (d *DependenciesDistributor) ReconcileResourceBinding(key util.QueueKey) er return fmt.Errorf("invalid key") } + klog.V(4).Infof("Start to reconcile ResourceBinding(%s)", ckey.NamespaceKey()) unstructuredObj, err := d.resourceBindingLister.Get(ckey.NamespaceKey()) if err != nil { if apierrors.IsNotFound(err) { From f66e391ee76c6f35215aedbe19442f930e908389 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Thu, 17 Mar 2022 14:55:56 +0800 Subject: [PATCH 2/2] bugfix: update Resource info when update attached binding Signed-off-by: lihanbo --- pkg/dependenciesdistributor/dependencies_distributor.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index d34321ca1..05fc549c6 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -603,6 +603,7 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding updatedBindingSnapshot := mergeBindingSnapshot(existBinding.Spec.RequiredBy, attachedBinding.Spec.RequiredBy) existBinding.Spec.RequiredBy = updatedBindingSnapshot existBinding.Labels = util.DedupeAndMergeLabels(existBinding.Labels, attachedBinding.Labels) + existBinding.Spec.Resource = attachedBinding.Spec.Resource if err := d.Client.Update(context.TODO(), existBinding); err != nil { klog.Errorf("failed to update resource binding(%s/%s): %v", existBinding.Namespace, existBinding.Name, err)