I started Airflow with no FERNET_KEY. Once I realised it, I did the following: https://airflow.apache.org/configuration.html#connections
pip install apache-airflow[crypto]
from cryptography.fernet import Fernet
fernet_key= Fernet.generate_key()
print(fernet_key)
took the key and placed it in airflow.cfg
and then called airflow initdb
, but the error still appears.
What am I doing wrong?
When I do:
airflow webserver -D
I get:
File "/usr/local/lib/python2.7/dist-packages/airflow/models.py", line 713, in extra_dejson
if self.extra:
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/attributes.py", line 293, in __get__
return self.descriptor.__get__(instance, owner)
File "/usr/local/lib/python2.7/dist-packages/airflow/models.py", line 632, in get_extra
return fernet.decrypt(bytes(self._extra, 'utf-8')).decode()
File "/usr/lib/python2.7/dist-packages/cryptography/fernet.py", line 101, in decrypt
raise InvalidToken
The log indicates that there is issue with this code:
def get_conn(conn_id, session=None):
conn = (session.query(Connection)
.filter(Connection.conn_id == conn_id)
.first())
return conn
def my_python_function():
conn = get_conn('s3connection')
key_id = conn.extra_dejson.get('aws_access_key_id')
secret_key = conn.extra_dejson.get('aws_secret_access_key')
default_region = conn.extra_dejson.get('region_name')
return key_id,secret_key,default_region