Skip to content

Commit

Permalink
Merge branch 'main' into auto-edits-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaedahBatool authored Jan 20, 2025
2 parents b2acdd3 + b3890e9 commit 68091e7
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 41 deletions.
55 changes: 45 additions & 10 deletions docs/admin/deploy/docker-single-container/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,34 @@ SELECT * FROM users;

## Upgrade

### Postgresql 16
> Warning: The 5.11 release updates the database container images from Postgres 12 to Postgres 16. Customers are advised to have a database backup before upgrading! See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice!
From sourcegraph version 5.11 onwards, the Sourcegraph single container Docker image uses Postgresql 16. Upgrading from Postgresql 12 to Postgresql 16 is a manual process, that is similar to the one outlined below for multi-version upgrades, but migrator has been merged into the container, allowing for a simpler upgrade.

> NOTE: It is highly recommended to **take an up-to-date snapshot of your databases** prior to starting a multi-version upgrade. The upgrade process aggressively mutates the shape and contents of your database, and undiscovered errors in the migration process or unexpected environmental differences may cause an unusable instance or data loss.
>
> Single-container *does not* support auto migration to postgres 16. If you are planning to upgrade to 5.11.0 and beyond on single-container, you will need to dump the postgres databases and restore them after the upgrade.
> In this event, we highly recommend you migrate to a production supported deployment method, or switch to our cloud offering.
> We recommend performing the entire upgrade procedure on an idle clone of the production instance and switch traffic over on success, if possible. This may be low-effort for installations with a canary environment or a blue/green deployment strategy.
>
> **If you do not feel confident running this process solo**, contact customer support team to help guide you thorough the process.
**Before performing a multi-version upgrade**:

