You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Michael Backes (JIRA)" <ji...@apache.org> on 2018/01/05 17:53:00 UTC
[jira] [Updated] (AIRFLOW-1970) Database cannot be initialized if
an invalid fernet key is provided
[ https://issues.apache.org/jira/browse/AIRFLOW-1970?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Backes updated AIRFLOW-1970:
------------------------------------
Description:
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:secret_pw@some.address: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.
was:
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":
[2018-01-05 16:43:00,525] {__init__.py:45} INFO - Using executor LocalExecutor
DB: postgresql+psycopg2://airflow_user:secret_pw@some.address: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.
> 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
>
> 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:secret_pw@some.address: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
(v6.4.14#64029)