Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
46b7841
additional note
DaedalusG Jan 31, 2025
a260768
feat: add upgrade guide for 6.0
Chickensoupwithrice Jan 31, 2025
fae5c96
fix: update upgrade docs for PG16 docker-compose
Chickensoupwithrice Feb 1, 2025
b144cc0
fix: add copy-paste commands for k8s upgrade
Chickensoupwithrice Feb 1, 2025
4440ca6
docker-compose updates
DaedalusG Feb 3, 2025
2952920
docker-compose formating edits
DaedalusG Feb 3, 2025
84ee836
remove unneeded special case docker-compose upgrade doc
DaedalusG Feb 3, 2025
0eb5fee
6.0.0 kustomize update
DaedalusG Feb 3, 2025
bc25b93
slight edit to kustomize doc
DaedalusG Feb 3, 2025
7897d10
Update docs/admin/deploy/docker-compose/upgrade.mdx
DaedalusG Feb 3, 2025
4d992b2
Update docs/admin/deploy/kubernetes/index.mdx
DaedalusG Feb 3, 2025
0ef56b1
Merge branch 'main' into wg/rel/sourcegraph-6-upgrade-docs
DaedalusG Feb 3, 2025
6f51f57
helm special notes and edits
DaedalusG Feb 4, 2025
b8a05b9
Update docs/admin/deploy/docker-compose/upgrade.mdx
DaedalusG Feb 4, 2025
f882b71
Update docs/admin/how-to/upgrade-postgres-12-16-builtin-dbs.mdx
DaedalusG Feb 4, 2025
56b10c5
Update docs/admin/how-to/upgrade-postgres-12-16-builtin-dbs.mdx
DaedalusG Feb 4, 2025
099bf53
Update docs/admin/postgres.mdx
DaedalusG Feb 4, 2025
9412f04
Update docs/admin/how-to/upgrade-postgres-12-16-builtin-dbs.mdx
DaedalusG Feb 4, 2025
c5cb8b6
Merge branch 'main' into wg/rel/sourcegraph-6-upgrade-docs
DaedalusG Feb 4, 2025
6e45317
Update docs/admin/deploy/kubernetes/index.mdx
MaedahBatool Feb 4, 2025
2518380
Update docs/admin/deploy/docker-compose/upgrade.mdx
MaedahBatool Feb 4, 2025
5636e26
Update docs/admin/postgres.mdx
MaedahBatool Feb 4, 2025
ff55146
Update docs/admin/postgres.mdx
MaedahBatool Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 60 additions & 46 deletions docs/admin/deploy/docker-compose/upgrade.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,70 +59,84 @@ $ docker-compose up -d --remove-orphans

### Multi-version upgrades

