From 39c54fa79fc014523babe2f1ecd621571f9805ad Mon Sep 17 00:00:00 2001 From: Seamus Johnston Date: Fri, 28 Apr 2023 16:02:30 -0500 Subject: [PATCH] Respond to PR feedback --- .../runbooks/rotate_application_secrets.md | 3 +- src/epplibwrapper/__init__.py | 1 + src/epplibwrapper/client.py | 31 ++++++++++--------- src/registrar/models/domain.py | 2 -- src/run.sh | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/operations/runbooks/rotate_application_secrets.md b/docs/operations/runbooks/rotate_application_secrets.md index a4ccef43c..456baf61d 100644 --- a/docs/operations/runbooks/rotate_application_secrets.md +++ b/docs/operations/runbooks/rotate_application_secrets.md @@ -88,8 +88,7 @@ openssl req -new -x509 -days 365 \ ``` -(Hint: -`docker run --platform=linux/amd64 -it --rm -v $(pwd):/apps -w /apps alpine/openssl`.) +(If you can't use openssl on your computer directly, you can access it using Docker as `docker run --platform=linux/amd64 -it --rm -v $(pwd):/apps -w /apps alpine/openssl`.) Encode them using: diff --git a/src/epplibwrapper/__init__.py b/src/epplibwrapper/__init__.py index 41cb0448d..ab3b63080 100644 --- a/src/epplibwrapper/__init__.py +++ b/src/epplibwrapper/__init__.py @@ -4,6 +4,7 @@ from types import SimpleNamespace try: from epplib import constants except ImportError: + # allow epplibwrapper to load without epplib, for testing and development pass logger = logging.getLogger(__name__) diff --git a/src/epplibwrapper/client.py b/src/epplibwrapper/client.py index d7f7068ca..7ddf0a03e 100644 --- a/src/epplibwrapper/client.py +++ b/src/epplibwrapper/client.py @@ -1,3 +1,5 @@ +"""Provide a wrapper around epplib to handle authentication and errors.""" + import logging from time import sleep @@ -21,12 +23,12 @@ try: # Write cert and key to disk CERT = Cert() KEY = Key() -except Exception as err: +except Exception: CERT = None # type: ignore KEY = None # type: ignore - logger.warning(err) logger.warning( - "Problem with client certificate. Registrar cannot contact registry." + "Problem with client certificate. Registrar cannot contact registry.", + exc_info=True, ) @@ -68,31 +70,31 @@ class EPPLibWrapper: with self._connect as wire: response = wire.send(command) except (ValueError, ParsingError) as err: - logger.debug(err) logger.warning( "%s failed to execute due to some syntax error." - % command.__class__.__name__ + % command.__class__.__name__, + exc_info=True, ) raise RegistryError() from err except TransportError as err: - logger.debug(err) logger.warning( "%s failed to execute due to a connection error." - % command.__class__.__name__ + % command.__class__.__name__, + exc_info=True, ) raise RegistryError() from err except LoginError as err: - logger.debug(err) logger.warning( "%s failed to execute due to a registry login error." - % command.__class__.__name__ + % command.__class__.__name__, + exc_info=True, ) raise RegistryError() from err except Exception as err: - logger.debug(err) logger.warning( "%s failed to execute due to an unknown error." - % command.__class__.__name__ + % command.__class__.__name__, + exc_info=True, ) raise RegistryError() from err else: @@ -119,7 +121,8 @@ try: # Initialize epplib CLIENT = EPPLibWrapper() logger.debug("registry client initialized") -except Exception as err: +except Exception: CLIENT = None # type: ignore - logger.warning(err) - logger.warning("Unable to configure epplib. Registrar cannot contact registry.") + logger.warning( + "Unable to configure epplib. Registrar cannot contact registry.", exc_info=True + ) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index b985c0629..dcf103586 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -7,8 +7,6 @@ from django.db import models from django_fsm import FSMField, transition # type: ignore from api.views import in_domains - -# from epplibwrapper import CLIENT as registry, commands from registrar.utility import errors from .utility.time_stamped_model import TimeStampedModel diff --git a/src/run.sh b/src/run.sh index 2d9391b93..487c54591 100755 --- a/src/run.sh +++ b/src/run.sh @@ -6,4 +6,4 @@ set -o pipefail # Make sure that django's `collectstatic` has been run locally before pushing up to any environment, # so that the styles and static assets to show up correctly on any environment. -gunicorn registrar.config.wsgi -t 60 --preload +gunicorn registrar.config.wsgi -t 60