Skip to content

Commit

Permalink
fixing condition to raise exception when URL is not reachable [Fixes #9]
Browse files Browse the repository at this point in the history
  • Loading branch information
DheerajDang committed May 21, 2021
1 parent 9e271b1 commit 02a49e4
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions rally_plugins/scenarios/kubernetes/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,32 +229,33 @@ def run(self, image, port, protocol, image_pull_policy='IfNotPresent',
else:
ip = "://" + server[:server.index(":") + 1]
url = ("http" + ip + str(node_port) + "/")
while i < retries_total:
try:
kwargs = {}
if request_timeout:
kwargs["timeout"] = request_timeout
requests.get(url, **kwargs)
except (requests.ConnectionError, requests.ReadTimeout) as ex:
if i < retries_total:
i += 1
commonutils.interruptable_sleep(sleep_time)
try:
while i < retries_total:
try:
kwargs = {}
if request_timeout:
kwargs["timeout"] = request_timeout
requests.get(url, **kwargs)
except (requests.ConnectionError, requests.ReadTimeout) as ex:
if i < retries_total:
i += 1
commonutils.interruptable_sleep(sleep_time)
if i == retries_total:
raise exceptions.RallyException(
message="Unable to get response "
"from %(url)s: %(ex)s" % {
"url": url,
"ex": str(ex)
})
else:
raise exceptions.RallyException(
message="Unable to get response "
"from %(url)s: %(ex)s" % {
"url": url,
"ex": str(ex)
})
else:
break

self.client.delete_service(name, namespace=namespace)
self.client.delete_pod(
name,
namespace=namespace,
status_wait=status_wait
)
break
finally:
self.client.delete_service(name, namespace=namespace)
self.client.delete_pod(
name,
namespace=namespace,
status_wait=status_wait
)


@scenario.configure(
Expand Down

0 comments on commit 02a49e4

Please sign in to comment.