Remove off by one with needed runners

Earlier we used a channel to store the runners. To make the environment
refresh block, we scheduled an additional runner as the buffered channel
was then filled up. As we don't use the channel anymore, we don't need
the additional runner anymore. Furthermore this leads to weird race
conditions in tests when comparing the runner count to the desired one.
This commit is contained in:
sirkrypt0
2021-06-02 12:13:31 +02:00
committed by Tobias Kantusch
parent 3d7b7e1761
commit b32e9c2a67
2 changed files with 2 additions and 2 deletions

View File

@ -138,7 +138,7 @@ func (m *NomadRunnerManager) refreshEnvironment(id EnvironmentId) {
log.WithError(err).Printf("Failed get allocation count")
break
}
additionallyNeededRunners := job.desiredIdleRunnersCount - uint(job.idleRunners.Length()) + 1
additionallyNeededRunners := job.desiredIdleRunnersCount - uint(job.idleRunners.Length())
requiredRunnerCount := jobScale
if additionallyNeededRunners > 0 {
requiredRunnerCount += additionallyNeededRunners

View File

@ -168,7 +168,7 @@ func (s *ManagerTestSuite) TestRefreshScalesJob() {
// use one runner to necessitate rescaling
_, _ = s.nomadRunnerManager.Claim(defaultEnvironmentId)
s.waitForRunnerRefresh()
s.apiMock.AssertCalled(s.T(), "SetJobScale", tests.DefaultJobId, defaultDesiredRunnersCount+1, "Runner Requested")
s.apiMock.AssertCalled(s.T(), "SetJobScale", tests.DefaultJobId, defaultDesiredRunnersCount, "Runner Requested")
}
func (s *ManagerTestSuite) TestRefreshAddsRunnerToPool() {