Autoscale in on-demand mode doesn't seem to shut down the last idle machine

I'm testing autoscaling using version 1.1.0~beta.135.g24365ee. In my application, I'd like to use on-demand machines, as my builds are infrequent. So once the builds are done and the configured IdleTime has expired, gitlab-runner should terminate all of the runner machines. My config looks like this:

[[runners]]
  name = "maxwell-docker"
  url = "https://my.gitlab.url/ci"
  token = "my_token"
  executor = "docker+machine"
  limit = 50
  [runners.ssh]
  [runners.docker]
    tls_verify = false
    image = ""
    privileged = false
    disable_cache = false
  [runners.parallels]
    base_name = ""
    disable_snapshots = false
  [runners.virtualbox]
    base_name = ""
    disable_snapshots = false
  [runners.cache]
    Insecure = false
  [runners.machine]
    IdleCount = 0
    IdleTime = 300
    MachineName = "ci-docker-%s"
    MachineDriver = "google"

The good news is that the autoscaling does work! As I trigger builds, new machines are brought online to service them as needed. However, it doesn't seem to shut down all of the machines when they aren't needed any more. I tried the following:

  • I triggered 2 builds in quick sequence. This caused the runner to create 2 machines to do the builds. After the builds were done and the IdleTime expired, it terminated the second machine, but left the first one running.

  • I triggered a single build. This caused the runner to create 1 machine to do the build. After the build was done and the IdleTime expired, it never terminated the machine.

It seems like there might be an off-by-one logic error somewhere, but it's not apparent to me where it is. Perhaps I'm doing something wrong?