When we increase the semaphore, we have already scheduled the strand for
now.
If the label is just waiting for the semaphore to increase, there's no
need for short naps.
Most of our wait labels are just waiting for the semaphore to increase,
so I extended their naps to 6 hours.
It will help decrease the load on the respirate on production
[^1]: 28dacb968b/model/semaphore.rb (L10)
89 lines
2.1 KiB
Ruby
89 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../../lib/util"
|
|
|
|
class Prog::Minio::MinioPoolNexus < Prog::Base
|
|
subject_is :minio_pool
|
|
|
|
def self.assemble(cluster_id, start_index, server_count, drive_count, storage_size_gib, vm_size)
|
|
unless MinioCluster[cluster_id]
|
|
fail "No existing cluster"
|
|
end
|
|
|
|
DB.transaction do
|
|
ubid = MinioPool.generate_ubid
|
|
|
|
minio_pool = MinioPool.create(
|
|
cluster_id: cluster_id,
|
|
start_index: start_index,
|
|
server_count: server_count,
|
|
drive_count: drive_count,
|
|
storage_size_gib: storage_size_gib,
|
|
vm_size: vm_size
|
|
) { _1.id = ubid.to_uuid }
|
|
|
|
minio_pool.server_count.times do |i|
|
|
Prog::Minio::MinioServerNexus.assemble(minio_pool.id, minio_pool.start_index + i)
|
|
end
|
|
Strand.create(prog: "Minio::MinioPoolNexus", label: "wait_servers") { _1.id = minio_pool.id }
|
|
end
|
|
end
|
|
|
|
def self.assemble_additional_pool(cluster_id, server_count, drive_count, storage_size_gib, vm_size)
|
|
DB.transaction do
|
|
unless MinioCluster[cluster_id]
|
|
fail "No existing cluster"
|
|
end
|
|
|
|
start_index = MinioCluster[cluster_id].servers.max_by(&:index).index + 1
|
|
st = assemble(cluster_id, start_index, server_count, drive_count, storage_size_gib, vm_size)
|
|
st.subject.incr_add_additional_pool
|
|
st
|
|
end
|
|
end
|
|
|
|
def before_run
|
|
when_destroy_set? do
|
|
unless ["destroy", "wait_servers_destroyed"].include?(strand.label)
|
|
hop_destroy
|
|
end
|
|
end
|
|
end
|
|
|
|
def cluster
|
|
@cluster ||= minio_pool.cluster
|
|
end
|
|
|
|
label def wait_servers
|
|
if minio_pool.servers.all? { _1.strand.label == "wait" }
|
|
when_add_additional_pool_set? do
|
|
decr_add_additional_pool
|
|
cluster.incr_reconfigure
|
|
end
|
|
|
|
hop_wait
|
|
end
|
|
|
|
nap 5
|
|
end
|
|
|
|
label def wait
|
|
nap 6 * 60 * 60
|
|
end
|
|
|
|
label def destroy
|
|
register_deadline(nil, 10 * 60)
|
|
decr_destroy
|
|
minio_pool.servers.each(&:incr_destroy)
|
|
|
|
hop_wait_servers_destroyed
|
|
end
|
|
|
|
label def wait_servers_destroyed
|
|
nap 5 unless minio_pool.servers.empty?
|
|
|
|
minio_pool.destroy
|
|
pop "pool destroyed"
|
|
end
|
|
end
|