Switch the license validator to use config_provider and have a test license
Fixes the broken tests currently which try (and fail) to read the license file
This commit is contained in:
parent
2a7dbd3348
commit
67f828279d
4 changed files with 23 additions and 9 deletions
|
@ -190,8 +190,8 @@ class LicenseValidator(Thread):
|
|||
This thread is meant to be run before registry gunicorn workers fork and uses shared memory as a
|
||||
synchronization primitive.
|
||||
"""
|
||||
def __init__(self, license_path, *args, **kwargs):
|
||||
self._license_path = license_path
|
||||
def __init__(self, config_provider, *args, **kwargs):
|
||||
self._config_provider = config_provider
|
||||
|
||||
# multiprocessing.Value does not ensure consistent write-after-reads, but we don't need that.
|
||||
self._license_is_expired = multiprocessing.Value(c_bool, True)
|
||||
|
@ -205,11 +205,10 @@ class LicenseValidator(Thread):
|
|||
|
||||
def _check_expiration(self):
|
||||
try:
|
||||
with open(self._license_path) as f:
|
||||
current_license = decode_license(f.read())
|
||||
is_expired = current_license.is_expired
|
||||
logger.debug('updating license expiration to %s', is_expired)
|
||||
self._license_is_expired.value = is_expired
|
||||
current_license = self._config_provider.get_license()
|
||||
is_expired = current_license.is_expired
|
||||
logger.debug('updating license expiration to %s', is_expired)
|
||||
self._license_is_expired.value = is_expired
|
||||
except (IOError, LicenseError):
|
||||
logger.exception('failed to validate license')
|
||||
is_expired = True
|
||||
|
|
Reference in a new issue