4.1.1.1 Upgrading Airflow
This section provides information about upgrading Airflow
To upgrade Airflow, follow these steps:
- Take a backup of your Airflow instance. To do so:
- Back up the metadata database (using tools such as mysqldump or
pg_dump), along with project DAGs, configuration files, and any custom
plugins.
Example:
mysqldump -u root -p airflow_db > airflow_db_1.8.9.sql - Note your current Airflow version to manage the upgrade path.
- Back up the metadata database (using tools such as mysqldump or
pg_dump), along with project DAGs, configuration files, and any custom
plugins.
- Deactivate Any Running Airflow Services. To do so, stop all running Airflow
processes, including the web server, scheduler, and workers by running the
following command:
pkill -f airflow - Activate Your Airflow Virtual Environment (if using virtualenv). To do so, run
the following command:
source <YOUR_AIRFLOW_HOME>/venv/bin/activateNote:
Skip this step if you are not using a virtualenv. - Upgrade Airflow and Providers
- To upgrade Airflow, install the desired Airflow version by
running the following command:
pip install --upgrade "apache-airflow==<NEW_VERSION>" \ --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-<NEW_VERSION>/<PYTHON_VERSION>.txt"Note:
- Replace <NEW_VERSION> with the target Airflow version (for example, 2.9.3).
- Replace <PYTHON_VERSION> with the required Python version (for example, 3.9 for Python 3.9). If you are unsure, run python --version and use cut -d. -f1,2 to extract the major and minor version.
- To Airflow Providers, run the following command:
pip install --upgrade apache-airflow-providers-cncf-kubernetes \ apache-airflow-providers-dockerNote:
For more information about additional/updated providers relevant to your DAGs, see Airflow provider documentation.
- To upgrade Airflow, install the desired Airflow version by
running the following command:
- Upgrade Custom or Linked Packages. To do so,upgrade custom dependencies such as
OpenMetadata and ingestion tools by running the following commands:
pip install --upgrade "openmetadata-managed-apis~=1.7.7"pip install --upgrade "openmetadata-ingestion[all]~=1.7.7"pip install --upgrade "python-daemon>=3.0.0" - Upgrade Airflow Metadata Database. To do so, run the database migration to
update the schema for the new Airflow version:
airflow db upgradeor
airflow db migrate - Review and Update Airflow Configuration. To do so:
- Review your airflow.cfg and update it to reflect any new, modified, or deprecated configuration settings as described in the Airflow version upgrade notes.
- If you use SQLAlchemy connection URIs or other custom configurations, adjust them as required.
- Start or Restart Airflow Services. To do so, start the Airflow web server,
scheduler, and any workers:
airflow webserver & airflow scheduler &or
airflow standalone >> ./airflow.log 2>&1 & echo $! > airflow.pid - Validate the Airflow Upgrade. To do so:
- Verify the installed Airflow version:
airflow version - Open the Airflow web UI and confirm that all DAGs load correctly.
- Trigger a few test DAGs to ensure proper execution.
- Review Airflow logs for any warnings or errors.
- Verify the installed Airflow version:
- Clean Up. To do so:
- Remove deprecated packages or old virtual environments that are no longer needed.
- Monitor the system and DAG execution over the next few cycles to detect any unexpected issues.