Skip to content

Commit 72d4210

Browse files
committed
Interpolate cloud_properties before passing to CPI update_disk
Both update_detached_disks and update_disk_cpi were passing raw cloud_properties to the CPI, which could contain unresolved variable placeholders like ((...)). The create_disk path already resolves these via variables_interpolator.interpolate_with_versioning; do the same for the update paths.
1 parent fd28702 commit 72d4210

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/bosh-director/lib/bosh/director/disk_manager.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ def update_detached_disks(instance_plan)
8484

8585
begin
8686
cloud = cloud_for_cpi(active_vm.cpi)
87+
resolved_cloud_properties = @variables_interpolator.interpolate_with_versioning(
88+
new_disk.cloud_properties,
89+
instance_plan.instance.desired_variable_set,
90+
)
8791
@logger.info("Updating detached disk '#{old_disk_model.disk_cid}' via CPI")
88-
new_disk_cid = cloud.update_disk(old_disk_model.disk_cid, new_disk.size, new_disk.cloud_properties)
92+
new_disk_cid = cloud.update_disk(old_disk_model.disk_cid, new_disk.size, resolved_cloud_properties)
8993

9094
updates = { size: new_disk.size, cloud_properties: new_disk.cloud_properties }
9195
if new_disk_cid && new_disk_cid != old_disk_model.disk_cid
@@ -316,7 +320,11 @@ def update_disk_cpi(instance_plan, new_disk, old_disk)
316320

317321
begin
318322
cloud = cloud_for_cpi(old_disk_model.instance.active_vm.cpi)
319-
new_disk_cid = cloud.update_disk(old_disk_model.disk_cid, new_disk.size, new_disk.cloud_properties)
323+
resolved_cloud_properties = @variables_interpolator.interpolate_with_versioning(
324+
new_disk.cloud_properties,
325+
instance_plan.instance.desired_variable_set,
326+
)
327+
new_disk_cid = cloud.update_disk(old_disk_model.disk_cid, new_disk.size, resolved_cloud_properties)
320328
rescue Bosh::Clouds::NotImplemented, Bosh::Clouds::NotSupported => e
321329
@logger.info("IaaS native update not possible for disk #{old_disk_model.disk_cid}. Falling back to creating new disk.\n#{e.message}")
322330
attach_disk(old_disk_model, instance_plan.tags)

src/bosh-director/spec/unit/bosh/director/disk_manager_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ module Bosh::Director
178178
{ 'new' => 'properties' }
179179
end
180180

181+
before do
182+
allow(variables_interpolator).to receive(:interpolate_with_versioning)
183+
.with(anything, anything)
184+
.and_return(cloud_properties)
185+
end
186+
181187
context 'when disk size and properties change' do
182188
it 'updates the disk via cpi' do
183189
disk_manager.update_persistent_disk(instance_plan)
@@ -806,6 +812,9 @@ module Bosh::Director
806812
before do
807813
allow(cloud_factory).to receive(:get).with('my-cpi', nil).and_return(cloud)
808814
allow(cloud_factory).to receive(:get).with('my-cpi').and_return(cloud)
815+
allow(variables_interpolator).to receive(:interpolate_with_versioning)
816+
.with(anything, anything)
817+
.and_return(cloud_properties)
809818
end
810819

811820
let(:enable_cpi_update_disk) { true }

0 commit comments

Comments
 (0)