Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

limit provision synchronous operation numbers #553

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions lib/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ const (
DefaultRetryPeriod = 2 * time.Second
// DefaultTermLimit is used when option function TermLimit is omitted
DefaultTermLimit = 30 * time.Second
// DefaultMaxProvisionOperationCount is used to set the max number of provision running provision Operations at the same time
DefaultMaxProvisionOperationCount = 20
)

var errRuntime = fmt.Errorf("cannot call option functions after controller has Run")
Expand Down Expand Up @@ -445,6 +447,10 @@ func (ctrl *ProvisionController) addClaim(obj interface{}) {
}

if ctrl.shouldProvision(claim) {
if len(ctrl.leaderElectors) >= DefaultMaxProvisionOperationCount {
glog.V(4).Infof("Provisioning opearations reach max %v, waiting until complete...", DefaultMaxProvisionOperationCount)
return
}
ctrl.leaderElectorsMutex.Lock()
le, ok := ctrl.leaderElectors[claim.UID]
ctrl.leaderElectorsMutex.Unlock()
Expand Down