Resolve "Backport #1124:Alter order of HR and lease lookup in allocation engine when looking for a free lease"
Closes #1141 (closed). This ports the change from #1124 (closed) to v1_6 branch.
Closes #1141 (closed). This ports the change from #1124 (closed) to v1_6 branch.