Skip to content

Commit b1e9ad6

Browse files
AlphasiteCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent bb78550 commit b1e9ad6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/bosh-director/lib/bosh/director/jobs/dynamic_disks/attach_dynamic_disk.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ def perform
4141
raise "disk `#{@disk_name}` is in AZ `#{disk_az}` but instance `#{@instance_id}` is in AZ `#{vm_az}`"
4242
end
4343

44-
cloud = Bosh::Director::CloudFactory.create.get(disk_model.cpi, vm.stemcell_api_version)
44+
if disk_model.deployment_id && disk_model.deployment_id != instance.deployment_id
45+
raise "disk `#{@disk_name}` belongs to deployment `#{disk_model.deployment&.name}` and cannot be attached to deployment `#{instance.deployment.name}`"
46+
end
47+
48+
if disk_model.cpi && disk_model.cpi != '' && disk_model.cpi != vm.cpi
49+
raise "disk `#{@disk_name}` uses CPI `#{disk_model.cpi}` but target vm uses CPI `#{vm.cpi}`"
50+
end
51+
52+
cloud = Bosh::Director::CloudFactory.create.get(vm.cpi, vm.stemcell_api_version)
4553

4654
unless already_attached_same_vm
4755
disk_hint = with_vm_lock(vm.cid, timeout: VM_LOCK_TIMEOUT) { cloud.attach_disk(vm.cid, disk_model.disk_cid) }

0 commit comments

Comments
 (0)