Files
ubicloud/migrate/20230415_add_vm_allocation_counters.rb
Enes Cakir 02c8a89c29 Switch TimestampMigrator from IntegerMigrator
IntegerMigrator doesn't allow duplicate migrations (1_foo, 1_bar).
Requires manual renaming for simultaneous migrations.

Here's comparison in detail:
https://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html#label-Two+separate+migrators

The TimestampMigrator will be used if any filename in the migrations
directory has a version greater than 20000101.

IntegerMigrator keeps version information at scheme_info table with an
integer. But TimestampMigrator keeps version information at
scheme_migrations tables with all filenames.

It's not backward compatible. You need to reset your database or create
and fill scheme_migrations table manually, then drop scheme_info table.
2023-07-05 11:15:03 -07:00

26 lines
1.0 KiB
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
alter_table(:vm_host) do
# N.B. this is an expedient, such a simple counter cannot handle
# more complex NUMA topological allocations. For example, on a
# Ampere Altra, there are 20 processors per NUMA node and four
# nodes in a socket. Through a series of allocations and
# deallocations, you will have a sub-optimal situation where you
# cannot concentrate a guest workload on as few or as symmetric
# NUMA nodes and accompanying memory as would otherwise be
# possible.
add_column :used_cores, Integer, null: false, default: 0
# Do not allocate one core on each host. This currently presumed
# to be enough to offset host memory overheads, though that
# simplification will require improvements later.
add_constraint(:core_allocation_limit) { used_cores < total_cores }
# Catch over-deallocation bugs.
add_constraint(:used_cores_above_zero) { used_cores >= 0 }
end
end
end