Commit Graph

51 Commits

Author SHA1 Message Date
Noah S-C
b9c4e2aae9
Revert "Revert "refactor: upgrade to rules_oci 2.0 (2nd attempt)"" (#64354)
Reverts sourcegraph/sourcegraph#64351

## Test plan

Need to test on main due to main-only CI steps (even with main dry-run)
2024-08-08 09:00:08 +00:00
Noah S-C
addba96f47
Revert "refactor: upgrade to rules_oci 2.0 (2nd attempt)" (#64351)
Reverts sourcegraph/sourcegraph#63829

Not working with Aspect Delivery

## Test plan

CI
2024-08-07 22:15:21 +00:00
Greg Magolan
be015c58c2
refactor: upgrade to rules_oci 2.0 (2nd attempt) (#63829)
2nd attempt of #63111, a follow up
https://github.com/sourcegraph/sourcegraph/pull/63085

rules_oci 2.0 brings a lot of performance improvement around oci_image
and oci_pull, which will benefit Sourcegraph. It will also make RBE
faster and have less load on remote cache.

However, 2.0 makes some breaking changes like

- oci_tarball's default output is no longer a tarball
- oci_image no longer compresses layers that are uncompressed, somebody
has to make sure all `pkg_tar` targets have a `compression` attribute
set to compress it beforehand.
- there is no curl fallback, but this is fine for sourcegraph as it
already uses bazel 7.1.

I checked all targets that use oci_tarball as much as i could to make
sure nothing depends on the default tarball output of oci_tarball. there
was one target which used the default output which i put a TODO for
somebody else (somebody who is more on top of the repo) to tackle
**later**.

## Test plan

CI. Also run delivery on this PR (don't land those changes)

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
2024-08-07 22:21:49 +01:00
Noah S-C
adef82f9ed
feat(bazel): read binary version info from accompanying files in OCI images instead of stamping //internal/version (#63977)
https://linear.app/sourcegraph/issue/DINF-111/rework-how-we-inject-version-in-our-artifacts

Pros:
- saves having to rebuild `bazel query 'kind("go_library", rdeps(//...,
//internal/version))' | wc -l` == 523 Go packages when stamp variables
cause a rebuild
- Cutting out GoLink action time when stamp changes but code is cached

Cons:
- Binaries themselves are no longer stamped, only knowing their version
info within the context of the docker image
- A tad extra complexity in internal/version/version.go to handle this
new divergence

---

Before:
```
$ bazel aquery --output=summary --include_commandline=false --include_artifacts=false --include_aspects=false --stamp 'inputs(".*volatile-status\.txt", //...)'

  Action: 1
  Genrule: 2
  Rustc: 3
  ConvertStatusToJson: 88
  GoLink: 383
```

After:
```
$ bazel aquery --output=summary --include_commandline=false --include_artifacts=false --include_aspects=false --stamp 'inputs(".*volatile-status\.txt", //...)'

Mnemonics:
  Genrule: 2
  Action: 3
  Rustc: 3
  ConvertStatusToJson: 86
```

## Test plan

Lots of building & rebuilding with stamp flags, comparing execution logs
& times

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-30 20:52:01 +00:00
Warren Gifford
762f6fa9a9
backend/appliance: Introduce a basic utils package for appliance sourcegraph upgrades (#63529)
Begin introducing an `upgrades` package in the appliance project. Later
to power buttons in target upgrades via site admin interface as well as
maintenance UI

This is just to initialize the package, will implement a better logger
etc later

## Test plan

Unit Tests

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-04 01:48:54 +00:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Noah S-C
21e8d2876b
bazel: move internal/version stamping to internal/version's go_library decl (#61495)
Instead of having to declare the stamp vars on every go_binary (and risk forgetting one, like in https://github.com/sourcegraph/sourcegraph/pull/61480/files#r1543982602), we can stamp at the go_library declaration point instead.

## Test plan

Locally tested with `strings`
2024-03-29 13:41:19 +00:00
Camden Cheek
1ead945267
Docs: update links to point to new site (#60381)
We have a number of docs links in the product that point to the old doc site. 

Method:
- Search the repo for `docs.sourcegraph.com`
- Exclude the `doc/` dir, all test fixtures, and `CHANGELOG.md`
- For each, replace `docs.sourcegraph.com` with `sourcegraph.com/docs`
- Navigate to the resulting URL ensuring it's not a dead link, updating the URL if necessary

Many of the URLs updated are just comments, but since I'm doing a manual audit of each URL anyways, I felt it was worth it to update these while I was at it.
2024-02-13 00:23:47 +00:00
Jean-Hadrien Chabran
1059406b23
chore: drop unused go pkg (#59433)
* chore: drop unused go pkg

* go mod tidy + bazel run :gazelle-update-repos

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-01-09 20:02:28 +01:00
Jean-Hadrien Chabran
2118cc4a39
chore: unexport version.MockTimestamp as it's only used in tests (#59434) 2024-01-09 16:19:58 +00:00
Erik Seliger
f9ac351dc3
Remove App from codebase (#59115)
Cody no longer needs it and it is obsolete now!

Since App added a non-insignificant amount of new concepts and alternative code paths, I decided to take some time and remove it from out codebase.
This PR removes ~21k lines of code. If we ever want parts of single binary (app), the redis kv alternatives, or the release pipeline for a native mac app back, we can look back at this PR and revert parts of it, but maintaining 21k lines of code and many code paths for which I had to delete a surprisingly small amount of tests justifies this move for me very well.

Technically, to some extent SG App and Cody App both still existed in the codebase, but we don't distribute either of them anymore, so IMO we shouldn't keep this weight in our code.

So.. here we go.

This should not affect any of the existing deployments, we only remove functionality that was special-cased for app.
2023-12-21 01:07:05 +01:00
Camden Cheek
539a5e2b38
Chore: construct logger inside dbtest.NewDB (#57549)
construct logger inside dbtest.NewDB
2023-10-11 20:41:11 -05:00
Quinn Slack
8caa9ad9a7
update code references to "Sourcegraph App" -> "Cody App" (#56747)
This updates variable names, property names, env var names, etc., to call it "Cody App".

The entire diff was created by running the following commands:

```
fastmod -e go SourcegraphAppMode CodyAppMode
fastmod -e go,ts,tsx sourcegraphAppMode codyAppMode
fastmod -e ts,tsx isSourcegraphApp isCodyApp
fastmod -e ts,tsx,go,yaml,sh,js SOURCEGRAPH_APP CODY_APP
fastmod -e ts,tsx,go,json,mod,graphql,md,js 'Sourcegraph App\b' 'Cody App'
fastmod -e ts,tsx,go,json,mod,graphql,md,js 'Sourcegraph app\b' 'Cody app' # with a few changes skipped
```
2023-09-19 12:31:12 -10:00
Noah S-C
746a323e26
autoupgrade: use heartbeats to detect crashed autoupgrade attempts (#53859)
If a frontend crashes due to OOM or any other reason, in a way that it
fails to set the `success` column in `upgrade_logs` to `false`, then all
frontends will block trying to claim the autoupgrade lock until the
status is manually set in postgres (or the table is truncated). With a
heartbeat mechanism, we can allow claiming the lock if the last lock
hasnt received a heartbeat in a certain amount of time (here we're
giving 6 missed heartbeats space).

## Test plan

Added unit tests for the claim query, tested in docker-compose

![image](https://github.com/sourcegraph/sourcegraph/assets/18282288/5e79817a-10d9-452f-bcab-e125fc8a8333)
2023-06-21 15:05:13 +00:00
Noah S-C
03aabe58de
mvu: check for upgrade completion during disconnect block checking (#53559)
In certain concurrent situations, it's possible for some frontends to
block indefinitely if theyre trying to autoupgrade when it has already
occurred and dependent services are already up and connected

## Test plan

Tested locally by first bringing up everything in docker-compose besides
sourcegraph-frontend-0, and then bringing it up once everything is reasy
2023-06-15 18:25:32 +00:00
Eric Fritz
2e4b4d3e2d
upgrades: Add UI (#53196) 2023-06-14 13:08:01 +00:00
Noah S-C
a6f1c3f264
mvu: autoupgrade in frontend (#52242)
Implements (basically) fully automated multi-version upgrades as an
optional startup step in the `frontend` service. It was put there for a
few reasons:
1) We can display a UI with whatever we want (not possible in init
containers)
2) We can support rolling upgrades, by booting up ready/health + conf
servers to shutting down of old services and blocking new services from
connecting until autoupgrade is complete

[brain
expansion](https://i.kym-cdn.com/entries/icons/original/000/014/401/tumblr_inline_mqrh26jIU11qz4rgp.jpg)

## Test plan

Expansive testing on a local docker-compose setup (from 3.37.0 to 5.0.5)
and some lighter testing on k3s (from 4.3.1 to 5.0.5)

---------

Co-authored-by: Eric Fritz <eric@sourcegraph.com>
2023-06-13 14:01:54 +01:00
Noah S-C
591d702d29
migrator: extract non-cli specifics from cli package (#53247)
YOINK

## Test plan

Tested migrator with an mvu (`upgrade` from 4.5.0 to 5.0.5) and standard
(`up` from 4.5.0 to 5.0.5)
2023-06-09 18:51:56 +01:00
Jean-Hadrien Chabran
3d36d34b3d
ci: re-enable race detection (#52776)
The previous approach to enable race detection was too radical and
accidently led to build our binaries with the race flage enabled, which
caused issues when building images down the line.

This happened because putting a `test --something` in bazelrc also sets
it on `build` which is absolutely not what we wanted. Usually folks get
this one working by having a `--stamp` config setting that fixes this
when releasing binaries, which we don't at this stage, as we're still
learning Bazel.

Luckily, this was caught swiftly. The current approach insteads takes a
more granular approach, which makes the `go_test` rule uses our own
variant, which injects the `race = "on"` attribute, but only on
`go_test`.


## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI, being a main-dry-run, this will cover the container building jobs,
which were the ones failing.

---------

Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
2023-06-05 20:41:47 +02:00
Noah S-C
dcd27761bf
mvu: fix handle missing 'auto_upgrade' column in versions table (#52509)
We weren't returning the values when performing the fallback query,
instead returning an error regardless

## Test plan

Tested in a full run of migrator
2023-05-26 15:07:25 +00:00
Noah S-C
b9d8b49e1b
mvu: handle missing 'auto_upgrade' column in versions table (#51942)
This column was first added in 5.0.0, so trying to run a migrator from a
version containing https://github.com/sourcegraph/sourcegraph/pull/48787
(no tagged release yet) or later on an instance pre-5.0.0 would result
in `checking auto upgrade: failed to get frontend version and
auto_upgrade state: ERROR: column \"auto_upgrade\" does not exist
(SQLSTATE 42703)`

## Test plan

Tested locally on a full upgrade from 3.33.0 to 5.0.1
2023-05-15 21:05:26 +00:00
Joe Chen
44eb389f8f
Add logic to handle versions.auto_upgrade in migrator upgrade command & UI improvements for Updates page (#48787)
This PR adds graphQL resolver methods to allow handling of the
`auto_upgrade` db column via a toggle switch. It also creates logic to
handle the state of the `auto_upgrade` flag in the `migrator upgrade`
command.

Currently the flag will be set at default as `false` and cannot be
changed via the frontend or any other method besides manually altering
the table via SQL queries. Meaning that `upgrade` will never hit the
`auto_upgrade` path here.

Toggle switch UI elements and API console methods have been separated
into another branch:
https://github.com/sourcegraph/sourcegraph/pull/50206

Finally this PR adds some visibility improvements to the UI and expands
drift by default.


_local dev env for testing_
```
export CODEINTEL_PG_ALLOW_SINGLE_DB=1
export PGUSER=sourcegraph
export PGPASSWORD=sourcegraph
export PGDATABASE=sourcegraph
```


## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

`sg start` was used to check the UI site-admin updates page

`go install cmd/migrator && migrator upgrade` was used to check logic
for handling the `auto_upgrade` column state

---

Part of https://github.com/sourcegraph/sourcegraph/issues/48048

---------

Co-authored-by: DaedalusG <warrenbruceg@gmail.com>
Co-authored-by: Warren Gifford <warren@sourcegraph.com>
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2023-03-31 11:35:51 -07:00
Jean-Hadrien Chabran
a0d53dc030
bzl: disable //client/web:test target (timing out) (#49771)
We're timing out over
https://buildkite.com/sourcegraph/sourcegraph/builds/208980#01870483-3e51-4714-a8a8-229d9ff6f938/35-1224
so let's disable those for now.

cc @valerybugakov 

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

🟢  ci
2023-03-21 10:11:23 -05:00
Joe Chen
b07a465f6e
app: skip one-minor-version upgrade check (#49667) 2023-03-21 22:25:30 +08:00
Dave Try
2b8fa079f0
bazel: fix buf files (#49444)
fix protoc-gen-go version
2023-03-15 20:21:38 +00:00
Dave Try
293385d5dd
bazel: update timeouts to suppress warnings (#49399)
Updates all of the BUILD fields with timeouts to suppress warnings and
reduce log spam.


## Test plan

Green CI
2023-03-15 15:04:16 +02:00
Jean-Hadrien Chabran
7c55c2351e
bk: add soft-failing bazel jobs (#47601)
This PR introduces soft-failing bazel jobs which are running on all
builds, as way to gather experience and feedback on running Bazel in CI.

Changes in the go code are mostly about adding missing git configuration
bits that were failing in the sandbox.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI will show up bazel stuff, but ok to fail. 


![image](https://user-images.githubusercontent.com/10151/223689285-ba4f91f9-991e-42ba-b333-f8adfd503ee9.png)

---------

Co-authored-by: Greg Magolan <gmagolan@gmail.com>
2023-03-08 11:28:18 +00:00
Jean-Hadrien Chabran
bc5490c4bb
bazel: introduce build files for Go (#46770) 2023-01-23 14:00:01 +01:00
Jean-Hadrien Chabran
c31f4a56c8
lint: re-enable depguard in golangci-lint + fix all errors (#45270) 2022-12-06 18:16:04 +01:00
Eric Fritz
37e7a6d035
dbconn: Modify query text to tag source, other metadata (#42588)
Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
2022-10-13 12:34:37 +00:00
Eric Fritz
1ca5650a0e
upgrade: Set new instance version on success (#40767) 2022-08-24 14:02:01 +02:00
Eric Fritz
5192a3ed9c
upgradestore: Add GetServiceVersion (#39645) 2022-07-29 08:44:04 +02:00
Eric Fritz
6e368e0571
migrator: Check previous instance version before making schema changes (#38110) 2022-07-06 00:05:57 +00:00
Eric Fritz
7148009913
errors: Introduce internal package (#30558) 2022-02-07 15:03:45 +00:00
Keegan Carruthers-Smith
e88d1a6f3f
version: remove src_version metric (#25597)
We already have the src_service_metadata metric exporting exactly the
same information.
2021-10-01 16:12:57 +02:00
Keegan Carruthers-Smith
bc5a39c9cf
version: export sourcegraph version in metrics (#24140)
Accidently exported the zoekt version rather than the sourcegraph
version.
2021-08-19 16:22:38 +02:00
Keegan Carruthers-Smith
663ae66437
all: instrument version in trace and prometheus (#24127)
We embed a version identifier in our binaries. This adds it to both
tracing and metrics. For tracing we add the tracer tag
"service.version". For metrics we add the gauge "src_version" which has
a label version. For metrics this can then be joined against[1].

This is useful for observing the impact of a version change on
metrics. Additionally when receiving debug information from customers
this helps us understand exactly which versions are being run.

[1]: https://www.robustperception.io/exposing-the-software-version-to-prometheus
2021-08-19 14:34:53 +02:00
Eric Fritz
abdf10d285
dx: Vet use of errors (#22704) 2021-07-12 19:51:38 +00:00
Eric Fritz
07a025836d
dx: Use cockroachdb/errors over stdlib errors (#22684) 2021-07-08 14:55:34 -05:00
uwedeportivo
15ae17efe1
debug: expose version in /-/debug/proxies/<instance>/vars pages (#12923) 2020-08-14 09:28:38 -07:00
Ryan Slade
a587a76f06
all: Remove redundant declarations (#12146)
* Fix various typos

* Ran GoLand code cleanup

Removed redundant import names
Removed redundant parenthesis
Removed redundant type conversions
2020-07-14 14:35:52 +02:00
Dax McDonald
a1aba93fa3
Implement testing best practices (#11697) 2020-06-24 14:06:54 -07:00
Dax McDonald
b65f041fc2
Correct err check (#11426) 2020-06-11 14:49:15 -07:00
Dax McDonald
9d56df7477
Warn users when sourcegraph becomes out of date (#10843)
This adds alerts when sourcegraph is out of date:
 - Months 1 & 2 outdated only admin is notified. Focus on upgrading being for features/bug fixes.
 - At 3 months, inform admin they may be missing important security bug fixes, warn them users will be notified at 4+ months.
 - 4 months, continue to inform admins of security risks but only inform users of bug fixes.
 - 6+ months, we additionally inform users of security risks, but we keep it just as. a warning level alert.
 - At +1 year, warnings turn to errors.
See site_alerts_test.go for completes spec.
It also removes animated alerts from Sourcegraph.

Co-authored-by: Stephen Gutekanst <stephen.gutekanst@gmail.com>
2020-06-10 17:16:39 -07:00
Geoffrey Gilmore
12493ef065
go: upgrade to 1.14 (#8625)
* go: upgrade to 1.14

* Update go.mod

* Update minversion.go

* Update ci-db-backcompat.sh

* Fix ci

* Update local_development.md

Co-authored-by: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>
2020-02-27 14:55:54 +08:00
Tomás Senart
f4f3c4347a
frontend: Enforce upgrade policy (#8157)
* frontend: Enforce upgrade policy

This commit changes the frontend to enforce our upgrade policy on
startup. A `versions` table is introduced, where the latest seen version
of a service in the Sourcegraph architecture is stored.

For the frontend, this is done on startup, before database migrations
are run. If an admin violates our upgrade policy, the frontend will
shutdown with a descriptive error, pointing to our documentation.

In a future PR, we'll ensure our upgrade policy is respected by
other services. This will be done by sending the service's version
along to the frontend on calls to `api.InternalClient.WaitForFrontend`
during a service's startup procedure, and having the frontend respond
with an error if the upgrade is invalid, which the service should handle
by logging and shutting itself down.

Fixes #7702
Follow-up in #8382

* fixup! Fix test

* fixup! Add integration tests

* fixup! Add comment

* fixup! Remove redundant import

* fixup! support all rollbacks and downgrades

* fixup! Fix typo

* fixup! Prevent panic on first run

* fixup! Support non semantic versions

* fixup! Add CHANGELOG entry

* fixup! ./dev/generate.sh

* fixup! Fix auto conflict resolution screw up
2020-02-17 11:49:13 +00:00
Keegan Carruthers-Smith
9abccadcd3
minversion: Document minversion policy (#7124) 2019-12-09 15:03:19 +02:00
Keegan Carruthers-Smith
19db137bc7
minversion: Lower to any go1.13 (#7083)
minversion is for ensuring developers are on a version of go which doesn't
introduce problems locally. It doesn't need to match the version we use in
CI. Currently minversion is higher than what is available from brew. So this
PR just lowers it to the actual minversion required for development purposes.
2019-12-06 10:50:20 +02:00
Geoffrey Gilmore
2a0ecfbd2a
use go 1.13.5 (#7069) 2019-12-05 11:46:54 -08:00
Geoffrey Gilmore
be23cd497a
require go 1.13.3 (#6200) 2019-10-24 15:17:58 -07:00