Files
ubicloud/prog/storage/remove_spdk.rb
Jeremy Evans 4b819d3cb2 Change all create_with_id to create
It hasn't been necessary to use create_with_id since
ebc79622df, in December 2024.

I have plans to introduce:

```ruby
def create_with_id(id, values)
  obj = new(values)
  obj.id = id
  obj.save_changes
end
```

This will make it easier to use the same id when creating
multiple objects.  The first step is removing the existing
uses of create_with_id.
2025-08-06 01:55:51 +09:00

49 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class Prog::Storage::RemoveSpdk < Prog::Base
subject_is :spdk_installation
def self.assemble(spdk_installation_id)
Strand.create(
prog: "Storage::RemoveSpdk",
label: "start",
stack: [{
"subject_id" => spdk_installation_id
}]
)
end
label def start
vm_host = spdk_installation.vm_host
fail "Can't remove the last storage backend from the host" if vm_host.spdk_installations.one? && vm_host.vhost_block_backends.empty?
spdk_installation.update(allocation_weight: 0)
hop_wait_volumes
end
label def wait_volumes
nap 30 if spdk_installation.vm_storage_volumes.length > 0
hop_remove_spdk
end
label def remove_spdk
version = spdk_installation.version
sshable = spdk_installation.vm_host.sshable
sshable.cmd("sudo host/bin/setup-spdk remove #{version.shellescape}")
hop_update_database
end
label def update_database
vm_host = spdk_installation.vm_host
VmHost.where(id: vm_host.id).update(
used_hugepages_1g: Sequel[:used_hugepages_1g] - spdk_installation.hugepages
)
spdk_installation.destroy
pop "SPDK installation was removed"
end
end