Situation: We want to run exactly 1 build on 1 machine. In order to do this we tried to set the limit of a working copy blueprint to the same number of machines in the relevant almanac service. When the working copy tries to lease a new host, it leases all the builds to the same host rather than spreading the load across all available hosts.
Expected Behaviour: When at capacity k < n and a new working copy resource is requested by a lease. A new host resource is created and a new working copy resource is created on the new machine.
Actual Behaviour: All working copies are created on the first (and only) host.
Reproduction Steps:
- Set up an installation with 2 devices, ec1 and ec2.
- Create a new service (linux) and add both devices as bindings.
- In Drydock, create an Almanac Hosts blueprint for the linux service.
- On the command line, run ./drydock lease --type host twice and observe that two leases for the same host are created rather than one for each host.
Versions
phabricator b371e90364de0f8214567f3f820a3c26b7ea627c (Dec 20 2016) arcanist f1c45a3323ae20eefe29c0a22c7923fe8b151bbf (Jul 2 2016) phutil 5fd2cf9d5ddd38424a54a8fba02398d527639970 (Jul 9 2016) Local Version Bitnami Phabricator 20160725-0
Analysis: Looking at the code this seems to be the expected behaviour.
Specifically, looking in DrydockLeaseUpdateWorker.executeAllocator, $resources is initially set to the result of loadResourcesForAllocatingLease which queries which suitable resources are available and then filters them depending on how the canAcquireLeaseOnResource method is defined for that resource type. For hosts (in DrydockAlmanacSericeHostBlueprint) the method always returns true. Thus, if there is one active host, the whole body of code which initialises a new resource is skipped.