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

🐛 Ensure one cma is processed by one addon worker at the same time #654

Merged
Merged
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
11 changes: 3 additions & 8 deletions pkg/addon/controllers/addonconfiguration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewAddonConfigurationController(
queue.QueueKeyByMetaNamespaceName,
c.addonFilterFunc,
clusterManagementAddonInformers.Informer()).
WithInformersQueueKeysFunc(queue.QueueKeyByMetaNamespaceName, addonInformers.Informer()).
WithInformersQueueKeysFunc(queue.QueueKeyByMetaName, addonInformers.Informer()).
Copy link
Member Author

@zhujian7 zhujian7 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the key point of this PR. mca changes, only enqueue the name.

WithInformersQueueKeysFunc(
index.ClusterManagementAddonByPlacementDecisionQueueKey(clusterManagementAddonInformers), placementDecisionInformer.Informer()).
WithInformersQueueKeysFunc(
Expand All @@ -101,12 +101,7 @@ func NewAddonConfigurationController(

func (c *addonConfigurationController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
logger := klog.FromContext(ctx)
key := syncCtx.QueueKey()
_, addonName, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
// ignore addon whose key is invalid
return nil
}
addonName := syncCtx.QueueKey()
logger.V(4).Info("Reconciling addon", "addonName", addonName)

cma, err := c.clusterManagementAddonLister.Get(addonName)
Expand Down Expand Up @@ -157,7 +152,7 @@ func (c *addonConfigurationController) sync(ctx context.Context, syncCtx factory
}

if minRequeue < maxRequeueTime {
syncCtx.Queue().AddAfter(key, minRequeue)
syncCtx.Queue().AddAfter(addonName, minRequeue)
}

return nil
Expand Down
8 changes: 1 addition & 7 deletions pkg/addon/controllers/addonmanagement/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@ func NewAddonManagementController(

func (c *addonManagementController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
logger := klog.FromContext(ctx)
key := syncCtx.QueueKey()
_, addonName, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
// ignore addon whose key is invalid
return nil
}

addonName := syncCtx.QueueKey()
logger.V(4).Info("Reconciling addon", "addonName", addonName)

cma, err := c.clusterManagementAddonLister.Get(addonName)
Expand Down
8 changes: 1 addition & 7 deletions pkg/addon/controllers/addontemplate/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"

"open-cluster-management.io/addon-framework/pkg/addonfactory"
Expand Down Expand Up @@ -106,12 +105,7 @@ func (c *addonTemplateController) stopUnusedManagers(

func (c *addonTemplateController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
logger := klog.FromContext(ctx)
key := syncCtx.QueueKey()
_, addonName, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
// ignore addon whose key is not in format: namespace/name
return nil
}
addonName := syncCtx.QueueKey()

cma, err := c.cmaLister.Get(addonName)
if err != nil {
Expand Down
Loading