mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
allow conf.settings to fallback to old encryption methods so settings work during migrations
This commit is contained in:
parent
7111d9232f
commit
bd52e4bb22
@ -22,6 +22,7 @@ from awx.main.utils import encrypt_field, decrypt_field
|
||||
from awx.main.utils.db import get_tower_migration_version
|
||||
from awx.conf import settings_registry
|
||||
from awx.conf.models import Setting
|
||||
from awx.conf.migrations._reencrypt import decrypt_field as old_decrypt_field
|
||||
|
||||
# FIXME: Gracefully handle when settings are accessed before the database is
|
||||
# ready (or during migrations).
|
||||
@ -245,7 +246,13 @@ class SettingsWrapper(UserSettingsHolder):
|
||||
if settings_to_cache[setting.key] != SETTING_CACHE_NOTSET:
|
||||
continue
|
||||
if self.registry.is_setting_encrypted(setting.key):
|
||||
value = decrypt_field(setting, 'value')
|
||||
try:
|
||||
value = decrypt_field(setting, 'value')
|
||||
except ValueError, e:
|
||||
#TODO: Remove in Tower 3.3
|
||||
logger.debug('encountered error decrypting field: %s - attempting fallback to old', e)
|
||||
value = old_decrypt_field(setting, 'value')
|
||||
|
||||
else:
|
||||
value = setting.value
|
||||
settings_to_cache[setting.key] = get_cache_value(value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user