-
Stan Hu authored
When `IdleCount` is 0, machines are always created on-demand before each job (if there is no available machine in Idle state). However, when `IdleCount` were set to 0 and `limit` were set to a positive value, the Runner would ignore the `limit` and attempt to allocate a machine each time. This change fixes that problem by updating `idleLimitStrategy` with a new function, `canCreateOnDemand`, to complement `canCreateIdle`. The latter returns true if there is capacity to create idle machines for pre-scaling, while the former returns true if there is capacity for on-demand jobs. We need to make this distinction to ensure that setting `idleCount` to 0 does not create an infinite number of idle machines in pre-scaling. When a build attempts to `Acquire` a machine, we now call `canCreateOnDemand` to check whether there is capacity to create a machine. We need to do this check before the runner proceeds to the `Prepare` stage where `Use` wou...