If you are upgrading to **Sourcegraph 5.1 or later**, we encourage you to perform an [**automatic multi-version upgrade**](/admin/updates/automatic). The following procedure has been automated, but is still applicable should errors occur in an automated upgrade.
> **⚠️ Attention:** Multiversion upgrades **require downtime**, please see our [cautionary note](/admin/updates/#best-practices) on upgrades, if you have any concerns about running a multiversion upgrade, please reach out to us at [[email protected]](mailto:[email protected]) for advisement.

---

> **⚠️ Attention:** please see our [cautionary note](/admin/updates/#best-practices) on upgrades, if you have any concerns about running a multiversion upgrade, please reach out to us at [[email protected]](mailto:[email protected]) for advisement.

To perform a **manual** multi-version upgrade on a Sourcegraph instance running on Docker compose follow the procedure below:
To perform a multi-version upgrade via migrators [upgrade](/admin/updates/migrator/migrator-operations#upgrade) command on a Sourcegraph instance running on Docker compose follow the procedure below:

1. **Check Upgrade Readiness**:
- Check the [upgrade notes](/admin/updates/docker_compose#docker-compose-upgrade-notes) for the version range you're passing through.
- Check the `Site Admin > Updates` page to determine [upgrade readiness](/admin/updates/#upgrade-readiness).

2. **Disable Connections to the Database**:
- Run the following command in the directory containing your `docker-compose.yaml` file.
```sh
$ docker-compose stop && docker-compose up -d pgsql codeintel-db codeinsights-db
```
3. **Run Migrator with the `upgrade` command**:
- The following procedure describes running migrator in brief, for more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#docker-compose).
1. Set the migrator `image:` in your `docker-compose.yaml` to the **latest** release of `migrator`. **Example:**
2. **Pull and merge upstream changes**:
- Follow the [standard upgrade procedure](#standard-upgrades) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.

3. **Disable Connections to the Database**:
- Stop running containers connected to the databases and the databases:
```
$ docker-compose down --remove-orphans
```

4. **Run Migrator with the `upgrade` command**:
- *For more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#upgrade).*
1. If the migrator `image:` in your `docker-compose.yaml` wasn't updated to in the **latest** release of `migrator` in step 2 set migrator's image to the latest release.
**Example:**
```yaml
migrator:
container_name: migrator
image: 'index.docker.io/sourcegraph/migrator:5.0.4'
image: 'index.docker.io/sourcegraph/migrator:6.0.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to use CURRENT_VERSION_STRING stuff here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be into doing this as a revision later yea, at the moment I think we just need to ship this, and a lot of SG uses this stuff

```
> *Note: Always use the latest image version of migrator for migrator commands, except the startup command `up`*
2. Set the migrator `command:` to `upgrade` you'll need to supply a `--to=` argument. **Example:**
2. Set the migrator `command:` to `upgrade` you'll need to supply a `--to=` argument to the version you're upgrading to.
**Example:**
```yaml
command: ['upgrade', '--from=v4.1.2', '--to=v4.4.0']
command: ['upgrade', '--from=v5.9.0', '--to=v6.0.0']
```
> *Note: you may add the `--dry-run` flag to the `command:` to test things out before altering the dbs*
3. Run migrator with `docker-compose up migrator` **Example:**
3. Run migrator with `docker-compose up migrator`

- Migrator `depends_on:` will ensure that the databases are ready before attempting to run migrator. Ensuring that database entrypoint scripts are run before migrator attempts to connect to the databases. For users upgrading from a version earliar than `5.10.0` a PostrgreSQL version is required and will be performed automatically here. For more details see [Upgradeing PostgreSQL](/admin/postgresql#upgrading-postgresql).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

earlier*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading*


**Example:**
```sh
$ ~/deploy-sourcegraph-docker/docker-compose/ docker-compose up migrator
codeintel-db is up-to-date
codeinsights-db is up-to-date
pgsql is up-to-date
Recreating migrator ... done
✔ Network docker-compose_sourcegraph Create... 0.1s
✔ Container pgsql Created 0.1s
✔ Container codeinsights-db Created 0.1s
✔ Container codeintel-db Created 0.1s
! codeinsights-db The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s
! pgsql The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s
! codeintel-db The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s
✔ Container migrator Created 0.0s
! migrator The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s
Attaching to migrator
migrator | ❗️ An error was returned when detecting the terminal size and capabilities:
migrator |
migrator | GetWinsize: inappropriate ioctl for device
migrator |
migrator | Execution will continue, but please report this, along with your operating
migrator | system, terminal, and any other details, to:
migrator | https://github.com/sourcegraph/sourcegraph/issues/new
migrator |
migrator | ✱ Sourcegraph migrator 4.4.0
migrator | 👉 Migrating to v4.3 (step 1 of 2)
migrator | 👉 Running schema migrations
migrator | ✅ Schema migrations complete
migrator | 👉 Running out of band migrations [17 18]
✅ Out of band migrations complete
migrator | 👉 Migrating to v4.4 (step 2 of 2)
migrator | 👉 Running schema migrations
migrator | ✅ Schema migrations complete
migrator | migrator exited with code 0
migrator | ✱ Sourcegraph migrator 6.0.0
migrator | ⚠️ Failed to check for migrator update: unexpected status code 404. Continuing...
migrator | Attempting connection to frontend...
migrator | ✅ Connection to frontend succeeded
migrator | Attempting connection to frontend...
migrator | ✅ Connection to frontend succeeded
migrator | Attempting connection to codeintel...
migrator | ✅ Connection to codeintel succeeded
migrator | Attempting connection to codeinsights...
migrator | ✅ Connection to codeinsights succeeded
migrator | 👉 Migrating to v6.0 (step 1 of 1)
migrator | 👉 Running schema migrations
migrator | ✅ Schema migrations complete
migrator exited with code 0
```
5. **Run Migrator with the `up` command**
- Set your migrator `command:` to `up`
> *Note: If you aren't upgrading to the latest release remember to set the migrator image back to the version you are upgrading to.*
**Example:**
```yaml
migrator:
container_name: migrator
image: 'index.docker.io/sourcegraph/migrator:6.0.0@sha256:ec295eb0b743da6bf56777ca6524972267a5c442b0288095e2fe12fce38ebacc'
cpus: 0.5
mem_limit: '500m'
command: ['up']
```

4. **Pull and merge upstream changes**:
- Follow the [standard upgrade procedure](#standard-upgrades) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.
- **⚠️ Attention:** *merging upstream changes should set the migrator `image:` version back to the release you are upgrading to, and the `command:` should be set back to `up`, this is necessary to start your instance again.*

5. **Start your containers again**:
6. **Start your containers again**:
- run `docker-compose up -d` in the folder containing your `docker-compose.yaml` file.
```sh
$ docker-compose up -d
Expand Down
2 changes: 2 additions & 0 deletions docs/admin/deploy/kubernetes/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ If you are upgrading to **Sourcegraph 5.1 or later**, we encourage you to perfor
- Check the `Site Admin > Updates` page to determine [upgrade readiness](/admin/updates/#upgrade-readiness).

**Step 2:**
> **⚠️ Attention:** If your database is still running Postgres 12, upgrade your database to Postgres 16 in this step. For our built-in databases offerings, this can be accomplished by starting the databases using our `postgresql-16` images packaged in the deploy repos starting in version `5.10.0`. Learn more [here](/admin/postgres).

Scale down `deployments` and `statefulSets` that access the database, _this step prevents services from accessing the database while schema migrations are in process._
The following services must have their replicas scaled to 0:
- Deployments (e.g., `kubectl scale deployment <name> --replicas=0`)
Expand Down
82 changes: 41 additions & 41 deletions docs/admin/deploy/kubernetes/upgrade.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,46 +120,41 @@ For example, if you use [overlays to make changes to the manifests](https://gith

## Multi-version upgrades

If you are upgrading to **Sourcegraph 5.1 or later**, we encourage you to perform an [**automatic multi-version upgrade**](/admin/updates/automatic). The following procedure has been automated, but is still applicable should errors occur in an automated upgrade.

---

> **⚠️ Attention:** please see our [cautionary note](/admin/updates/#best-practices) on upgrades, if you have any concerns about running a multiversion upgrade, please reach out to us at [[email protected]](mailto:[email protected]) for advisement.

To perform a **manual** multi-version upgrade on a Sourcegraph instance running on our **kubernetes** repo follow the procedure below:
To perform a multi-version upgrade via migrators [upgrade](/admin/updates/migrator/migrator-operations#upgrade) command on a Sourcegraph instance deployed with our [kustomize repo](https://github.com/sourcegraph/deploy-sourcegraph-k8s) follow the procedure below:

1. **Check Upgrade Readiness**:
- Check the [upgrade notes](/admin/updates/kubernetes#kubernetes-upgrade-notes) for the version range you're passing through.
- Check the `Site Admin > Updates` page to determine [upgrade readiness](/admin/updates/#upgrade-readiness).

2. **Disable Connections to the Database**:
- The following services must have their replicas scaled to 0:
- Deployments (e.g., `kubectl scale deployment <name> --replicas=0`)
- precise-code-intel-worker
- repo-updater
- searcher
- sourcegraph-frontend
- sourcegraph-frontend-internal
- symbols
- worker
- Stateful sets (e.g., `kubectl scale sts <name> --replicas=0`):
- gitserver
- indexed-search

*convenience command:*
```sh
$ kubectl scale deployment precise-code-intel-worker repo-updater searcher sourcegraph-frontend sourcegraph-frontend-internal symbols worker --replicas=0 && kubectl scale sts gitserver indexed-search --replicas=0
```

3. **Run Migrator with the `upgrade` command**:
- The following procedure describes running migrator in brief, for more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#kubernetes-kustomize).
1. In the `configure/migrator/migrator.Job.yaml` manifest ([kustomize](https://github.com/sourcegraph/deploy-sourcegraph/blob/master/configure/migrator/migrator.Job.yaml) or [legacy](https://github.com/sourcegraph/deploy-sourcegraph/blob/master/configure/migrator/migrator.Job.yaml)):
2. **Pull and merge upstream changes**:
- Follow the [standard legacy upgrade procedure](#upgrade-with-legacy-kubernetes) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.

3. **Update cluster.yaml and scale down non-database deployments and replicas**:
- In your cluster kustomization file (`instances/my-sourcegraph/kustomize.yaml`), uncomment the [multi-version-upgrade util](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/instances/template/kustomization.template.yaml#L155). This will scale down all non-database deployments and statefulSets replicas to 0.
```yaml
# - ../../components/utils/uid # -- Run all Postgres database with valid users on host
- ../../components/utils/multi-version-upgrade # -- Scale down non-database pods to 0 for multi-version upgrade
# - ../../components/utils/migrate-to-nonprivileged # -- Component for migrating from privileged to non-privileged
#
```
- Generate and apply a new cluster.yaml file.
```sh
kubectl kustomize instances/my-sourcegraph -o cluster.yaml
kubectl apply --prune -l deploy=sourcegraph -f cluster.yaml
```
> Note: This step will ensure that any PostgreSQL upgrade performed as an entrypoint script will have a chance to execute before the migrator is run. For more information see [Upgradeing PostgreSQL](/admin/postgres#upgrading-postgresql).

4. **Run Migrator with the `upgrade` command**:
- *For more detailed instructions and available command flags see our [migrator docs](/admin/updates/migrator/migrator-operations#upgrade).*
1. In the `configure/migrator/migrator.Job.yaml` [manifest](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/components/utils/migrator/resources/migrator.Job.yaml):
- set the `image:` to the **latest** release of `migrator`
- set the `args:` value to `upgrade`. **Example:**
```yaml
- name: migrator
image: "index.docker.io/sourcegraph/migrator:5.0.3"
args: ["upgrade", "--from=v3.41.0", "--to=v4.5.1"]
- name: migrator
image: "index.docker.io/sourcegraph/migrator:6.0.0" // here we use a later version of migrator than the version we're upgrading too.
args: ["upgrade", "--from=v5.9.0", "--to=5.11.0"]
env:
```
> *Note:*
Expand All @@ -168,11 +163,11 @@ To perform a **manual** multi-version upgrade on a Sourcegraph instance running
2. Run the following commands to schedule the migrator job with the upgrade command and monitor its progress:
```sh
# To ensure no previous job invocations will conflict with our current invocation
kubectl delete -f configure/migrator/migrator.Job.yaml
kubectl delete job migrator
# Start the migrator job
kubectl apply -f configure/migrator/migrator.Job.yaml
kubectl apply -f components/utils/migrator/resources/migrator.Job.yaml
# Stream the migrator's stdout logs for progress
kubectl logs job.batch/migrator -f
kubectl logs job/migrator -f
```
**Example:**
```sh
Expand Down Expand Up @@ -209,14 +204,19 @@ To perform a **manual** multi-version upgrade on a Sourcegraph instance running
migrator 1/1 9s 35s
```

4. **Pull and merge upstream changes**:
- Follow the [standard legacy upgrade procedure](#upgrade-with-legacy-kubernetes) to pull and merge upstream changes from the version you are upgrading to to your `release` branch.

5. **Scale your replicas back up and apply new manifests**:
- The [legacy kubernetes upgrade procedure](#upgrade-with-legacy-kubernetes) describes this step in more detail.
- Ensure that the replica counts adjusted in the previous steps are turned back up.
- Run `./kubectl-apply-all.sh` to deploy the new pods to the Kubernetes cluster.
- Monitor the status of the deployment via `kubectl get pods -o wide --watch`.
5. **Generate and apply a new cluster.yaml file**:
1. Comment out the [multi-version-upgrade util](https://github.com/sourcegraph/deploy-sourcegraph-k8s/blob/main/instances/template/kustomization.template.yaml#L155) in your cluster kustomization file (`instances/my-sourcegraph/kustomize.yaml`).
```yaml
# - ../../components/utils/uid # -- Run all Postgres database with valid users on host
# - ../../components/utils/multi-version-upgrade # -- Scale down non-database pods to 0 for multi-version upgrade
# - ../../components/utils/migrate-to-nonprivileged # -- Component for migrating from privileged to non-privileged
```
2. Generate and apply a new cluster.yaml with the new images from Step 2.
```sh
kubectl kustomize instances/my-sourcegraph -o cluster.yaml
kubectl apply --prune -l deploy=sourcegraph -f cluster.yaml
```
Your instance should now be up and running in the new version!

---

Expand Down
Loading