Skip to content

Commit 32f26f7

Browse files
TheYorkWeiGerrit Code Review
authored and
Gerrit Code Review
committed
fix: increase Lightwave server setup attempts
Increase the number of attempts to reach the Lightwave server as occasionally it is able to connect after almost max number of attempts currently set. If the server is still unreachable, it will exit without continuing building other vms as the error will go unnoticed and cause issues when running authentication related tests. Vagrant is also updated so that the lightwave vm is created only when auth is enabled since it requires correct configuration and takes resources when trying to use an auth disabled environment. Change-Id: I7b6de9940f74a706fa2fd71ba13f536b55b5bad1
1 parent a097d4f commit 32f26f7

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

devbox-photon/Vagrantfile

+30-27
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Vagrant.configure("2") do |config|
114114
gem install jsonlint --no-rdoc --no-ri
115115
EOM
116116

117+
if ENV['ENABLE_AUTH'] == 'true'
117118
#
118119
# VM definition for lightwave
119120
#
@@ -189,33 +190,33 @@ Vagrant.configure("2") do |config|
189190
dynamic_params = %Q(
190191
{)
191192

192-
if ENV['ENABLE_AUTH'] == 'true'
193-
if ENV['LW_DOMAIN_NAME']
194-
dynamic_params += %Q(\n "LIGHTWAVE_DOMAIN" : "#{ENV['LW_DOMAIN_NAME']}")
195-
else
196-
abort("auth is enabled for devbox lightwave, but domain is not set")
197-
end
198193

199-
if ENV['LW_PASSWORD']
200-
dynamic_params += %Q(,\n "LIGHTWAVE_PASSWORD" : "#{ENV['LW_PASSWORD']}")
201-
else
202-
abort("auth is enabled for devbox lightwave, but password is not set")
203-
end
194+
if ENV['LW_DOMAIN_NAME']
195+
dynamic_params += %Q(\n "LIGHTWAVE_DOMAIN" : "#{ENV['LW_DOMAIN_NAME']}")
196+
else
197+
abort("auth is enabled for devbox lightwave, but domain is not set")
198+
end
204199

205-
if ENV["PUBLIC_NETWORK_IP"]
206-
if ENV["PUBLIC_LW_NETWORK_IP"]
207-
# The hostname is set to the IP since Photon Controller does not have DNS set
208-
# to Lightwave yet, but Photon Controller during auth enabled needs to
209-
# verify the hostname matches the Lightwave server certificate.
210-
dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ENV['PUBLIC_LW_NETWORK_IP']}")
211-
else
212-
abort("auth is enabled for devbox lightwave, but hostname is not set")
213-
end
200+
if ENV['LW_PASSWORD']
201+
dynamic_params += %Q(,\n "LIGHTWAVE_PASSWORD" : "#{ENV['LW_PASSWORD']}")
202+
else
203+
abort("auth is enabled for devbox lightwave, but password is not set")
204+
end
205+
206+
if ENV["PUBLIC_NETWORK_IP"]
207+
if ENV["PUBLIC_LW_NETWORK_IP"]
208+
# The hostname is set to the IP since Photon Controller does not have DNS set
209+
# to Lightwave yet, but Photon Controller during auth enabled needs to
210+
# verify the hostname matches the Lightwave server certificate.
211+
dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ENV['PUBLIC_LW_NETWORK_IP']}")
214212
else
215-
private_network_lw_ip = ENV["PRIVATE_NETWORK_LW_IP"] || "172.31.253.67"
216-
dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{private_network_lw_ip}")
213+
abort("auth is enabled for devbox lightwave, but hostname is not set")
217214
end
215+
else
216+
private_network_lw_ip = ENV["PRIVATE_NETWORK_LW_IP"] || "172.31.253.67"
217+
dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{private_network_lw_ip}")
218218
end
219+
219220
dynamic_params += "\n}"
220221

221222
# Write dynamic_params file
@@ -313,11 +314,12 @@ cat >> $out <<-'EOM'
313314
echo "Checking to connect to Lightwave REST client to start"
314315
attempts=1
315316
reachable="false"
316-
while [ $attempts -lt 30 ] && [ $reachable != "true" ]; do
317+
total_attempts=50
318+
while [ $attempts -lt $total_attempts ] && [ $reachable != "true" ]; do
317319
http_code=$(curl -w "%{http_code}" -s -X GET --insecure https://lightwave.#{ENV['LW_DOMAIN_NAME']})
318320
# The curl returns 000 when it fails to connect to the lightwave server
319321
if [ $http_code -eq 000 ]; then
320-
echo "Lightwave REST server not reachable (attempt $attempts/30), will try again."
322+
echo "Lightwave REST server not reachable (attempt $attempts/$total_attempts), will try again."
321323
attempts=$[$attempts+1]
322324
sleep 5
323325
else
@@ -329,15 +331,16 @@ cat >> $out <<-'EOM'
329331
break
330332
fi
331333
done
332-
if [ $attempts -eq 30 ]; then
333-
echo "Could not connect to Lightwave REST client after 30 attempts, users not added and token expiration not updated."
334+
if [ $attempts -eq $total_attempts ]; then
335+
echo "Could not connect to Lightwave REST client after $total_attempts attempts, users not added and token expiration not updated."
336+
exit 1
334337
fi
335338
EOM
336339
chmod +x $out
337340
$out
338341
EOS
339342
end
340-
343+
end
341344

342345
#
343346
# VM definition for photon

0 commit comments

Comments
 (0)