Я использую Airflow 1.9.0 в экземпляре EC2 с базой данных в RDS (posgreSQL).
Я использую аутентификацию в потоке воздуха и пытаюсь создать нового пользователя, выполнив следующие действия:
>>> import airflow
>>> from airflow import models, settings
>>> from airflow.contrib.auth.backends.password_auth import PasswordUser
>>> user = PasswordUser(models.User())
>>> user.username = 'new_user_name'
>>> user.email = 'new_user_email@example.com'
>>> user._set_password = 'mypassword'
>>> session = settings.Session()
>>> session.add(user)
>>> session.commit()
>>> session.close()
>>> exit()
Когда я пытаюсь выполнить session.commit (), у меня появляется такая ошибка
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: users
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
self.transaction.commit()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
self._prepare_impl()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
self.session.flush()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
self._flush(objects)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2381, in _flush
transaction.rollback(_capture_exception=True)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2345, in _flush
flush_context.execute()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 395, in execute
rec.execute(self)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 560, in execute
uow
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
mapper, table, insert)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
execute(statement, params)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
raise value.with_traceback(tb)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users [SQL: 'INSERT INTO users (username, email, password) VALUES (?, ?, ?)'] [parameters: ('[![czambrano', 'some@email.com', b'$2b$12$1r4vhFaJHJEvOssY/EuDMuPQtN26M2crNHRjFowxYSf189P9HRkju'][1]][1])] (Background on this error at: http://sqlalche.me/e/e3q8)
Я проверил свой экземпляр RDS, и таблица пользователей создана таким образом
Поэтому я попытался вставить в таблицу вручную значения, которые я получал ранее: czambrano ',' some@email.com ', b' $ 2b $ 12 $ 1r4vhFaJHJEvOssY / EuDMuPQtN26M2crNHRjFowxYSf189P9HRkju '
Но когда я пытался войти в Airflow, я получаю сообщение об ошибке:
____/ ( ( ) ) \___
/( ( ( ) _ )) ) )\
(( ( )( ) ) ( ) )
((/ ( _( ) ( _) ) ( () ) )
( ( ( (_) (( ( ) .((_ ) . )_
( ( ) ( ( ) ) ) . ) ( )
( ( ( ( ) ( _ ( _) ). ) . ) ) ( )
( ( ( ) ( ) ( )) ) _)( ) ) )
( ( ( \ ) ( (_ ( ) ( ) ) ) ) )) ( )
( ( ( ( (_ ( ) ( _ ) ) ( ) ) )
( ( ( ( ( ) (_ ) ) ) _) ) _( ( )
(( ( )( ( _ ) _) _(_ ( (_ )
(_((__(_(__(( ( ( | ) ) ) )_))__))_)___)
((__) \\||lll|l||/// \_))
( /(/ ( ) ) )\ )
( ( ( ( | | ) ) )\ )
( /(| / ( )) ) ) )) )
( ( ((((_(|)_))))) )
( ||\(|(|)|/|| )
( |(||(||)|||| )
( //|/l|||)|\\ \ )
(/ / // /|//||||\\ \ \ \ _)
-------------------------------------------------------------------------------
Node: ip-10-7-0-242.ec2.internal
-------------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask_admin/base.py", line 69, in inner
return self._run_view(f, *args, **kwargs)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask_admin/base.py", line 368, in _run_view
return fn(self, *args, **kwargs)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/airflow/www/views.py", line 645, in login
return airflow.login.login(self, request)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/airflow/contrib/auth/backends/password_auth.py", line 135, in login
if not user.authenticate(password):
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/airflow/contrib/auth/backends/password_auth.py", line 66, in authenticate
return check_password_hash(self._password, plaintext)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask_bcrypt.py", line 67, in check_password_hash
return Bcrypt().check_password_hash(pw_hash, password)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/flask_bcrypt.py", line 193, in check_password_hash
return safe_str_cmp(bcrypt.hashpw(password, pw_hash), pw_hash)
File "/home/ubuntu/.local/share/virtualenvs/pampita-jFcteNag/lib/python3.6/site-packages/bcrypt/__init__.py", line 87, in hashpw
ValueError: Invalid salt
Некоторая помощь будет полезна!