Skip to content

Commit

Permalink
Ensure one cma is processed by one addon worker at the same time (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujian7 authored Oct 18, 2024
1 parent 6d68522 commit bc01437
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
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()).
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

0 comments on commit bc01437

Please sign in to comment.