Skip to content

Commit c49276b

Browse files
committed
Use IaaS-native disk resize only when growing persistent disk
1 parent e349e11 commit c49276b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/bosh-director/lib/bosh/director/deployment_plan/persistent_disk_collection.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ def size_diff_only?(other)
144144
cloud_properties == other.cloud_properties &&
145145
size != other.size && name == other.name
146146
end
147+
148+
def is_bigger_than?(other)
149+
unless other.is_a? PersistentDisk
150+
raise Exception, 'Cannot compare persistent disk size to anything
151+
that is not a persistent disk.'
152+
end
153+
154+
size >= other.size
155+
end
147156
end
148157

149158
class NewPersistentDisk < PersistentDisk

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def update_persistent_disk(instance_plan)
3232

3333
@logger.info("CPI resize disk enabled: #{Config.enable_cpi_resize_disk}")
3434

35-
if use_cpi_resize_disk?(old_disk, new_disk)
35+
if use_iaas_native_disk_resize?(old_disk, new_disk)
3636
resize_disk(instance_plan, new_disk, old_disk)
3737
else
3838
update_disk(instance_plan, new_disk, old_disk)
@@ -84,8 +84,12 @@ def step_report
8484
DeploymentPlan::Stages::Report.new
8585
end
8686

87-
def use_cpi_resize_disk?(old_disk, new_disk)
88-
Config.enable_cpi_resize_disk && new_disk && new_disk.size_diff_only?(old_disk) && new_disk.managed?
87+
def use_iaas_native_disk_resize?(old_disk, new_disk)
88+
Config.enable_cpi_resize_disk &&
89+
new_disk &&
90+
new_disk.managed? &&
91+
new_disk.size_diff_only?(old_disk) &&
92+
new_disk.is_bigger_than?(old_disk)
8993
end
9094

9195
def add_event(action, deployment_name, instance_name, object_name = nil, parent_id = nil, error = nil)

0 commit comments

Comments
 (0)