Files
ubicloud/migrate/20240118_core_constraint.rb
Hadi Moshayedi 80ef4a6dce Relax core_allocation_limit to allow allocating all host cores.
Previously, we didn't allocate one core on each host to offset host
memory overheads. Given that we will use 2 cores per host for SPDK using
only 1G, we can relax this constraint.

On a 64-core host, 2 cores will be allocated for SPDK, which will leave
room for (64-2)/2 = 31 standard-2 VMs. The previous constraint left room
for (63-2)/2 = 30 standard-2 VMs.
2024-01-19 10:28:24 -08:00

20 lines
647 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
alter_table(:vm_host) do
# Previously, we didn't allocate one core on each host to offset host
# memory overheads. Given that we will use 1 core (=2 vcpus) per host for
# SPDK using only 1G, we can relax this constraint.
drop_constraint :core_allocation_limit
add_constraint(:core_allocation_limit) { used_cores <= total_cores }
end
# We had missed to account for SPDK in previous hosts. SPDK uses 1 vcpu in
# all previous setups, which is one core.
run <<~SQL
UPDATE vm_host SET used_cores = used_cores + 1;
SQL
end
end