File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
components/node-labeler/cmd Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "net/http"
1313 "strconv"
1414 "strings"
15+ "sync"
1516 "time"
1617
1718 "github.com/bombsimon/logrusr/v2"
@@ -287,8 +288,9 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
287288
288289type NodeScaledownAnnotationController struct {
289290 client.Client
290- nodesToReconcile chan string
291- stopChan chan struct {}
291+ nodesToReconcile chan string
292+ stopChan chan struct {}
293+ nodeReconcileLock sync.Map
292294}
293295
294296func NewNodeScaledownAnnotationController (client client.Client ) (* NodeScaledownAnnotationController , error ) {
@@ -427,6 +429,12 @@ func (wc *NodeScaledownAnnotationController) reconcileAllNodes(ctx context.Conte
427429
428430// reconcileNode counts the workspaces running on a node and updates the autoscaler annotation accordingly
429431func (c * NodeScaledownAnnotationController ) reconcileNode (ctx context.Context , nodeName string ) error {
432+ mutexInterface , _ := c .nodeReconcileLock .LoadOrStore (nodeName , & sync.Mutex {})
433+ mutex := mutexInterface .(* sync.Mutex )
434+
435+ mutex .Lock ()
436+ defer mutex .Unlock ()
437+
430438 timer := prometheus .NewTimer (NodeScaledownAnnotationReconcileDuration .WithLabelValues ("node" ))
431439 defer timer .ObserveDuration ()
432440
You can’t perform that action at this time.
0 commit comments