Skip to content

Commit

Permalink
move txnID to global
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyulin0719 committed Jun 20, 2024
1 parent c48d3df commit c19db92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/cache/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import (

const registerNodeContextHandler = "RegisterNodeContextHandler"

var global_txnID atomic.Uint64

var (
ErrorPodNotFound = errors.New("predicates were not run because pod was not found in cache")
ErrorNodeNotFound = errors.New("predicates were not run because node was not found in cache")
Expand All @@ -73,8 +75,8 @@ type Context struct {
namespace string // yunikorn namespace
configMaps []*v1.ConfigMap // cached yunikorn configmaps
lock *locking.RWMutex // lock
txnID atomic.Uint64 // transaction ID counter
klogger klog.Logger
// txnID atomic.Uint64 // transaction ID counter
klogger klog.Logger
}

// NewContext create a new context for the scheduler using a default (empty) configuration
Expand Down Expand Up @@ -1569,7 +1571,7 @@ func (ctx *Context) registerNodes(nodes []*v1.Node) ([]*v1.Node, error) {
wg.Add(len(pendingNodes))

// register with the dispatcher so that we can track our response
handlerID := fmt.Sprintf("%s-%d", registerNodeContextHandler, ctx.txnID.Add(1))
handlerID := fmt.Sprintf("%s-%d", registerNodeContextHandler, global_txnID.Add(1))
dispatcher.RegisterEventHandler(handlerID, dispatcher.EventTypeNode, func(event interface{}) {
nodeEvent, ok := event.(CachedSchedulerNodeEvent)
if !ok {
Expand Down

0 comments on commit c19db92

Please sign in to comment.