Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push instead of single buds #1179

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 11 additions & 28 deletions prog/vm/host_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ def before_run

label def start
register_deadline(:wait, 15 * 60)
hop_prep if retval&.dig("msg") == "rhizome user bootstrapped and source installed"

bud Prog::BootstrapRhizome, {"target_folder" => "host"}
hop_wait_bootstrap_rhizome
end

label def wait_bootstrap_rhizome
reap
hop_prep if leaf?
donate
push Prog::BootstrapRhizome, {"target_folder" => "host"}
end

label def prep
Expand Down Expand Up @@ -91,35 +85,24 @@ def before_run
end

label def setup_hugepages
bud Prog::SetupHugepages
hop_wait_setup_hugepages
end
hop_setup_spdk if retval&.dig("msg") == "hugepages installed"

label def wait_setup_hugepages
reap
hop_setup_spdk if leaf?
donate
push Prog::SetupHugepages
end

label def setup_spdk
bud(Prog::Storage::SetupSpdk,
{
"version" => frame["spdk_version"],
"start_service" => false,
"allocation_weight" => 100
})
hop_wait_setup_spdk
end

label def wait_setup_spdk
reap
if leaf?
if retval&.dig("msg") == "SPDK was setup"
spdk_installation = vm_host.spdk_installations.first
spdk_cores = (spdk_installation.cpu_count * vm_host.total_cores) / vm_host.total_cpus
vm_host.update(used_cores: spdk_cores)
hop_prep_reboot
end
donate

push Prog::Storage::SetupSpdk, {
"version" => frame["spdk_version"],
"start_service" => false,
"allocation_weight" => 100
}
end

label def prep_reboot
Expand Down
75 changes: 18 additions & 57 deletions spec/prog/vm/host_nexus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,14 @@
end

describe "#start" do
it "buds a bootstrap rhizome process" do
expect(nx).to receive(:bud).with(Prog::BootstrapRhizome, {"target_folder" => "host"})
expect { nx.start }.to hop("wait_bootstrap_rhizome")
it "pushes a bootstrap rhizome process" do
expect(nx).to receive(:push).with(Prog::BootstrapRhizome, {"target_folder" => "host"}).and_call_original
expect { nx.start }.to hop("start", "BootstrapRhizome")
end
end

describe "#wait_bootstrap_rhizome" do
before { expect(nx).to receive(:reap) }

it "hops to prep if there are no sub-programs running" do
expect(nx).to receive(:leaf?).and_return true

expect { nx.wait_bootstrap_rhizome }.to hop("prep")
end

it "donates if there are sub-programs running" do
expect(nx).to receive(:leaf?).and_return false
expect(nx).to receive(:donate).and_call_original

expect { nx.wait_bootstrap_rhizome }.to nap(1)
it "hops once BootstrapRhizome has returned" do
nx.strand.retval = {"msg" => "rhizome user bootstrapped and source installed"}
expect { nx.start }.to hop("prep")
end
end

Expand Down Expand Up @@ -161,47 +149,29 @@
end

describe "#setup_hugepages" do
it "buds the hugepage program" do
expect(nx).to receive(:bud).with(Prog::SetupHugepages)
expect { nx.setup_hugepages }.to hop("wait_setup_hugepages")
end
end

describe "#wait_setup_hugepages" do
it "enters the setup_spdk state" do
expect(nx).to receive(:reap).and_return([])
expect(nx).to receive(:leaf?).and_return true
vmh = instance_double(VmHost)
nx.instance_variable_set(:@vm_host, vmh)

expect { nx.wait_setup_hugepages }.to hop("setup_spdk")
it "pushes the hugepage program" do
expect { nx.setup_hugepages }.to hop("start", "SetupHugepages")
end

it "donates its time if child strands are still running" do
expect(nx).to receive(:reap).and_return([])
expect(nx).to receive(:leaf?).and_return false
expect(nx).to receive(:donate).and_call_original

expect { nx.wait_setup_hugepages }.to nap(1)
it "hops once SetupHugepages has returned" do
nx.strand.retval = {"msg" => "hugepages installed"}
expect { nx.setup_hugepages }.to hop("setup_spdk")
end
end

describe "#setup_spdk" do
it "buds the spdk program" do
expect(nx).to receive(:bud).with(Prog::Storage::SetupSpdk,
it "pushes the spdk program" do
expect(nx).to receive(:push).with(Prog::Storage::SetupSpdk,
{
"version" => Config.spdk_version,
"start_service" => false,
"allocation_weight" => 100
})
expect { nx.setup_spdk }.to hop("wait_setup_spdk")
}).and_call_original
expect { nx.setup_spdk }.to hop("start", "Storage::SetupSpdk")
end
end

describe "#wait_setup_spdk" do
it "hops to prep_reboot if all tasks are done" do
expect(nx).to receive(:reap).and_return([])
expect(nx).to receive(:leaf?).and_return true
it "hops once SetupSpdk has returned" do
nx.strand.retval = {"msg" => "SPDK was setup"}
vmh = instance_double(VmHost)
spdk_installation = SpdkInstallation.new(cpu_count: 4)
allow(vmh).to receive_messages(
Expand All @@ -211,16 +181,7 @@
)
allow(nx).to receive(:vm_host).and_return(vmh)
expect(vmh).to receive(:update).with({used_cores: 2})

expect { nx.wait_setup_spdk }.to hop("prep_reboot")
end

it "donates its time if child strands are still running" do
expect(nx).to receive(:reap).and_return([])
expect(nx).to receive(:leaf?).and_return false
expect(nx).to receive(:donate).and_call_original

expect { nx.wait_setup_spdk }.to nap(1)
expect { nx.setup_spdk }.to hop("prep_reboot")
end
end

Expand Down