> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Astro Private Cloud: Upgrade Runtime

## Overview

Regularly upgrading the [Astro Runtime](/docs/runtime/overview) version of your deployments on Astro Private Cloud ensures that you continue to be supported and that your Airflow deployments have the latest features and functionality.

To upgrade your Airflow Deployment to a later version of Airflow:

* Select a new Airflow version with the APC UI or CLI to start the upgrade.
* Change the `FROM` statement in your project's `Dockerfile` to reference an Astro Runtime image that corresponds to your current Airflow version.
* Deploy your upgrade to Astronomer.

## Available Astronomer image versions

A cron job automatically pulls new Astronomer image versions from the Astronomer [update service](http://updates.astronomer.io/) and adds them to the APC UI and CLI within 24 hours of their publication. You don't have to upgrade Astronomer to upgrade Airflow.

If you don't want to wait for new Astronomer image versions, you can manually trigger the cron job with the following Kubernetes command:

```bash wrap theme={null}
kubectl create job --namespace astronomer --from=cronjob/astronomer-houston-update-airflow-check airflow-update-check-first-run
```

If you get a message indicating that a job already exists, delete the job and rerun the command.

## Upgrade considerations

Consider the following when you upgrade Astro Runtime:

* Astronomer supports rollbacks within Astro Runtime 3.x (3.1.0 and later) and from Astro Runtime 3.x to 2.x (2.3.0 and later) on Astro Private Cloud 1.1 and later. Astro Runtime 3.0.x versions are not supported for automated rollbacks. See [Roll back a deploy](/docs/astro-private-cloud/v-1-x/deploy-rollbacks).
* 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](/docs/runtime/version-upgrade-considerations).

