fix Missing filter (#151)

Signed-off-by: tytao <1522014784@qq.com>

Signed-off-by: tytao <1522014784@qq.com>
This commit is contained in:
TYTaO
2022-09-02 04:34:41 +08:00
committed by GitHub
parent 787d7c5d45
commit 6a0f69fd47
3 changed files with 12 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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,