Skip to content

Commit

Permalink
Pass deepCopy objects to the polling goroutines (#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
zroubalik authored May 25, 2021
1 parent 503de68 commit aa0b7d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
### Other

- Adding OpenStack Swift scaler end-to-end tests ([#1522](https://github.com/kedacore/keda/pull/1522))
- Pass deepCopy objects to the polling goroutines ([#1812](https://github.com/kedacore/keda/pull/1812))

## v2.2.0

Expand Down
12 changes: 10 additions & 2 deletions pkg/scaling/scale_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,16 @@ func (h *scaleHandler) HandleScalableObject(scalableObject interface{}) error {

// a mutex is used to synchronize scale requests per scalableObject
scalingMutex := &sync.Mutex{}
go h.startPushScalers(ctx, withTriggers, scalableObject, scalingMutex)
go h.startScaleLoop(ctx, withTriggers, scalableObject, scalingMutex)

// passing deep copy of ScaledObject/ScaledJob to the scaleLoop go routines, it's a precaution to not have global objects shared between threads
switch obj := scalableObject.(type) {
case *kedav1alpha1.ScaledObject:
go h.startPushScalers(ctx, withTriggers, obj.DeepCopy(), scalingMutex)
go h.startScaleLoop(ctx, withTriggers, obj.DeepCopy(), scalingMutex)
case *kedav1alpha1.ScaledJob:
go h.startPushScalers(ctx, withTriggers, obj.DeepCopy(), scalingMutex)
go h.startScaleLoop(ctx, withTriggers, obj.DeepCopy(), scalingMutex)
}
return nil
}

Expand Down

0 comments on commit aa0b7d4

Please sign in to comment.