remove unused code
Signed-off-by: huiwq1990 <huiwq1990@163.com>
This commit is contained in:
parent
dd7bdc2403
commit
d96ac4e222
|
@ -62,10 +62,6 @@ type ResourceDetector struct {
|
||||||
// a reconcile function to consume the items in queue.
|
// a reconcile function to consume the items in queue.
|
||||||
bindingReconcileWorker util.AsyncWorker
|
bindingReconcileWorker util.AsyncWorker
|
||||||
|
|
||||||
// clusterBindingReconcileWorker maintains a rate limited queue which used to store ClusterResourceBinding's key and
|
|
||||||
// a reconcile function to consume the items in queue.
|
|
||||||
clusterBindingReconcileWorker util.AsyncWorker
|
|
||||||
|
|
||||||
RESTMapper meta.RESTMapper
|
RESTMapper meta.RESTMapper
|
||||||
|
|
||||||
// waitingObjects tracks of objects which haven't be propagated yet as lack of appropriate policies.
|
// waitingObjects tracks of objects which haven't be propagated yet as lack of appropriate policies.
|
||||||
|
@ -97,8 +93,6 @@ func (d *ResourceDetector) Start(ctx context.Context) error {
|
||||||
// setup binding reconcile worker
|
// setup binding reconcile worker
|
||||||
d.bindingReconcileWorker = util.NewAsyncWorker("binding reconciler", time.Microsecond, ClusterWideKeyFunc, d.ReconcileResourceBinding)
|
d.bindingReconcileWorker = util.NewAsyncWorker("binding reconciler", time.Microsecond, ClusterWideKeyFunc, d.ReconcileResourceBinding)
|
||||||
d.bindingReconcileWorker.Run(1, d.stopCh)
|
d.bindingReconcileWorker.Run(1, d.stopCh)
|
||||||
d.clusterBindingReconcileWorker = util.NewAsyncWorker("cluster binding reconciler", time.Microsecond, ClusterWideKeyFunc, d.ReconcileClusterResourceBinding)
|
|
||||||
d.clusterBindingReconcileWorker.Run(1, d.stopCh)
|
|
||||||
|
|
||||||
// watch and enqueue binding changes.
|
// watch and enqueue binding changes.
|
||||||
bindingHandler := informermanager.NewHandlerOnEvents(d.OnResourceBindingAdd, d.OnResourceBindingUpdate, d.OnResourceBindingDelete)
|
bindingHandler := informermanager.NewHandlerOnEvents(d.OnResourceBindingAdd, d.OnResourceBindingUpdate, d.OnResourceBindingDelete)
|
||||||
|
@ -546,7 +540,6 @@ func (d *ResourceDetector) BuildClusterResourceBinding(object *unstructured.Unst
|
||||||
Resource: workv1alpha1.ObjectReference{
|
Resource: workv1alpha1.ObjectReference{
|
||||||
APIVersion: object.GetAPIVersion(),
|
APIVersion: object.GetAPIVersion(),
|
||||||
Kind: object.GetKind(),
|
Kind: object.GetKind(),
|
||||||
Namespace: object.GetNamespace(),
|
|
||||||
Name: object.GetName(),
|
Name: object.GetName(),
|
||||||
ResourceVersion: object.GetResourceVersion(),
|
ResourceVersion: object.GetResourceVersion(),
|
||||||
},
|
},
|
||||||
|
@ -900,12 +893,7 @@ func (d *ResourceDetector) ReconcileResourceBinding(key util.QueueKey) error {
|
||||||
|
|
||||||
// OnClusterResourceBindingAdd handles object add event.
|
// OnClusterResourceBindingAdd handles object add event.
|
||||||
func (d *ResourceDetector) OnClusterResourceBindingAdd(obj interface{}) {
|
func (d *ResourceDetector) OnClusterResourceBindingAdd(obj interface{}) {
|
||||||
key, err := ClusterWideKeyFunc(obj)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
d.clusterBindingReconcileWorker.AddRateLimited(key)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnClusterResourceBindingUpdate handles object update event and push the object to queue.
|
// OnClusterResourceBindingUpdate handles object update event and push the object to queue.
|
||||||
|
@ -935,34 +923,6 @@ func (d *ResourceDetector) OnResourceBindingDelete(obj interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReconcileClusterResourceBinding handles ResourceBinding object changes.
|
|
||||||
// For each ClusterResourceBinding changes, we will try to calculate the summary status and update to original object
|
|
||||||
// that the ClusterResourceBinding refer to.
|
|
||||||
func (d *ResourceDetector) ReconcileClusterResourceBinding(key util.QueueKey) error {
|
|
||||||
ckey, ok := key.(keys.ClusterWideKey)
|
|
||||||
if !ok { // should not happen
|
|
||||||
klog.Error("Found invalid key when reconciling cluster resource binding.")
|
|
||||||
return fmt.Errorf("invalid key")
|
|
||||||
}
|
|
||||||
|
|
||||||
binding := &workv1alpha1.ClusterResourceBinding{}
|
|
||||||
if err := d.Client.Get(context.TODO(), client.ObjectKey{Name: ckey.Name}, binding); err != nil {
|
|
||||||
if apierrors.IsNotFound(err) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
klog.Infof("Reconciling cluster resource binding(%s)", binding.Name)
|
|
||||||
switch binding.Spec.Resource.Kind {
|
|
||||||
case util.DeploymentKind:
|
|
||||||
return d.AggregateDeploymentStatus(binding.Spec.Resource, binding.Status.AggregatedStatus)
|
|
||||||
default:
|
|
||||||
// Unsupported resource type.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AggregateDeploymentStatus summarize deployment status and update to original objects.
|
// AggregateDeploymentStatus summarize deployment status and update to original objects.
|
||||||
func (d *ResourceDetector) AggregateDeploymentStatus(objRef workv1alpha1.ObjectReference, status []workv1alpha1.AggregatedStatusItem) error {
|
func (d *ResourceDetector) AggregateDeploymentStatus(objRef workv1alpha1.ObjectReference, status []workv1alpha1.AggregatedStatusItem) error {
|
||||||
if objRef.APIVersion != "apps/v1" {
|
if objRef.APIVersion != "apps/v1" {
|
||||||
|
|
Loading…
Reference in New Issue