mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-19 23:57:57 +00:00
fix Missing filter (#151)
Signed-off-by: tytao <1522014784@qq.com> Signed-off-by: tytao <1522014784@qq.com>
This commit is contained in:
@@ -330,6 +330,14 @@ func AppliedManifestworkQueueKeyFunc(hubhash string) factory.ObjectQueueKeyFunc
|
||||
}
|
||||
}
|
||||
|
||||
// AppliedManifestworkHubHashFilter filter the appliedmanifestwork belonging to this hub
|
||||
func AppliedManifestworkHubHashFilter(hubHash string) factory.EventFilterFunc {
|
||||
return func(obj interface{}) bool {
|
||||
accessor, _ := meta.Accessor(obj)
|
||||
return strings.HasPrefix(accessor.GetName(), hubHash)
|
||||
}
|
||||
}
|
||||
|
||||
// HubHash returns a hash of hubserver
|
||||
// NOTE: the length of hash string is 64, meaning the length of manifestwork name should be less than 189
|
||||
func HubHash(hubServer string) string {
|
||||
|
||||
@@ -36,6 +36,7 @@ func NewAppliedManifestWorkFinalizeController(
|
||||
spokeDynamicClient dynamic.Interface,
|
||||
appliedManifestWorkClient workv1client.AppliedManifestWorkInterface,
|
||||
appliedManifestWorkInformer workinformer.AppliedManifestWorkInformer,
|
||||
hubHash string,
|
||||
) factory.Controller {
|
||||
|
||||
controller := &AppliedManifestWorkFinalizeController{
|
||||
@@ -46,10 +47,10 @@ func NewAppliedManifestWorkFinalizeController(
|
||||
}
|
||||
|
||||
return factory.New().
|
||||
WithInformersQueueKeyFunc(func(obj runtime.Object) string {
|
||||
WithFilteredEventsInformersQueueKeyFunc(func(obj runtime.Object) string {
|
||||
accessor, _ := meta.Accessor(obj)
|
||||
return accessor.GetName()
|
||||
}, appliedManifestWorkInformer.Informer()).
|
||||
}, helper.AppliedManifestworkHubHashFilter(hubHash), appliedManifestWorkInformer.Informer()).
|
||||
WithSync(controller.sync).ToController("AppliedManifestWorkFinalizer", recorder)
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ func (o *WorkloadAgentOptions) RunWorkloadAgent(ctx context.Context, controllerC
|
||||
spokeDynamicClient,
|
||||
spokeWorkClient.WorkV1().AppliedManifestWorks(),
|
||||
spokeWorkInformerFactory.Work().V1().AppliedManifestWorks(),
|
||||
hubhash,
|
||||
)
|
||||
manifestWorkFinalizeController := finalizercontroller.NewManifestWorkFinalizeController(
|
||||
controllerContext.EventRecorder,
|
||||
|
||||
Reference in New Issue
Block a user