# Recipe Upgrade

:::info
Update the recipes about 3-4 weeks before planning the production upgrade

:::

If you made changes to the recipe itself, please see [Recipe Development](/doc/74813ce7-7b8d-4d07-a172-3453f0c52b35) for common caveats

First check if the recipe is already up-to-date with the upstream docker image. If so, you can skip to →*Test the Upgrade-Process.*

## Preparation

* Move to the folder of the recipe you want to update
* Run `git pull`
* Run `alakazam install`

## Upgrade image labels

* Set env for current recipe (optional - personal taste): 

  ```bash
  RECIPE=<recipe_name>
  ```
* Upgrade the image Labels: 

  ```bash
  abra recipe upgrade $RECIPE
  ```
  * Consider skipping db upgrades (images db, postgres)

    
    :::tip
    You can consider Migrating to `pgautoupgrade` - see [this Issue](https://git.local-it.org/KolliCloud-intern/development/issues/308#issuecomment-19102)
    * consider the postgres version from the docker compose file, if there is a docker compose from the app itself
    * Check which postgres version we used? Alpine or Debian
      * keep the same for pgautoupgrade: -alpine or -bookworm (for debian)

    :::
  * Type `y` to confirm that you want to commit the changes
* Check the [Release Notes for Apps](/doc/ca61d814-9673-437a-bc13-54ab3eff24ac) for breaking changes
  * If necessary: adapt the recipe
  * f you made other changes to the recipe, commit again
  * Optionally: add changelog to file `release/next`
  * 
    :::warning
    Don’t forget to update the`abra.sh` config versions if you changed something in the listed files in the abra.sh file.

    :::

## Test the Upgrade-Process

### On Dev

* Set the Dev-App and Version envs (optional, personal taste)
* Deploy chaos version to dev instance

  ```bash
  APP_DOMAIN=<app>.dev.local-it.cloud
  abra app deploy -C $APP_DOMAIN
  ```
* Observe the logs for any error messages while upgrading

  ```python
  abra app logs $APP_DOMAIN
  ```
* especially the upgrade process is tested by that

### FOR LOCAL-IT only: On Staging

* Set the version hash to the `alaka-versions.yml` of the staging instance for the recipe you upgrade
* Redeploy staging
* Click around and check if everything works

### Checklist what could break

- [ ] All Apps
  - [ ] SSO Login
- [ ] Authentik
  - [ ] Blueprints

### In case of **issues**

* Check here if issues for specific services/recipes are known: [Troubleshooting](/doc/7b818885-f26f-40ab-b937-1268221f77c3)
* tune the recipe using chaos deployments
* sometimes it might be that on dev there is already a chaos version deployed, than you also need to use the chaos flag to deploy, but no need to update the recipe, see [Version “xxxxxxx” is unknown](https://wiki.local-it.org/doc/recipe-upgrade-HXRCnL1hJp#h-version-xxxxxxx-is-unknown)

  ```bash
  abra app deploy -C $INSTANCE
  ```


:::info
If **the *Test the upgrade* step above didn’t work** on the first try or the dev version was not equal to the current stable version, you need to test the upgrade process from the stable version.

:::

* Downgrade to the stable version

  ```javascript
  abra app undeploy $APP_DOMAIN
  abra app volume rm $APP_DOMAIN
  abra app deploy $APP_DOMAIN $OLD_VERSION
  ```
* Test the upgrade process again

  ```javascript
  abra app upgrade $APP_DOMAIN $NEW_VERSION
  ```

## Publish the Release

* Upgrade the recipe version: Create a new release (it will be directly commited and the tags pushed):
  * Für Breaking Changes oder Major Image Upgrades:

    ```bash
    abra recipe release $RECIPE --major
    ```
  * ODER für Minor Image Upgrades

    ```bash
    abra recipe release $RECIPE --minor
    ```
  * ODER für kleinere Änderungen ausschließlich am Recipe

    ```bash
    abra recipe release $RECIPE --patch
    ```

    

## FOR BREAKING CHANGES: Test a new Deployment


:::info
If you **changed critical parts of the recipe**, you should test if a new deployment still works. Otherwise testing the upgrade process for dev is enough.

:::

* Remove the app

  ```javascript
  abra app undeploy $APP_DOMAIN
  abra app rm $APP_DOMAIN
  ```
* Redeploy with alakazam:
  * set `<new_version>` in `lit-alaka/alaka-testing-versions.yaml`

    ```javascript
    alakazam <dev-server>.yml config -r $RECIPE
    alakazam <dev-server>.yml secrets -r $RECIPE
    alakazam <dev-server>.yml deploy -r $RECIPE
    alakazam <dev-server>.yml cmd --upgrade -r $RECIPE
    ```




:::success
:sparkles:**Done! Next Step →**  [Upgrade Kollektivhosting](/doc/c8f2120f-39a0-4ac3-baf3-3a082dd28e07)

:::


# Troubleshooting

## Version “xxxxxxx” is unknown

**Issue:** You cannot deploy the upgraded recipe on dev to test the upgrade process

**Root Cause:** A version with chaos flag has been deployed (probably on dev instance) before

**Solution:**

* Deploy again with chaos flag ON DEV
* If you succeed deploy on other instances for kollektivhosting with alakazam → exclude dev instance there