From 44accf896963f9771e8d189e5c76bb01a165916a Mon Sep 17 00:00:00 2001 From: Prince Canuma Date: Wed, 2 Mar 2022 13:03:05 +0530 Subject: [PATCH 1/2] Pc/ssl-error-message (#853) * Add new message to SSLError * changing SSLError name * adding new SSLError message to legacy client --- neptune/api_exceptions.py | 53 +++++++++++++++++++++++--- neptune/new/exceptions.py | 53 +++++++++++++++++++++++--- neptune/new/internal/backends/utils.py | 4 +- neptune/utils.py | 4 +- tests/neptune/test_imports.py | 6 +-- 5 files changed, 103 insertions(+), 17 deletions(-) diff --git a/neptune/api_exceptions.py b/neptune/api_exceptions.py index b11b11713..bd80d88f5 100644 --- a/neptune/api_exceptions.py +++ b/neptune/api_exceptions.py @@ -21,12 +21,55 @@ class NeptuneApiException(NeptuneException): pass -class SSLError(NeptuneException): +class NeptuneSSLVerificationError(NeptuneException): def __init__(self): - super(SSLError, self).__init__( - "SSL certificate validation failed. Set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE " - "environment variable to accept self-signed certificates." - ) + message = """ +{h1} +----NeptuneSSLVerificationError----------------------------------------------------------------------- +{end} + +Neptune client was unable to verify your SSL Certificate. + +{bold}What could go wrong?{end} + - You are behind a proxy that inspects traffic to Neptune servers. + - Contact your network administrator + - Your on-prem installation's SSL/TLS certificate is not recognized due to a custom Certificate Authority (CA). + - To check run the following command in terminal: + {bash}curl https:///api/backend/echo {end} + - Where is the address that you use to access Neptune UI i.e. abc.com + - Contact your network administrator if you get the following output: + {fail}"curl: (60) server certificate verification failed..."{end} + - Your machine software is not up-to-date. + - Minimal OS requirements: + - Windows >= XP SP3 + - macOS >= 10.12.1 + - Ubuntu >= 12.04 + - Debian >= 8 + +{bold}What can I do?{end} +You can manually configure Neptune to skip all SSL checks. To do that +set the NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to 'TRUE'. +{bold}Note that might mean your connection is less secure{end}. + +Linux/Unix +In your terminal run: + {bash}export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +Windows +In your terminal run: + {bash}set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +Jupyter notebook +In your code cell: + {bash}%env NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +You may also want to check the following docs pages: + - https://docs.neptune.ai/api-reference/environment-variables#neptune_allow_self_signed_certificate + + +{correct}Need help?{end}-> https://docs.neptune.ai/getting-started/getting-help +""" + super().__init__(message.format(**STYLES)) class ConnectionLost(NeptuneApiException): diff --git a/neptune/new/exceptions.py b/neptune/new/exceptions.py index 5950de67d..cf4ee6c65 100644 --- a/neptune/new/exceptions.py +++ b/neptune/new/exceptions.py @@ -548,12 +548,55 @@ def __init__(self, host): super().__init__(message.format(host=host, **STYLES)) -class SSLError(NeptuneException): +class NeptuneSSLVerificationError(NeptuneException): def __init__(self): - super().__init__( - "SSL certificate validation failed. Set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE " - "environment variable to accept self-signed certificates." - ) + message = """ +{h1} +----NeptuneSSLVerificationError----------------------------------------------------------------------- +{end} + +Neptune client was unable to verify your SSL Certificate. + +{bold}What could go wrong?{end} + - You are behind a proxy that inspects traffic to Neptune servers. + - Contact your network administrator + - Your on-prem installation's SSL/TLS certificate is not recognized due to a custom Certificate Authority (CA). + - To check run the following command in terminal: + {bash}curl https:///api/backend/echo {end} + - Where is the address that you use to access Neptune UI i.e. abc.com + - Contact your network administrator if you get the following output: + {fail}"curl: (60) server certificate verification failed..."{end} + - Your machine software is not up-to-date. + - Minimal OS requirements: + - Windows >= XP SP3 + - macOS >= 10.12.1 + - Ubuntu >= 12.04 + - Debian >= 8 + +{bold}What can I do?{end} +You can manually configure Neptune to skip all SSL checks. To do that +set the NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to 'TRUE'. +{bold}Note that might mean your connection is less secure{end}. + +Linux/Unix +In your terminal run: + {bash}export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +Windows +In your terminal run: + {bash}set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +Jupyter notebook +In your code cell: + {bash}%env NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end} + +You may also want to check the following docs pages: + - https://docs.neptune.ai/api-reference/environment-variables#neptune_allow_self_signed_certificate + + +{correct}Need help?{end}-> https://docs.neptune.ai/getting-started/getting-help +""" + super().__init__(message.format(**STYLES)) class NeptuneConnectionLostException(NeptuneException): diff --git a/neptune/new/internal/backends/utils.py b/neptune/new/internal/backends/utils.py index 62c3d0521..c2b0a2950 100644 --- a/neptune/new/internal/backends/utils.py +++ b/neptune/new/internal/backends/utils.py @@ -63,7 +63,7 @@ NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE, ) from neptune.new.exceptions import ( - SSLError, + NeptuneSSLVerificationError, NeptuneConnectionLostException, Unauthorized, Forbidden, @@ -105,7 +105,7 @@ def wrapper(*args, **kwargs): raise NeptuneInvalidApiTokenException() raise except requests.exceptions.SSLError as e: - raise SSLError() from e + raise NeptuneSSLVerificationError() from e except ( BravadoConnectionError, BravadoTimeoutError, diff --git a/neptune/utils.py b/neptune/utils.py index ba5b85717..70d97ffcd 100644 --- a/neptune/utils.py +++ b/neptune/utils.py @@ -50,7 +50,7 @@ from neptune.api_exceptions import ( ConnectionLost, Forbidden, - SSLError, + NeptuneSSLVerificationError, ServerError, Unauthorized, ) @@ -297,7 +297,7 @@ def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except requests.exceptions.SSLError: - raise SSLError() + raise NeptuneSSLVerificationError() except HTTPBadRequest as e: if parse_error_type(e) == MIGRATION_FINISHED: raise ProjectMigratedToNewStructure() diff --git a/tests/neptune/test_imports.py b/tests/neptune/test_imports.py index 7cfc9c1e5..90f1d97e8 100644 --- a/tests/neptune/test_imports.py +++ b/tests/neptune/test_imports.py @@ -35,7 +35,7 @@ from neptune.api_exceptions import PathInExperimentNotFound from neptune.api_exceptions import PathInProjectNotFound from neptune.api_exceptions import ProjectNotFound -from neptune.api_exceptions import SSLError +from neptune.api_exceptions import NeptuneSSLVerificationError from neptune.api_exceptions import ServerError from neptune.api_exceptions import StorageLimitReached from neptune.api_exceptions import Unauthorized @@ -287,7 +287,7 @@ from neptune.new.exceptions import ProjectNotFound from neptune.new.exceptions import RunNotFound from neptune.new.exceptions import RunUUIDNotFound -from neptune.new.exceptions import SSLError +from neptune.new.exceptions import NeptuneSSLVerificationError from neptune.new.exceptions import Unauthorized from neptune.new.exceptions import UnsupportedClientVersion from neptune.new.exceptions import Version @@ -489,7 +489,7 @@ from neptune.utils import NotADirectory from neptune.utils import NotAFile from neptune.utils import ProjectMigratedToNewStructure -from neptune.utils import SSLError +from neptune.utils import NeptuneSSLVerificationError from neptune.utils import ServerError from neptune.utils import Unauthorized From 64c1e637911dfb82d784fe9ab67b8cac4fed375a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Jankowski?= Date: Wed, 2 Mar 2022 15:58:45 +0100 Subject: [PATCH 2/2] E2E only on failure and timeout added (#857) --- .github/workflows/full.yml | 3 ++- .github/workflows/pull_request.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/full.yml b/.github/workflows/full.yml index a040861c8..8e3c18226 100644 --- a/.github/workflows/full.yml +++ b/.github/workflows/full.yml @@ -21,6 +21,7 @@ jobs: # Both integration tests and E2E test: runs-on: ${{ matrix.os }} + timeout-minutes: 30 strategy: max-parallel: 4 matrix: @@ -85,7 +86,7 @@ jobs: fields: repo,message,commit,author,eventName,workflow,job,took env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() + if: job.status != 'success' publish: needs: [lint, test] diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2adac09ad..7ba072002 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -15,6 +15,7 @@ jobs: integration: runs-on: ${{ matrix.os }} + timeout-minutes: 30 strategy: matrix: os: [ubuntu-latest]