Astro: Upgrade Runtime
New versions of Astro Runtime are released regularly to support new Astro and Apache Airflow functionality. To take advantage of new features and bug and security fixes, Astronomer recommends upgrading Astro Runtime as new versions are available.
Prerequisites
- The Astro CLI.
- An Astro project.
- An Astro Deployment.
Step 1: Review upgrade considerations
Astro upgrades can include breaking changes, especially when you’re upgrading to a new major version. Check the upgrade considerations for your upgrade version to anticipate any breaking changes or upgrade-specific instructions before you proceed.
Step 2: (Optional) Pin provider package versions
Major Astro Runtime upgrades can include major upgrades to built-in provider packages. These package upgrades can sometimes include breaking changes for your dags. See the Apache Airflow documentation for a list of all available provider packages and their release notes.
For the most stable upgrade path, Astronomer recommends pinning all provider package versions from your current Runtime version before upgrading. To check the version of all provider packages installed in your Runtime version, run:
After reviewing this list, pin the version for each provider package in your Astro project requirements.txt
file. For example, Runtime 7.4.1 uses version 4.0.0 of apache-airflow-providers-databricks
. To pin this version of the Databricks provider package when you upgrade to a later version of Runtime, you add the following line to your requirements.txt
file:
Step 3: (Optional) Run upgrade tests with the Astro CLI
You can use the Astro CLI to anticipate and address problems before upgrading to a newer version of Astro Runtime. Before you upgrade, run the following command to run tests against the version of Astro Runtime you’re upgrading to:
The Astro CLI then generates test results in your Astro project that identify dependency conflicts and import errors that you would experience using the new Astro Runtime version. Review these results and make the recommended changes to reduce the risk of your project generating errors after you upgrade. For more information about using this command and the test results, see Test before upgrade your Astro project.
Step 4: Update Your Dockerfile
-
In your Astro project, open your
Dockerfile
. -
Change the Docker image in the
FROM
statement of yourDockerfile
to a new version of Astro Runtime.To upgrade to the latest version of Runtime, for example, change the
FROM
statement in your Dockerfile to:You must always specify the major, minor, and patch version of any given Astro Runtime version.
-
Save the changes to your
Dockerfile
.
Step 5: Test Astro Runtime locally
Astronomer recommends testing new versions of Astro Runtime locally before upgrading a Deployment on Astro.
-
Open your project directory in your terminal and run
astro dev restart
. This restarts the Docker containers for the Airflow webserver, scheduler, triggerer, and Postgres metadata database. -
Access the Airflow UI of your local environment by navigating to
http://localhost:8080
in your browser. -
Confirm that your local upgrade was successful by scrolling to the end of any page. The new Astro Runtime version is listed in the footer as well as the version of Airflow it is based on.
-
(Optional) Run dags locally to ensure that all of your code works as expected. If you encounter errors after your upgrade, it’s possible that your new Astro Runtime version includes a breaking provider package change. If you encounter one of these breaking changes, follow the steps in Upgrade or pin provider package versions to check your provider package versions and, if required, pin the provider package version from your previous Runtime version in your
requirements.txt
file.
Step 6: (Optional) Upgrade and test provider packages
If you pinned provider package versions before your upgrade, upgrade your provider packages by changing the pinned version in your requirements.txt
file. Test each provider package upgrade locally before deploying to Astro.
Step 7: Deploy to Astronomer
To push your upgraded project to an Astro Deployment, run:
For more information about deploying to Astro, see Deploy code.
After you upgrade a Deployment on Astro to a new version of Astro Runtime, the only way to downgrade is to roll back to a previous deploy. If you attempt to downgrade a Deployment by updating your Dockerfile, the Astro CLI produces an error and your request to deploy does not succeed.
Generally speaking, Deployment rollbacks to lower Runtime versions are recommended only when your current code isn’t working as expected. This is because rollbacks to lower Runtime versions can result in your Deployment losing data from the metadata database. For more information, see What happens during a deploy rollback.
Step 8: Confirm your upgrade on Astro
-
In the Astro UI, select a Workspace, click Deployments, and then select a Deployment.
-
Click Open Airflow.
-
In the Airflow UI, scroll to the bottom of any page. You should see your new Runtime version in the footer:
You will also see an Image tag for your deploy. This tag is shown only for Deployments on Astro and is not generated for changes in a local environment.
Upgrade considerations
Consider the following when you upgrade Astro Runtime:
- All versions of the Astro CLI support all versions of Astro Runtime. There are no dependencies between the two products.
- Upgrading to certain versions of Runtime might result in extended upgrade times or otherwise disruptive changes to your environment. To learn more, see Version-specific upgrade considerations.
- You can’t downgrade a Deployment on Astro to a lower version of Astro Runtime unless you roll back to a previous deploy.
To stay up to date on the latest versions of Astro Runtime, see Astro Runtime release notes. For more information on Astro Runtime versioning and support, see Astro Runtime versioning and lifecycle policy. For a full collection of Astro Runtime Docker images, go to the Astro Runtime repository on Quay.io.
Run a deprecated Astro Runtime version
If you’re migrating to Astro from OSS Airflow or Astro Hybrid, where your Deployments run using an older version of Airflow or a deprecated version of the Astro Runtime, you can now use stepwise migration to complete your migration in stages. First, you can create Deployments with a deprecated version of the Astro Runtime using the Astro API to move to an Astro Hosted environment. Then, you can upgrade your code to the most up-to-date version of the Astro Runtime.
Deployments that run deprecated Astro Runtime versions will only receive support as Astro Runtime maintenance policy, and Astronomer might advise you to upgrade your runtime to the latest version of Astro to resolve performance issues or bugs. Runtime Version 4.2.9 is the lowest deprecated Runtime version that can be used with Astro.
- Contact your Astronomer account team and request the ability to run deprecated versions of Astro Runtime.
- Create a Personal Access Token(PAT) to use for authentication to Astro.
- Create a Deployment using the Astro API. In your request, specify your PAT in the authorization header, and your deprecated Astro Runtime version using the
astroRuntimeVersions
property.
After you create the Deployment, you can manage the Deployment using any interface, including the Astro CLI and Astro UI. You can also create additional Deployments with deprecated Runtimes using the Astro API and either a Workspace or Organization API token.