Comments (7)
I would suggest that for local development the FERNET_KEY
variable remains static and fixed in the docker-compose definition.
First, generate a cryptography key (fernet_key)
python -c "from cryptography.fernet import Fernet; FERNET_KEY = Fernet.generate_key().decode(); print(FERNET_KEY)"
then, copy-paste the printed result into the environment definition of your docker-compose.
environment:
- LOAD_EX=n
- EXECUTOR=Local
- FERNET_KEY=xxx
It is better to restart the environment for these changes to take place properly.
docker-compose -f ./docker/docker-compose-local.yml down
rm -r db-data
./mwaa-local-env start
if necessary, replace it in the airflow.cfg as well.
This should solve part of the issue.
The other part is the ability of aws-mwaa-local-runner to perform inner airflow cli
commands.
This is possible to verify by simply going into the container and execute airflow version
:
docker exec CONTAINER_ID airflow version
(to check your container_id do: docker ps
)
The output should be something like:
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 5, in <module>
from airflow.__main__ import main
File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 34, in <module>
from airflow import settings
File "/usr/local/lib/python3.7/site-packages/airflow/settings.py", line 37, in <module>
from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf # NOQA F401
File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 1098, in <module>
conf = initialize_config()
File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 860, in initialize_config
conf.validate()
File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 199, in validate
self._validate_config_dependencies()
File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 240, in _validate_config_dependencies
f"error: sqlite C library version too old (< {min_sqlite_version}). "
airflow.exceptions.AirflowConfigException: error: sqlite C library version too old (< 3.15.0). See https://airflow.apache.org/docs/apache-airflow/2.0.2/howto/set-up-database.rst#setting-up-a-sqlite-database
In fact, this simply means that CLI is trying to access to the default database (sqlite). We have to override this configuration in order to perform any CLI operations.
Simply add SqlAlchemy connection (AIRFLOW__CORE__SQL_ALCHEMY_CONN
) to the environment in the docker-compose definition:
environment:
- LOAD_EX=n
- EXECUTOR=Local
- FERNET_KEY=xxx
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
Other solution would be to add it in the airflow.cfg file by replacing this line:
#sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/airflow.db
by
sql_alchemy_conn = postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
Now, it should be possible to perform airflow connectios list
.
Possibly helps with #27
This solution I propose should be only temporary waiting for the complete integration into the local-runner process.
from aws-mwaa-local-runner.
same problem here, I can add a connection by going to http://localhost:8080/connection/add and the connection works. But when I restart the environment, the connection doesn't work anymore and I get the same error when I execute my DAG.
from aws-mwaa-local-runner.
Possibly related to #27
from aws-mwaa-local-runner.
Possibly related to #29
from aws-mwaa-local-runner.
I have found a procedure that fixes this.
To Replicate
- define
fernet_key = ...
in airflow.cfg - run
./mwaa-local-env build-image
- run
./mwaa-local-env start
http://localhost:8080/home
will run successfully- connect to local_runner container
docker exec -it docker_local-runner_1 /bin/sh
- run
airflow connections list
will return the same error listed abovecryptography.fernet.InvalidToken
The Fix
- run
airflow db reset -y
airflow connections list
will now work - and it will continue to work even when the container is stopped and restarted.
Break It Again
- run
airflow db init
and this will cause the problem reported in number 6 above to return.
Can anyone (@o-nikolas @dhegberg) explain why this is the case?
from aws-mwaa-local-runner.
As a workaround:
- delete
db-data
local folder - run
./mwaa-local-env build-image
- run
./mwaa-local-env start
from aws-mwaa-local-runner.
As a workaround:
- delete
db-data
local folder- run
./mwaa-local-env build-image
- run
./mwaa-local-env start
For me, this still results in the same problem. The airflow cli still fails to display airflow connections list
from aws-mwaa-local-runner.
Related Issues (20)
- ImportError: cannot import name 'AwsGlueJobOperator' from 'airflow.providers.amazon.aws.operators.glue' HOT 1
- Tasks taking too long time after 2.7.2 Airflow update
- possible to update dags when s3 dags update on s3 HOT 2
- Cannot add mssql provider
- Running mwaa-local-runner on aarch64 and calling the aws cli will fail
- Request to Update constraint.txt File HOT 1
- Update for MWAA v2.8.1 HOT 3
- Error when mwaa-local start HOT 2
- Airflow installation recommendation is incorrect HOT 4
- Error when trying to pre-import module 'airflow.providers.cncf.kubernetes.operators.pod'
- IgnoreAllDependencies doesn't exist in 2.7.2 & above.
- Docker Container Image Not Working (Windows) HOT 5
- Error building docker image for branch v2.6.3 HOT 1
- windows: /bin/sh: 1: [python,: not found
- amazonlinux SSL peer certificate or SSH remote key was not OK
- local runner not starting HOT 1
- Upgrade to 2.8.1 with an error An error occurred while fetching the dag source code. HOT 1
- `package-requirements` always returns exit code 0, even on failure HOT 1
- Inconsistent behaviour with sla_miss_callback and S3KeySensor
- Postgres-related error upon starting container, on Windows with WSL HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-mwaa-local-runner.