|
28 | 28 |
|
29 | 29 | import requests
|
30 | 30 | from six import raise_from
|
| 31 | +from urllib3.exceptions import ( |
| 32 | + NewConnectionError, |
| 33 | + ConnectTimeoutError, |
| 34 | + MaxRetryError, |
| 35 | +) |
31 | 36 |
|
32 | 37 | from .catalog import CatalogController
|
33 | 38 | from .config import ConfigController
|
@@ -477,20 +482,26 @@ def create_session(self):
|
477 | 482 | response = None
|
478 | 483 | try:
|
479 | 484 | self.log.debug("REQ: {} : {} {}".format("Login", "post", url))
|
480 |
| - response = requests.post(url, json=auth, verify=self.verify_ssl) |
| 485 | + response = requests.post( |
| 486 | + url, json=auth, verify=self.verify_ssl, timeout=10 |
| 487 | + ) |
481 | 488 | response.raise_for_status()
|
482 | 489 |
|
483 |
| - except requests.exceptions.ConnectionError as e: |
| 490 | + except ( |
| 491 | + requests.exceptions.ConnectionError, |
| 492 | + NewConnectionError, |
| 493 | + MaxRetryError, |
| 494 | + ConnectTimeoutError, |
| 495 | + ) as e: |
484 | 496 | self.log.debug(
|
485 | 497 | "RES: {} : {} {} {}".format("Login", "post", url, str(e))
|
486 | 498 | )
|
487 | 499 | if self.log.level == 10: # "DEBUG"
|
488 |
| - msg = "Could not connect to controller." |
| 500 | + # The error is already output to the log, so this message |
| 501 | + # can be brief. |
| 502 | + msg = "Could not connect to the controller." |
489 | 503 | else:
|
490 |
| - msg = ( |
491 |
| - "Could not connect to controller - set LOG_LEVEL=DEBUG to " |
492 |
| - "see more detail." |
493 |
| - ) |
| 504 | + msg = "Could not connect to the controller.\n" + str(e) |
494 | 505 | raise_from(
|
495 | 506 | APIException(
|
496 | 507 | message=msg, request_method="post", request_url=url,
|
|
0 commit comments