[
https://issues.apache.org/jira/browse/AIRFLOW-1970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16844896#comment-16844896
]
Adam Whitlock commented on AIRFLOW-1970:
----------------------------------------
The condition where an invalid Fernet key being provided will prevent `airflow
initdb` from creating the database still exists. I was able to confirm this
condition with 1.10.3. There should be a condition that if an invalid Fernet
key is read that it exits, allowing scripting to catch the condition. If not,
the name of the JIRA should be updated to reflect the changes made and accepted
as part of this fix.
> Database cannot be initialized if an invalid fernet key is provided
> -------------------------------------------------------------------
>
> Key: AIRFLOW-1970
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1970
> Project: Apache Airflow
> Issue Type: Bug
> Components: configuration
> Affects Versions: 1.9.0
> Environment: Python 2.7.12
> PostgreSQL 9.6.3
> Reporter: Michael Backes
> Assignee: Jarosław Śmietanka
> Priority: Major
> Fix For: 1.10.1, 2.0.0
>
>
> If I use an invalid fernet key in my config file, I'm not able to run
> "airflow initdb" successfully.
> For example if I have the following in my config:
> {panel:title=airflow.cfg}
> ...
> \\# Secret key to save connection passwords in the db
> fernet_key = xxx
> ...
> {panel}
> I will get the following error when running "airflow initdb":
> {panel:title=log}
> [2018-01-05 16:43:00,525] {__init__.py:45} INFO - Using executor LocalExecutor
> DB: postgresql+psycopg2://airflow_user:[email protected]:5432/airflow
> [2018-01-05 16:43:00,624] {db.py:312} INFO - Creating tables
> INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
> INFO [alembic.runtime.migration] Will assume transactional DDL.
> Traceback (most recent call last):
> File "/usr/local/bin/airflow", line 27, in <module>
> args.func(args)
> File "/usr/local/lib/python2.7/site-packages/airflow/bin/cli.py", line 897,
> in initdb
> db_utils.initdb()
> File "/usr/local/lib/python2.7/site-packages/airflow/utils/db.py", line
> 114, in initdb
> schema='airflow_ci'))
> File "<string>", line 4, in __init__
> File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/state.py",
> line 414, in _initialize_instance
> manager.dispatch.init_failure(self, args, kwargs)
> File
> "/usr/local/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py",
> line 66, in __exit__
> compat.reraise(exc_type, exc_value, exc_tb)
> File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/state.py",
> line 411, in _initialize_instance
> return manager.original_init(*mixed[1:], **kwargs)
> File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 578,
> in __init__
> self.extra = extra
> File "<string>", line 1, in __set__
> File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 639,
> in set_extra
> fernet = get_fernet()
> File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 105,
> in get_fernet
> return Fernet(configuration.get('core', 'FERNET_KEY').encode('utf-8'))
> File "/usr/local/lib64/python2.7/site-packages/cryptography/fernet.py",
> line 34, in __init__
> key = base64.urlsafe_b64decode(key)
> File "/usr/lib64/python2.7/base64.py", line 119, in urlsafe_b64decode
> return b64decode(s.translate(_urlsafe_decode_translation))
> File "/usr/lib64/python2.7/base64.py", line 78, in b64decode
> raise TypeError(msg)
> TypeError: Incorrect padding
> {panel}
> I also got an error when I try to add extras to a connection, if fernet_key
> is empty in the config file. The error message was "Incorrect padding". Once
> I provided a valid key generated with the instructions given
> [here|http://airflow.readthedocs.io/en/latest/configuration.html?highlight=fernet#connections]
> and restarted all of the airflow services it worked without any issues.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)