Skip to content

Commit 899892a

Browse files
committed
Don't add bosh director ip if ip version do not match
If the bosh directors ip version does not match the ip version of the subnet range (ipv4 <-> ipv6), bosh will trigger a redeploy everytime it deploys the relevant deployment. I also added an intgration test for this use case.
1 parent 9bd1d81 commit 899892a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def self.parse(network_name, subnet_spec, availability_zones, managed = false)
6262

6363
Config.director_ips&.each do |cidr|
6464
each_ip(cidr) do |ip|
65+
if ip.ipv4? != range.ipv4?
66+
next
67+
end
6568
restricted_ips.add(ip)
6669
end
6770
end
@@ -157,8 +160,6 @@ def overlaps?(subnet)
157160
def is_reservable?(ip)
158161
restricted_ips.each do | restricted_ip |
159162
return false if restricted_ip.include?(ip)
160-
rescue IPAddr::InvalidAddressError # when ip versions are not the same
161-
return false
162163
end
163164

164165
range.include?(ip.to_range.first) && range.include?(ip.to_range.last)

src/spec/integration/global_networking/ip_reservations/allocating_dynamic_ips_using_two_networks_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ def make_network_spec(first_subnet, second_subnet)
9595
expect(instances.size).to eq(1)
9696
expect(instances.map(&:ips).flatten).to match_array(['192.168.1.2', '10.10.0.3'])
9797
end
98+
99+
it 'does not redeploy VM if no changes are done event if the networks have different address types', no_create_swap_delete: true do
100+
first_subnet = SharedSupport::DeploymentManifestHelper.make_subnet(available_ips: 2, range: '192.168.1.0/24') # 1 for compilation
101+
second_subnet = SharedSupport::DeploymentManifestHelper.make_subnet(available_ips: 1, range: '2001:db8::/120')
102+
103+
cloud_config_hash = SharedSupport::DeploymentManifestHelper.simple_cloud_config
104+
cloud_config_hash['networks'] = make_network_spec(first_subnet, second_subnet)
105+
cloud_config_hash['compilation']['network'] = 'first'
106+
upload_cloud_config(cloud_config_hash: cloud_config_hash)
107+
108+
manifest_hash = SharedSupport::DeploymentManifestHelper.simple_manifest_with_instance_groups
109+
manifest_hash['instance_groups'] = [instance_group_with_two_networks]
110+
deploy_simple_manifest(manifest_hash: manifest_hash)
111+
112+
instances = director.instances
113+
expect(instances.size).to eq(1)
114+
expect(instances.map(&:ips).flatten).to match_array(['192.168.1.2', '2001:db8::2'])
115+
116+
output = deploy_simple_manifest(manifest_hash: manifest_hash)
117+
118+
expect(output).to_not match(/executing pre-stop/)
119+
instances = director.instances
120+
expect(instances.size).to eq(1)
121+
expect(instances.map(&:ips).flatten).to match_array(['192.168.1.2', '2001:db8::2'])
122+
end
98123
end
99124
end
100125
end

0 commit comments

Comments
 (0)