- Read our [update policy](/admin/updates/#update-policy) to learn about Sourcegraph updates.
- Find the entries that apply to the version range you're passing through in the [update notes for Sourcegraph with Docker Single Container](/admin/updates/server#multi-version-upgrade-procedure).

0. You must first shutdown the container instance via `docker stop [CONTAINER]`.
1. Start a temporary Postgres container on top of the Postgres data directory used by the old `sourcegraph/server` image. You must use the *new* postgresql-16-codeinsights image, which is based on the new Postgresql 16 image, and provides an automatic upgrade script to move from Postgresql 12 to Postgresql 16.

`docker run --rm -it -v ~/.sourcegraph/data/postgresql:/data/pgdata-12 -e POSTGRES_USER=postgres -p 5432:5432 sourcegraph/postgresql-16-codeinsights:{CURRENT_VERSION_NO_V}`

2. Once that temporary container marks that Postgresql has started, the migration is complete and you can stop the temporary container.
3. Start the new `sourcegraph/server` container.

`docker run --publish 7080:7080 --publish 127.0.0.1:3370:3370 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph sourcegraph/server:{CURRENT_VERSION_NO_V}`

You now have a single server Sourcegraph container image running on Postgresql 16.


### Standard upgrades

Expand All @@ -156,6 +180,16 @@ To update, just use the newer `sourcegraph/server:N.N.N` Docker image (where `N.

### Multi-version upgrades

> NOTE: It is no longer necessary to run Migrator outside of the single instance container. Migrator is now built into the container, and will be run via the `sourcegraph/server` image.
>
> We **still** recommend performing the entire upgrade procedure on an idle clone of the production instance and switch traffic over on success, if possible. This may be low-effort for installations with a canary environment or a blue/green deployment strategy.
>
> The below docs are kept for posterity for users on older versions of Sourcegraph that are looking to upgrade or run the migrator tool.
To update, just use the newer `sourcegraph/server:N.N.N` Docker image in place of the older one, using the same Docker volumes. Your server's data will be migrated automatically if needed. You can always find the version number details of the latest release via the [technical changelog](/technical-changelog).

### (Legacy) Multi-version upgrades

A [multi-version upgrade](/admin/updates/#multi-version-upgrades) is a downtime-incurring upgrade from version 3.20 or later to any future version. Multi-version upgrades will run both schema and data migrations to ensure the data available from the instance remains available post-upgrade.

> NOTE: It is highly recommended to **take an up-to-date snapshot of your databases** prior to starting a multi-version upgrade. The upgrade process aggressively mutates the shape and contents of your database, and undiscovered errors in the migration process or unexpected environmental differences may cause an unusable instance or data loss.
Expand Down Expand Up @@ -218,21 +252,22 @@ For example, `${PATH}` is `~/.sourcegraph/data` in `-v ~/.sourcegraph/data:/var/

```sh
$ docker run --rm -it \
-v ${PATH}/postgresql:/data/pgdata-${PG_VERSION} \
-v ${PATH}/postgresql:/data/pgdata-12 \
-u 70 \
-p 5432:5432 \
--entrypoint bash \
sourcegraph/postgres-${PG_VERSION_TAG}:${SG_VERSION} \
-c 'echo "host all all 0.0.0.0/0 trust" >> /data/pgdata-${PG_VERSION}/pg_hba.conf && postgres -c l listen_addresses="*" -D /data/pgdata-${PG_VERSION}'
sourcegraph/${PG_VERSION_TAG}:${SG_VERSION} \
-c 'echo "host all all 0.0.0.0/0 trust" >> /data/pgdata-12/pg_hba.conf && postgres -c l listen_addresses="*" -D /data/pgdata-12'
```

The version of this Postgres container is dependent on the version of the instance prior to upgrade.

| `${SG_VERSION}` | `${PG_VERSION}` | `${PG_VERSION_TAG}` |
| ------------------- | --------------- | ------------------- |
| `3.20.X` - `3.29.X` | `12` | `12.6` |
| `3.30.X` - `3.37.X` | `12` | `12.6-alpine` |
| `3.38.X` - | `12` | `12-alpine` |
| `${SG_VERSION}` | `${PG_VERSION_TAG}` |
| ------------------- | ------------------- |
| `3.20.X` - `3.29.X` | `postgres-12.6` |
| `3.30.X` - `3.37.X` | `postgres-12.6-alpine`|
| `3.38.X` - `5.9.X` | `postgres-12-alpine` |
| `5.10.X` - | `postgresql-16` |

## Troubleshooting

Expand Down
4 changes: 4 additions & 0 deletions docs/admin/deploy/kubernetes/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ data:
password: ""
port: ""
user: ""
pgsslmode: "require" # optional, enable if using SSL
---
apiVersion: v1
kind: Secret
Expand All @@ -115,6 +116,7 @@ data:
password: ""
port: ""
user: ""
pgsslmode: "require" # optional, enable if using SSL
---
apiVersion: v1
kind: Secret
Expand All @@ -127,6 +129,7 @@ data:
password: ""
port: ""
user: ""
pgsslmode: "require" # optional, enable if using SSL
```
The above Secrets should be deployed to the same namespace as the existing Sourcegraph deployment.
Expand Down Expand Up @@ -163,6 +166,7 @@ pgsql:
user: "new-user"
password: "new-password"
port: "5432"
pgsslmode: "require" # optional, enable if using SSL
```

#### Using external Redis instances
Expand Down
19 changes: 19 additions & 0 deletions docs/admin/executors/executors_troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,22 @@ Tells us that the Pod cannot be scheduled because the pod affinity rules (`EXECU
configured do not match any nodes.

In this case, the `EXECUTOR_KUBERNETES_POD_AFFINITY` needs to be modified to correctly target the node.

### Executor Job failure issues

If you see below errors for executor jobs:

Codeintel
```Index failed to index: Running command "step.kubernetes.pre-index.0": job sg-executor-job-codeintel-111877 failed: Usage of EmptyDir volume "job-data" exceeds the limit "5Gi".```

Batch Changes
```"step.kubernetes.step.0.pre": job sg-executor-job-batches-91562 failed: Usage of EmptyDir volume "job-data" exceeds the limit "5Gi".```

Update the below variables in the respective executor's deployment file to increase EmptyDir volume "job-data" storage. In this example, ```KUBERNETES_JOB_VOLUME_SIZE``` is set to 20Gi, but you can tweak it as per your requirement.

```
- name: KUBERNETES_JOB_VOLUME_TYPE value: emptyDir
- name: KUBERNETES_JOB_VOLUME_SIZE value: 20Gi
```

```KUBERNETES_JOB_VOLUME_TYPE``` can be either set to ```emptyDir``` or ```pvc``` and if it’s not set, the default is ```emptyDir```
File renamed without changes.
1 change: 1 addition & 0 deletions docs/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Currently supported versions of Sourcegraph:

| **Release** | **General Availability Date** | **Supported** | **Release Notes** | **Install** |
|--------------|-------------------------------|---------------|--------------------------------------------------------------------|------------------------------------------------------|
| 5.11 Patch 4 | January 2025 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5114013) | [Install](https://sourcegraph.com/docs/admin/deploy) |
| 5.11 Patch 3 | January 2025 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5114013) | [Install](https://sourcegraph.com/docs/admin/deploy) |
| 5.11 Patch 2 | January 2025 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5113601) | [Install](https://sourcegraph.com/docs/admin/deploy) |
| 5.11 Patch 1 | January 2025 || [Notes](https://sourcegraph.com/docs/technical-changelog#v5112732) | [Install](https://sourcegraph.com/docs/admin/deploy) |
Expand Down
38 changes: 38 additions & 0 deletions docs/technical-changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@ This page documents all notable changes to Sourcegraph. For more detailed change

{/* CHANGELOG_START */}

# 5.11 Patch 4

## v5.11.5234

- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.5234)

- [docker-compose](https://github.com/sourcegraph/deploy-sourcegraph-docker/releases/tag/v5.11.5234)

- [helm](https://github.com/sourcegraph/deploy-sourcegraph-helm/releases/tag/v5.11.5234)

- [kustomize](https://github.com/sourcegraph/deploy-sourcegraph-k8s/releases/tag/v5.11.5234)

### Features

#### Perforce

- Use depot name for label cache `(PR #2805)`

### Fix

#### Source

- Possible Perforce changelists are now converted to their respective git commit during ResolveRevision `(PR #2825)`

### Reverts

There were no reverts for this release

### Uncategorized

#### Others

- [Manual Backport]: update shellcheck to 0.10.0 `(PR #2838)`
- NA

{/* RSS={"version":"v5.11.5234", "releasedAt": "2025-01-17"} */}


# 5.11 Patch 3

## v5.11.4013
Expand Down
60 changes: 30 additions & 30 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ const nextConfig = {
// https://vercel.com/docs/projects/environment-variables/system-environment-variables
// basePath: process.env.VERCEL_ENV === 'production' ? '/docs' : '',
basePath: '/docs',
async redirects() {
return [
...updatedRedirectsData,
{
source: `/v/${config.DOCS_LATEST_VERSION}/:slug*`,
destination: `https://sourcegraph.com/docs/:slug*`,
permanent: false
},
{
source: `/@${config.DOCS_LATEST_VERSION}/:slug*`,
destination: `https://sourcegraph.com/docs/:slug*`,
permanent: false
},
{
source: '/v/:version(\\d+\\.\\d+)/:slug*',
destination: 'https://:version.sourcegraph.com/:slug*',
permanent: true
},
{
source: '/@:version(\\d+\\.\\d+)/:slug*',
destination: 'https://:version.sourcegraph.com/:slug*',
permanent: true
},
{
source: '/changelog.rss',
destination: '/technical-changelog.rss',
permanent: true
}
];
}
// async redirects() {
// return [
// ...updatedRedirectsData,
// {
// source: `/v/${config.DOCS_LATEST_VERSION}/:slug*`,
// destination: `https://sourcegraph.com/docs/:slug*`,
// permanent: false
// },
// {
// source: `/@${config.DOCS_LATEST_VERSION}/:slug*`,
// destination: `https://sourcegraph.com/docs/:slug*`,
// permanent: false
// },
// {
// source: '/v/:version(\\d+\\.\\d+)/:slug*',
// destination: 'https://:version.sourcegraph.com/:slug*',
// permanent: true
// },
// {
// source: '/@:version(\\d+\\.\\d+)/:slug*',
// destination: 'https://:version.sourcegraph.com/:slug*',
// permanent: true
// },
// {
// source: '/changelog.rss',
// destination: '/technical-changelog.rss',
// permanent: true
// }
// ];
// }
};

module.exports = async () => {
Expand Down
1 change: 0 additions & 1 deletion src/data/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const navigation: NavigationItem[] = [
{ title: "Chat", href: "/cody/capabilities/chat", },
{ title: "Autocomplete", href: "/cody/capabilities/autocomplete", },
{ title: "Auto-edit", href: "/cody/capabilities/auto-edit", },
{ title: "Prompts", href: "/cody/capabilities/commands", },
{ title: "OpenCtx", href: "/cody/capabilities/openctx", },
{ title: "Debug Code", href: "/cody/capabilities/debug-code", },
{ title: "Context Filters", href: "/cody/capabilities/ignore-context", },
Expand Down
14 changes: 14 additions & 0 deletions src/data/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6717,6 +6717,20 @@ const redirectsData = [
destination: "/code-search/code-navigation/inference_configuration",
permanent: true
},
// Model Config docs
{
source: "/cody/clients/model-configuration",
destination: "/cody/enterprise/model-configuration",
permanent: true
},

//Commands redirects
{
source: "/cody/capabilities/commands",
destination: "/cody/capabilities/prompts",
permanent: true
},


];

Expand Down
88 changes: 88 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
import docsConfig from '../docs.config.js'

const { updatedRedirectsData } = require('./data/redirects.ts');

function createRedirectUrl(request: NextRequest, destination: string, path: string): string {
// Handle absolute URLs
if (destination.startsWith('http')) {
// Handle dynamic slug replacements
if (destination.includes(':slug')) {
const slugMatch = path.match(/[^/]+$/)
const slug = slugMatch ? slugMatch[0] : ''
destination = destination.replace(':slug*', slug)
}
// Handle version replacements
if (destination.includes(':version')) {
const versionMatch = path.match(/\d+\.\d+/)
const version = versionMatch ? versionMatch[0] : ''
destination = destination.replace(':version', version)
}

return destination
}

// Handle relative paths
const basePath = '/docs'
return destination.startsWith('/') ?
`${request.nextUrl.origin}${basePath}${destination}` :
`${request.nextUrl.origin}${basePath}/${destination}`
}

export function middleware(request: NextRequest) {
const path = request.nextUrl.pathname
const pathWithoutBase = path.replace('/docs', '')

// Handle base redirects from redirects.ts
const redirect = updatedRedirectsData.find((r: any) => r.source === pathWithoutBase)
if (redirect) {
return NextResponse.redirect(createRedirectUrl(request, redirect.destination, path))
}
// Handle version without slug
const versionOnlyMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)$/)
if (versionOnlyMatch) {
return NextResponse.redirect(`https://${versionOnlyMatch[1]}.sourcegraph.com/`)
}
// Handle version-specific redirects
if (pathWithoutBase.startsWith(`/v/${docsConfig.DOCS_LATEST_VERSION}/`)) {
return NextResponse.redirect(createRedirectUrl(
request,
`https://sourcegraph.com/docs/:slug*`,
pathWithoutBase
))
}
if (pathWithoutBase.startsWith(`/@${docsConfig.DOCS_LATEST_VERSION}/`)) {
return NextResponse.redirect(createRedirectUrl(
request,
`https://sourcegraph.com/docs/:slug*`,
pathWithoutBase
))
}
const versionMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)\/(.*)/)
if (versionMatch) {
return NextResponse.redirect(createRedirectUrl(
request,
'https://:version.sourcegraph.com/:slug*',
pathWithoutBase
))
}
const atVersionMatch = pathWithoutBase.match(/^\/@(\d+\.\d+)\/(.*)/)
if (atVersionMatch) {
return NextResponse.redirect(createRedirectUrl(
request,
'https://:version.sourcegraph.com/:slug*',
pathWithoutBase
))
}
if (pathWithoutBase === '/changelog.rss')
return NextResponse.redirect(createRedirectUrl(request, '/technical-changelog.rss', path))

return NextResponse.next()
}

export const config = {
matcher: [
'/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js).*)',
],
}

0 comments on commit 68091e7

Please sign in to comment.