Skip to content

Commit 897ab3a

Browse files
authored
Merge branch 'main' into sg-next-dec18
2 parents 3921955 + 5575ed3 commit 897ab3a

File tree

8 files changed

+109
-109
lines changed

8 files changed

+109
-109
lines changed

docs/admin/config/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ This page documents how to configure a Sourcegraph instance. For deployment conf
3333
- [Restore postgres database from snapshot](/admin/config/restore/)
3434
- [Enabling database encryption for sensitive data](/admin/config/encryption)
3535
- [Configuring Sourcegraph in private networks](/admin/config/private-network)
36+
- [Restricting outgoing connections](/admin/config/network-filtering)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Outoing Connection Filtering
2+
It’s possible for the Sourcegraph instance to deny access to hosts by setting the environment variable `EXTERNAL_DENY_LIST` on the deployment. If you want to only prevent codemonitors and other frontend services to connect to arbitrary hosts, you can set the variable only on the frontend deployment.
3+
The external denylist supports a comma separated list of IP ranges, hostnames and keywords. To block all the internal connections use the “private” keyword, this would block all RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7) IP addresses. Keywords can be combined with ranges and IP addresses so it's very customizable.
4+
5+
The default denylist is set up to only block localhost and the Cloud metadata service IP address. Expanding the denylist could interfere with internal authentication providers, and they might need to be excluded from the denylist.
6+
7+
## Example Configuration
8+
9+
```
10+
EXTERNAL_DENY_LIST="private,github.com"
11+
```
12+
13+
This would deny all connections to hosts in the private network and github.com.
14+
15+
## Implementation Details
16+
To achieve this, we use [gitea's hostmatcher](https://github.com/go-gitea/gitea/blob/v1.22.6/modules/hostmatcher/hostmatcher.go#L39). This is configured by default for the `ExternalClient`, which is used for all external requests. The common options and configuration can be found [here](https://github.com/sourcegraph/sourcegraph-public-snapshot/blob/main/internal/httpcli/client.go#L406C1-L423C2).

docs/admin/deploy/kubernetes/index.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,18 @@ Helm offers a simple deployment process on Kubernetes using well known and stand
2121

2222
</QuickLinks>
2323

24-
<Callout type="warning">Sourcegraph currently does not support migration from an existing Sourcegraph deployment without Helm to a Sourcegraph deployment using Helm. The information you are looking at is currently recommended for a new install of Sourcegraph. We are currently working to provide migration guidance from a non-Helm deployment. If you are inquiring about performing such a migration please email `[email protected]`.</Callout>
25-
2624
## Why use Helm
2725

2826
Our Helm chart has a lot of sensible defaults baked into the values.yaml so that when an override file is used to make the changes, you _never_ have to deal with merge conflicts during upgrades (see more about customizations in the [configuration](#configuration) section).
2927

3028
## High-level overview of how to use Helm with Sourcegraph
3129

3230
1. Prepare any required customizations
33-
- Most environments are likely to need changes from the defaults—use the guidance in [Configuration](#configuration).
34-
- These changes are inclusive of updates to resourcing for each service. See our [resource estimator](/admin/deploy/resource_estimator) for more information.
35-
1. Review the changes
31+
- Most environments will likely require some customizations to the default Helm chart values. See _[Configuration](#configuration)_ for more information.
32+
- Additionally, resource allocations for individual services may need to be adjusted. See our _[Resource Estimator](/admin/deploy/resource_estimator)_ for more information.
33+
2. Review the customized Helm chart
3634
- There are [three mechanisms](#reviewing-changes) that can be used to review any customizations made, this is an optional step, but may be useful the first time you deploy Sourcegraph, for peace of mind.
37-
1. Select your deployment method and follow the guidance:
35+
3. Follow the relevant platform-specific guide below to deploy Sourcegraph to your environment:
3836
- [Google GKE](#configure-sourcegraph-on-google-kubernetes-engine-gke)
3937
- [AWS EKS](#configure-sourcegraph-on-elastic-kubernetes-service-eks)
4038
- [Azure AKS](#configure-sourcegraph-on-azure-managed-kubernetes-service-aks)

docs/admin/external_services/postgres.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { CURRENT_VERSION_STRING_NO_V, CURRENT_VERSION_STRING } from 'src/compone
22

33
# Using your own PostgreSQL server
44

5-
You can use your own PostgreSQL v12+ server with Sourcegraph if you wish. For example, you may prefer this if you already have existing backup infrastructure around your own PostgreSQL server, wish to use Amazon RDS, etc.
5+
You can use your own PostgreSQL v16+ server with Sourcegraph if you wish. For example, you may prefer this if you already have existing backup infrastructure around your own PostgreSQL server, wish to use Amazon RDS, etc.
66

77
Please review the [PostgreSQL](/admin/postgres) documentation for a complete list of requirements.
88

9-
<Callout type="note">As of version 3.39.0, codeinsights-db no longer relies on the internal TimescaleDB and can be externalized.</Callout>
9+
<Callout type="note">As of version 6.0.0 The Sourcegraph application will require PostgreSQL v16+, earlier versions worked with 12 or greater.</Callout>
1010

1111
## General recommendations
1212

docs/admin/postgres.mdx

Lines changed: 13 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ Sourcegraph uses several PostgreSQL databases to support various functionality.
44

55
- `pgsql` or `primary`: responsible for user data and account information
66
- `codeintel-db`: provides support for lsif data and part of the code-intelligence
7+
- `codeinsights-db`: provides support for code insights data
78

89
## Version requirements
910

10-
We support any version **starting from 12**.
11-
12-
> NOTE: ⚠️ Version **3.26** required only Postgres 9.6. You should check the [upgrade docs for your deployment type](/admin/updates/) as well as the [database upgrade docs](#upgrading-postgresql) below prior to upgrading to 3.27.
11+
We support Postgres 16 and above. Older versions of Sourcegraph supported 12 see our [Postgres 12 deprecation notice](/admin/postgres12_end_of_life_notice) for more details.
1312

1413
## Role requirements
1514

@@ -23,19 +22,25 @@ intarray
2322
pg_stat_statements
2423
pg_trgm
2524
pgcrypto
25+
vector
2626
```
2727

2828
## [Configuring PostgreSQL](/admin/config/postgres-conf)
2929

30-
## Upgrading PostgreSQL
30+
### Upgrading Built-in PostgreSQL
3131

32-
Sourcegraph uses PostgreSQL as its main database and this documentation describes how to upgrade PostgreSQL between major versions.
32+
Sourcegraph deployments come packaged with containers using the `postgresql-16` image for `pgsql` and `codeintel-db` deployments and `postgresql-16-codeinsights` for `codeinsights`. These images contain an entryscript which will detect and upgrade Postgres instances at version 12 (our previous images Postgres version). See the (Postgres 12 end of life notice)[/admin/prostgres12_end_of_life_notice#] for more details.
3333

3434
> WARNING: Upgrading the PostgreSQL database requires stopping your Sourcegraph deployment which will result in **downtime**.
35+
>
36+
> Additionally, once the upgrade process is started via the database container, interrupting the container before the upgrade is complete could result in corrupting the underlying Postgres database. We strongly advise taking a backup before the upgrade.
37+
38+
The `PG_UPGRADE_EXTRA_ARGS` env var can be set in the built-in `postgresql-16` and `postgresql-16-codeinsights` deployments to provide extra arguments to the `pg_upgrade` command.
3539

40+
Setting the env var `PG_UPGRADE_EXTRA_ARGS=--link` provides the `--link` option to the underlying `pg_update`; creating a hard links between the old and new data directories instead of copying data. This option is faster and requires less disk space, however if the database containers are interrupted during the upgrade process there is a strong possibility of data corruption. This can still be a viable choice for users who are confident in their container scheduling and backups and would like to avoid longer downtimes.
3641

42+
If not using the `--link` option, you will need enough disk space available for Postgres to make a copy of the existing data. For example, if your database is currently using 100GiB of storage, you will need an additional 100GiB free space in order for the upgrade process to succeed.
3743

38-
> NOTE: If you running PostgreSQL externally, see [Upgrading external PostgreSQL instances](/admin/postgres#upgrading-external-postgresql-instances)
3944

4045
### Upgrading external PostgreSQL instances
4146

@@ -52,100 +57,11 @@ When running an [external PostgreSQL instance](/admin/external_services/postgres
5257
- [EnterpriseDB](https://www.enterprisedb.com/docs/en/9.6/pg/upgrading.html)
5358
- [Citus](http://docs.citusdata.com/en/v8.1/admin_guide/upgrading_citus.html)
5459
- [Aiven PostgreSQL](https://help.aiven.io/postgresql/operations/how-to-perform-a-postgresql-in-place-major-version-upgrade)
55-
- [Your own PostgreSQL](https://www.postgresql.org/docs/11/pgupgrade.html)
60+
- [Your own PostgreSQL](https://www.postgresql.org/docs/16/pgupgrade.html)
5661
4. Turn Sourcegraph back on connecting to the now-upgraded database.
5762

5863
> WARNING: **Do not allow Sourcegraph to run/connect to the new Postgres database until it has been fully populated with your data.** Doing so could result in Sourcegraph trying to create e.g. a new DB schema and partially migrating. If this happens to you, restore from the backup you previously took or contact us ([email protected])
5964
60-
### Upgrading internal PostgreSQL instances
61-
62-
Many of Sourcegraph's [deployment methods](/admin/deploy/) come with internal PostgreSQL instances that can be deployed as part of a Sourcegraph installation. This section outlines how to upgrade these databases.
63-
64-
#### Sourcegraph with Docker Compose
65-
66-
Generally, no additional steps are required to upgrade the databases shipped alongside [Sourcegraph with Docker Compose](/admin/deploy/docker-compose/).
67-
68-
#### Sourcegraph with Kubernetes
69-
70-
**The upgrade process is different for [Sourcegraph Kubernetes deployments](/admin/deploy/kubernetes/)** because [by default](https://github.com/sourcegraph/sourcegraph-public-snapshot/blob/main/docker-images/postgres-12/build.sh#L10), it uses `sourcegraph/postgres-12` which can be [customized with environment variables](https://github.com/sourcegraph/deploy-sourcegraph/blob/7edcadb/docs/configure#external-postgres).
71-
72-
If you have changed `PGUSER`, `PGDATABASE` or `PGDATA`, then the `PG*OLD` and `PG*NEW` environment variables are
73-
required. Below are the defaults and documentation on what each variable is used for:
74-
75-
- `POSTGRES_PASSWORD=''`: Password of `PGUSERNEW` if it is newly created (i.e when `PGUSERNEW` didn't exist in the old
76-
database).
77-
- `PGUSEROLD=sg`: A user that exists in the old database that can be used to authenticate intermediate upgrade
78-
operations.
79-
- `PGUSERNEW=sg`: A user that must exist in the new database after the upgrade is done (i.e. it'll be created if it
80-
didn't exist already).
81-
- `PGDATABASEOLD=sg`: A database that exists in the old database that can be used to authenticate intermediate upgrade
82-
operations. (e.g `psql -d`)
83-
- `PGDATABASENEW=sg`: A database that must exist in the new database after the upgrade is done (i.e. it'll be created if
84-
it didn't exist already).
85-
- `PGDATAOLD=/data/pgdata-11`: The data directory containing the files of the old PostgreSQL database to be upgraded.
86-
- `PGDATANEW=/data/pgdata-12`: The data directory containing the upgraded PostgreSQL data files, used by the new version
87-
of PostgreSQL.
88-
89-
Additionally, the upgrade process assumes it can write to the parent directory of `PGDATAOLD`.
90-
91-
##### Requirements for upgrading from Postgres 11 to 12 for Kubernetes
92-
93-
**This guide is for the Sourcegraph 3.27 release.** The migration to Postgres 12 using the Sourcegraph provided Postgres images is largely automated.
94-
However, you should take some steps before the migration. For the `3.27` release, these apply to the `pgsql` & `codeintel-db` deployments.
95-
96-
1. Inform your users prior to starting the upgrade that Sourcegraph will take downtime. This downtime scales with the
97-
size and resources allocated to the Postgres database instances.
98-
1. Take snapshots of all Sourcegraph Postgres databases. You can find the backing disk in your cloud by describing the
99-
relevant `PersistentVolumes`.
100-
1. Ensure that the size of the disks backing the databases are under 50% utilization. (You will need *up-to* 2x the size
101-
of your current database to do the migration). In most cases Kubernetes can expand the size of the volume for you,
102-
see the relevant kubernetes
103-
docs [here](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#expanding-persistent-volumes-claims).
104-
105-
You can use `kubectl exec -it $DB_POD_NAME -- df -h`. By default, the database will be mounted under `/data/`.
106-
10765
#### Single-container Sourcegraph
10866

109-
When running a new version of Sourcegraph, [single-container Sourcegraph with Docker instances](/admin/deploy/kubernetes/) will check if the PostgreSQL data needs upgrading upon initialization.
110-
111-
See the following steps to upgrade between major postgresql versions:
112-
113-
**1.** Stop the `sourcegraph/server` container.
114-
115-
**2.** Save this script and give it executable permissions (`chmod + x`).
116-
117-
> NOTE: The script presumes your data is being upgraded from `11` to `12` and your Sourcegraph directory is at `~/.sourcegraph/`. Change the values in the code below if that's not the case.
118-
119-
```bash
120-
#!/usr/bin/env bash
121-
122-
set -xeuo pipefail
123-
124-
export OLD=${OLD:-"11"}
125-
export NEW=${NEW:-"12"}
126-
export SRC_DIR=${SRC_DIR:-"$HOME/.sourcegraph"}
127-
128-
docker run \
129-
-w /tmp/upgrade \
130-
-v "$SRC_DIR/data/postgres-$NEW-upgrade:/tmp/upgrade" \
131-
-v "$SRC_DIR/data/postgresql:/var/lib/postgresql/$OLD/data" \
132-
-v "$SRC_DIR/data/postgresql-$NEW:/var/lib/postgresql/$NEW/data" \
133-
"tianon/postgres-upgrade:$OLD-to-$NEW"
134-
135-
mv "$SRC_DIR/data/"{postgresql,postgresql-$OLD}
136-
mv "$SRC_DIR/data/"{postgresql-$NEW,postgresql}
137-
138-
curl -fsSL -o "$SRC_DIR/data/postgres-$NEW-upgrade/optimize.sh" https://raw.githubusercontent.com/sourcegraph/sourcegraph/master/cmd/server/rootfs/postgres-optimize.sh
139-
140-
docker run \
141-
--entrypoint "/bin/bash" \
142-
-w /tmp/upgrade \
143-
-v "$SRC_DIR/data/postgres-$NEW-upgrade:/tmp/upgrade" \
144-
-v "$SRC_DIR/data/postgresql:/var/lib/postgresql/data" \
145-
"postgres:$NEW" \
146-
-c 'chown -R postgres $PGDATA . && gosu postgres bash /admin/optimize.sh $PGDATA'
147-
```
148-
149-
**3.** Execute the script.
150-
151-
**4.** Start the `sourcegraph/server` container.
67+
Sourcegraph Single-container is not a supported production deployment and currently doesn't support upgrades to Postgres 16. Admins with production data in a single container deployment are advised to reach out to [email protected] for assistance.

docs/admin/updates/index.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Sourcegraph releases have three digits, for example: `v5.0.3`
2222
| minor | `0` |
2323
| patch | `3` |
2424

25-
For more details on our release cadence, refer to the [Sourcegraph handbook](https://handbook.sourcegraph.com/departments/engineering/dev/process/releases/#sourcegraph-releases).
25+
For more details on previous releases see [Sourcegraph Releases](/releases).
2626

27-
Generally, we ship a new version of Sourcegraph with new features and bug fixes monthly, followed by a patch release later that month. Major and minor releases happen less frequently and contain substantial changes to Sourcegraph.
27+
Generally, we ship a new minor version of Sourcegraph with new features and bug fixes monthly, followed by a patch release later that month.
2828

2929
Check the [Sourcegraph blog](https://about.sourcegraph.com/blog) for release announcements and details on the latest version.
3030

@@ -78,14 +78,16 @@ It is highly recommended to:
7878
Sourcegraph upgrades take the following general form:
7979
1. Determine if your instance is ready to Upgrade (check upgrade notes)
8080
2. Merge the latest Sourcegraph release into your deployment manifests
81-
3. If updating more than a single minor version, perform an [**automatic multi-version upgrade**](/admin/updates/automatic) if targeting **Sourcegraph 5.1 or later**; [manual multi-version upgrades]/admin/updates/migrator/migrator-operations) are required if upgrading to an earlier version, which requires shutting off the instance and invoking the `migrator` container or job to perform the database rewrite and application of unfinished out-of-band migrations
81+
3. Select an upgrade method:
82+
- If updating more than a single minor version, perform a multiversion upgrade with either the migrator [upgrade command](/admin/updates/migrator/migrator-operations#upgrade) or an [automatic upgrade](/admin/updates/automatic). *This method requires downtime.*
83+
- If updating a single minor version, perform a standard upgrade with the [migrator up command](/admin/updates/migrator/migrator-operations#up) or an [automatic upgrade](/admin/updates/automatic). `up` is the default migrator entry command and runs on `frontend` startup.
8284
4. With upstream changes to your manifests merged, start the new instance
8385

8486
> Note: For more explicit steps, specific to your deployment see the operations guides linked below.
8587
8688
### Upgrade Readiness
8789

88-
Starting in v5.0.0, as an admin you are able to check instance upgrade readiness by navigating to the `Site admin > Updates` page. Here you'll be notified if your instance has any **schema drift** or unfinished **out of band migrations**.
90+
Navigate to the `Site admin > Updates` page. Here you'll be notified if your instance has any **schema drift** or unfinished **out of band migrations**.
8991

9092
![Screenshot 2023-05-17 at 1 37 12 PM](https://storage.googleapis.com/sourcegraph-assets/docs/239155807-185fc3e8-0706-4a23-b9fe-e262f9a9e4b3.png)
9193

@@ -117,6 +119,7 @@ If your instance has schema drift or unfinished oob migrations you may need to a
117119
- [**Sourcegraph AWS AMI instances**](/admin/deploy/machine-images/aws-ami#upgrade)
118120

119121
## Other helpful links
122+
- [Postgres 12 End Of Life Notice](admin/postgres12_end_of_life_notice#postgres-12-end-of-life)
120123
- [Migrator operations](/admin/updates/migrator/migrator-operations)
121124
- [Upgrading Early Versions](/admin/updates/migrator/upgrading-early-versions)
122125
- [Troubleshooting upgrades](/admin/updates/migrator/troubleshooting-upgrades)

docs/releases.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Currently supported versions of Sourcegraph:
1212

1313
| **Release** | **General Availability Date** | **Supported** | **Release Notes** | **Install** |
1414
|--------------|-------------------------------|---------------|--------------------------------------------------------------------|------------------------------------------------------|
15+
| 5.10 Patch 2 | December 2024 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5102832) | [Install](https://sourcegraph.com/docs/admin/deploy) |
1516
| 5.10 Patch 1 | December 2024 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5101164) | [Install](https://sourcegraph.com/docs/admin/deploy) |
1617
| 5.10 Patch 0 | November 2024 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5100) | [Install](https://sourcegraph.com/docs/admin/deploy) |
1718
| 5.9 Patch 3 | November 2024 || [Notes](https://sourcegraph.com/docs/technical-changelog#v591590) | [Install](https://sourcegraph.com/docs/admin/deploy) |

0 commit comments

Comments
 (0)