|
13 | 13 | import requests |
14 | 14 | from requests_toolbelt import user_agent |
15 | 15 | from .utils import dict_merge |
| 16 | +from retrying import retry |
16 | 17 |
|
17 | 18 | from deis import __version__ as deis_version |
18 | 19 |
|
@@ -700,25 +701,19 @@ def resolve_state(self, pod): |
700 | 701 |
|
701 | 702 | return states.get(pod_state, pod_state) |
702 | 703 |
|
| 704 | + @retry(stop_max_attempt_number=3, wait_fixed=1000) |
703 | 705 | def _get_port(self, image): |
704 | 706 | # try thrice to find the port before raising exception as docker-py is flaky |
705 | | - for i in range(3): |
706 | | - try: |
707 | | - imagepath = self.registry + '/' + image |
708 | | - repo = imagepath.split(":") |
709 | | - # image already includes the tag, so we split it out here |
710 | | - docker_cli = Client(version="auto") |
711 | | - docker_cli.pull(repo[0]+":"+repo[1], tag=repo[2], insecure_registry=True) |
712 | | - image_info = docker_cli.inspect_image(imagepath) |
713 | | - if 'ExposedPorts' not in image_info['Config']: |
714 | | - return None |
715 | | - port = int(list(image_info['Config']['ExposedPorts'].keys())[0].split("/")[0]) |
716 | | - return port |
717 | | - except Exception: |
718 | | - if i == 2: |
719 | | - raise |
720 | | - else: |
721 | | - continue |
| 707 | + imagepath = self.registry + '/' + image |
| 708 | + repo = imagepath.split(":") |
| 709 | + # image already includes the tag, so we split it out here |
| 710 | + docker_cli = Client(version="auto") |
| 711 | + docker_cli.pull(repo[0]+":"+repo[1], tag=repo[2], insecure_registry=True) |
| 712 | + image_info = docker_cli.inspect_image(imagepath) |
| 713 | + if 'ExposedPorts' not in image_info['Config']: |
| 714 | + return None |
| 715 | + port = int(list(image_info['Config']['ExposedPorts'].keys())[0].split("/")[0]) |
| 716 | + return port |
722 | 717 |
|
723 | 718 | def _api(self, tmpl, *args): |
724 | 719 | """Return a fully-qualified Kubernetes API URL from a string template with args.""" |
|
0 commit comments