To stay up to date on the latest versions of Astro Runtime, see [Astro Runtime release notes](/docs/runtime/runtime-release-notes). For more information on Astro Runtime versioning and support, see [Astro Runtime versioning and lifecycle policy](/docs/runtime/runtime-version-lifecycle-policy). For a full collection of Astro Runtime Docker images, go to the [Astro Runtime repository on Quay.io](https://quay.io/repository/astronomer/astro-runtime?tab=tags).

## Step 1: Review upgrade considerations

Astro Runtime upgrades can include breaking changes, especially when you're upgrading to a new major version. Check the [upgrade considerations](/docs/runtime/version-upgrade-considerations) for your upgrade version to anticipate any breaking changes or upgrade-specific instructions before you proceed.

## Step 2: (Optional) Start the upgrade process

Now, by default, Astro Private Cloud uses the Runtime version that you configure in your Dockerfile in **Step 5: Update your Astro Project**. Prior to version 0.36, by default, you must first specify the Airflow and Runtime version you wanted to upgrade to, before starting your upgrade process.

If you want to use the prior workflow, you must change the feature flag, `disableDesiredRuntimeVersion`, in your Houston API `values.yaml` configuration to `false`:

```yaml wrap theme={null}
astronomer:
    houston:
        config:
            deployments:
                disableDesiredRuntimeVersion: false

```

After you apply the configuration, you can start the upgrade process. Starting the upgrade process doesn't interrupt or otherwise impact your Airflow Deployment. It only signals to Astro Private Cloud that you intend to upgrade at a later time.

### With the APC UI

1. Go to **Deployment** > **Settings** > **Basics** > **Runtime Version**.
2. Select an [Astro Runtime](/docs/runtime/overview) version. Each version shows the Airflow version it's based on.
3. Click **Upgrade**.

### With the Astro CLI

1. Run `astro login <base-domain>` to confirm you're authenticated.

2. Run the following command to list your current Deployments.

   ```bash wrap theme={null}
   astro deployment list
   ```

   Copy the ID of the Deployment you want to upgrade.

3. Run the following command to list the available Airflow versions:

   ```bash wrap theme={null}
   astro deployment airflow upgrade --deployment-id=<deployment-id>
   ```

4. Enter the Airflow version you want to upgrade to and press `Enter`.

<a id="pin-provider-package" />

## Step 3: (Optional) Pin provider package versions

Major Astro Runtime upgrades can include significant upgrades to built-in provider packages. These package upgrades can sometimes include breaking changes for your dags. See the [Apache Airflow documentation](https://airflow.apache.org/docs/apache-airflow-providers/packages-ref.html) 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.

1. Run the following command to check the version of all provider packages installed in your Astro Runtime version:

   ```bash wrap theme={null}
   docker run --rm quay.io/astronomer/astro-runtime:<current-runtime-version> pip freeze | grep apache-airflow-providers
   ```

2. 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:

   ```text wrap theme={null}
   apache-airflow-providers-databricks==4.0.0
   ```

## Step 4: (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:

```bash wrap theme={null}
astro dev upgrade-test --runtime-version <upgraded-runtime-version>
```

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](/docs/cli/v1.43/test-your-astro-project-locally#test-before-an-astro-runtime-upgrade).

## Step 5: Update your Astro project

1. In your Astro project, open your `Dockerfile`.
2. Change the Docker image in the `FROM` statement of your `Dockerfile` to a new version of Astro Runtime. For example, to upgrade to the latest version of Runtime, you would change the `FROM` statement in your Dockerfile to:

   ```dockerfile wrap theme={null}
   FROM quay.io/astronomer/astro-runtime:13.2.0
   ```

   For a list of supported Astro Runtime versions, see [Astro Runtime maintenance and lifecycle policy](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-lifecycle-schedule).

<Warning>Rollbacks are only supported on Astro Private Cloud 1.1 and later, for Astro Runtime 3.1.0+ and 2.3.0+. Astro Runtime 3.0.x versions require manual intervention. See [Roll back a deploy](/docs/astro-private-cloud/v-1-x/deploy-rollbacks).</Warning>

1. Save the changes to your `Dockerfile`.

## Step 6: Test Astro Runtime locally

Astronomer recommends testing new versions of Astro Runtime locally to ensure that Airflow starts as expected before upgrading your Deployment on Astro.

1. 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.

2. Access the Airflow UI of your local environment by navigating to `http://localhost:8080` in your browser.

3. Confirm that your local upgrade was successful by scrolling to the bottom of any page. You should see your new Astro Runtime version in the footer as well as the version of Airflow it is based on.

   <Frame>
     <img src="https://mintcdn.com/astronomer/8myRWRYNXt6d2ktd/images/docs/image-tag-airflow-ui-local.png?fit=max&auto=format&n=8myRWRYNXt6d2ktd&q=85&s=7485cb06ba2e2cb9157e173ed395f2c0" alt="Runtime Version banner - Local" width="1613" height="281" data-path="images/docs/image-tag-airflow-ui-local.png" />
   </Frame>

4. (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 experience one of these breaking changes, follow the steps in [Upgrade or pin provider package versions](#step-3-optional-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 7: Deploy to Astronomer

1. Run the following command to push your upgraded Astro project to your Deployment:

   ```bash wrap theme={null}
   astro deploy
   ```

2. In the APC UI, open your Deployment and click **Open Airflow**.

3. In the Airflow UI, scroll to the bottom of any page. You should see your new Runtime version in the footer.

## Cancel Airflow upgrade

As a System Admin, you can cancel an Airflow Deployment upgrade at any time if you haven't yet changed the Astronomer Runtime image in your `Dockerfile` and deployed it.

In the APC UI, select **Cancel** next to **Airflow Version**.

Using the Astro CLI, run:

```bash wrap theme={null}
astro deployment airflow upgrade --cancel --deployment-id=<deployment-id>
```

For example, if you cancel an upgrade from Airflow 2.1.0 to Airflow 2.2.0 in the CLI, the following message appears:

```bash wrap theme={null}
Airflow upgrade process has been successfully canceled. Your Deployment was not interrupted and you are still running Airflow 2.1.0.
```

Canceling the Airflow upgrade process does not interrupt or otherwise impact your Airflow Deployment or code that's running.

<Info>
  If you can't cancel your upgrade and receive an error message about using an unsupported Airflow version, set the following value in your `values.yaml` file and [apply the change](/docs/astro-private-cloud/v-2-x/apply-platform-config) to successfully cancel your upgrade. This configuration allows you to roll back to your current version of Airflow, even if it's not supported.

  ```yaml wrap theme={null}
  astronomer:
    houston:
      config:
        deployments:
          enableSystemAdminCanCreateDeprecatedAirflows: true
  ```
</Info>
