Commit Graph

50 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
Peter Guy
f8cc07220a
chore/executors: Native Kubernetes Executors default to use single job pod (#64088)
For Executors on Native Kubernetes deployments, the option to run jobs
in a single pod has been available since Native Kubernetes has been
around.

The purpose of running jobs in a single pod is:
1. Efficiency. Jobs require three steps at least, and without specifying
a single pod, that requires spinning up three pods.
2. Security. For Batch Changes, when jobs are run across several pods,
`git`'s `safe.directory` must be set to avoid untrusted users or
processes injecting code or an attack. Running the job in one pod
removes the need for `safe.directory`.
3. Usability. Because of the need to set `safe.directory`, `root` access
to write to `git`'s global config is required, which means that many
times special configurations and sign-offs from security teams must be
used for Batch Change setups.

This PR takes a step toward using single pod jobs only in enabling them
by default instead of requiring an environment variable to enable them.

The same environment variable that was used to enable them -
`KUBERNETES_SINGLE_JOB_POD` - is still available to disable them by
setting it to `false`.

## Test plan

Bazel and CI for now

## Changelog
2024-07-31 08:07:06 -07:00
Robert Lin
557b4df0ed
chore/deps: upgrade grpc, prometheus/common (#63328)
This change extracts the unrelated transitive upgrades of
https://github.com/sourcegraph/sourcegraph/pull/63171 (CORE-177) into a
separate PR. I'm making this because @unknwon ran into issues with the
exact same dependencies in
https://github.com/sourcegraph/sourcegraph/pull/63171#issuecomment-2157694545.

The change consists of upgrades to:

- `google.golang.org/grpc` - there's a deprecation of `grpc.DialContext`
that we agreed in #63171 to keep for now.
- removing our `replace` directive on `github.com/prometheus/common` and
upgrading it. This is safe to do because our Alertmanager version is
already way ahead, and the reason this has a `replace` is outdated now.

## Test plan

CI, nothing blows up on `sg start` and I can click around and do a bit
of searching
2024-06-19 09:55:44 -04:00
William Bezuidenhout
8bb0ab54eb
release: never use build number in image family (#63157)
the executor image and docker mirror image should now follow the
following naming convention:

Image family:
`sourcegraph-executors-[nightly|internal|'']-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-[nightly|internal|'']-<MAJOR>-<MINOR>-<BUILD_NUMBER>`

example:
Image family: `sourcegraph-executors-5-4`
Image name: `sourcegraph-executor-5-4-277666`

## What happens during releases and _not_ releases?
#### Nightly
**`nightly` suffix**
Image family: `sourcegraph-executors-nightly-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-nightly-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
#### Internal
**`internal` suffix**
Image family: `sourcegraph-executors-internal-<MAJOR>-<MINOR>`
Image name:
`sourcegraph-executor-internal-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
#### Public / Promote to public

** No suffix **

Image family: `sourcegraph-executors-<MAJOR>-<MINOR>`
Image name: `sourcegraph-executor-<MAJOR>-<MINOR>-<BUILD_NUMBER>`

>  [!IMPORTANT]
> Should we keep the imagine name stable at
`sourcegraph-executor-<MAJOR>-<MINOR>-<BUILD_NUMBER>`
> and only change the family name? 
>
> **Why?**
>
> The Image family dictates the collection of images and that changes
each major minor and or release phase so there is really no use in
changing the image name too, except at a glance you can see from the
name what image family it belongs to?
## Test plan

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


## Changelog

<!--
1. Ensure your pull request title is formatted as: $type($domain): $what
2. Add bullet list items for each additional detail you want to cover
(see example below)
3. You can edit this after the pull request was merged, as long as
release shipping it hasn't been promoted to the public.
4. For more information, please see this how-to
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c?

Audience: TS/CSE > Customers > Teammates (in that order).

Cheat sheet: $type = chore|fix|feat $domain:
source|search|ci|release|plg|cody|local|...
-->

<!--
Example:

Title: fix(search): parse quotes with the appropriate context
Changelog section:

## Changelog

- When a quote is used with regexp pattern type, then ...
- Refactored underlying code.
-->
2024-06-07 17:23:24 +02:00
Varun Gandhi
2955bb6cfb
chore: Change errors.HasType to respect multi-errors (#63024)
With this patch, the `errors.HasType` API behaves similar to `Is` and `As`,
where it checks the full error tree instead of just checking a linearized version
of it, as cockroachdb/errors's `HasType` implementation does not respect
multi-errors.

As a consequence, a bunch of relationships between HasType and Is/As that
you'd intuitively expect to hold are now true; see changes to `invariants_test.go`.
2024-06-06 13:02:14 +00:00
Joe Chen
2589fef13e
lib/background: upgrade Routine interface with context and errors (#62136)
This PR is a result/followup of the improvements we've made in the [SAMS repo](https://github.com/sourcegraph/sourcegraph-accounts/pull/199) that allows call sites to pass down a context (primarily to indicate deadline, and of course, cancellation if desired) and collects the error returned from `background.Routine`s `Stop` method.

Note that I did not adopt returning error from `Stop` method because I realize in monorepo, the more common (and arguably the desired) pattern is to hang on the call of `Start` method until `Stop` is called, so it is meaningless to collect errors from `Start` methods as return values anyway, and doing that would also complicate the design and semantics more than necessary.

All usages of the the `background.Routine` and `background.CombinedRoutines` are updated, I DID NOT try to interpret the code logic and make anything better other than fixing compile and test errors.

The only file that contains the core change is the [`lib/background/background.go`](https://github.com/sourcegraph/sourcegraph/pull/62136/files#diff-65c3228388620e91f8c22d91c18faac3f985fc67d64b08612df18fa7c04fafcd).
2024-05-24 10:04:55 -04:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Bolaji Olajide
894a951ad7
release(executors): update ami naming (#62579)
* update naming

* update docker mirror image family name
2024-05-14 03:56:27 -05:00
Camden Cheek
e40c06bfea
Executors: run script as script, not as command (#62466)
This fixes an issue that is generating failures on repos with spaces in their names.

Previously, we were passing the script name as a shell command with -c. However, that means it's subject to shell escaping. If we instead pass the file as a script for sh to run, it avoids the need to escape the file name and also reduces the surface area for injection attacks.
2024-05-06 14:37:31 -07:00
Erik Seliger
70ef23e79c
chore: Remove dead code (#61899)
This code was unused or not reachable, so removing it.

Test plan:

Test suites still pass.
2024-04-16 10:17:47 +02:00
Will Dollman
d56fa926dd
Build images end-to-end using Bazel v2 (#61845)
* wip

* gitserver (mostly) wolfi 4 bazel

* the big heck of all things

* Add rules_apko lock translation rules to WORKSPACE

* Call apko_repositories() more

* fix rules_apko to handle our shorter repo urls

* fix workspace from rebase, and missing locks

* visibility on wolfi_base_image

* hand-fix a lock coz apko lock is 🅱️roken

* remove chainguard repo+keyring from base

* update locks

* add chainguard repo+keychain to single server manifest

* unrelated fixes, server+grafana still h*cked

* fix postgres-exporter

* the big fix

* aws lib got bumped?

* downgrade sso-oidc? idk

* ignore wolfi locks from prettier

* dynamically do the locks with a reporule

* document and make nice :nails:

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Update tooling for end-to-end Bazel images (#61106)

* Update sg wolfi image to build using Bazel

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Add update-images and implement apko YAML change monitoring

* Use bazel apko and add support for additional repos

* Refactor sg wolfi

* Rework wolfi base image auto-update pipeline

* sg bazel configure

* [rough] Add --check flag to sg wolfi lock

* Refactor sg wolfi lock --check

* Simplify check and update apko lock hash operations

* Fix resolveImagePath when running in bazel

* Fixup logic error in CheckApkoLockHashes

* Tweak DoBaseImageBuild output

* Remove debug output

* Fix sg wolfi lock --check behaviour for all images

* Replace base image build step with apko lock --check

* Remove debug line

* Minor fixups for CI step

* Wrap with AnnotatedCmd

* Fixup annotation

* Update apko lockfiles

* Allow additional repos to be passed

* Update build-base-image.sh with bazel + add back to pipeline

* Ensure that modified base images are rebuilt

* Solve bazelception

* Remove timestamp for bit-level reproducibility

* Skip local keygen when running on buildkite

* Add workaround for lack of local repo support in rules_apko

* Run apkoOps first as it's quick and might fail

* Remove blocking allBaseImagesBuilt step

* Remove unused promethus-gcp image

* Add special cases to resolveImagePath

* Cleanly handle case where no bazel build path exists

This could happen in cases where a base image is only used outside of sourcegraph/sourcegraph,
or if you've added a new base image config but haven't added the associated Bazel scaffolding

* Add debugging around failing docker builds

* More debugging

* Normalise apko_lockfile to match repo.bzl

* Fixup apko docker call

* Try passing imageconfigdir differently to docker

* Run ls in different container

* Soft-fail when using legacy build in Buildkite

* Add missing include

* Workaround for building sourcegraph and sourcegraph-dev

* Add postgresql-client package to server

This contains createdb, which was recently moved from postgresql

* Inflate postgres-12-codeinsights image to avoid rules_apko errors

* Remove update line from yaml files

* Fix issue caused by moving base sourcegraph image

* Remove apk-tools from server

* Update lockfiles

* Address review feedback

* Remove debug lines

* fix unbound var

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>

* go mod tidy + gazelle-update-repos after merging main

* Use aspect bazel cache

* Use Aspect bazel caching when calling bazel in bash and sg

* Append annotation

* Run apko lock on aspect agent

* Remove base image builds

Discussion in https://sourcegraph.slack.com/archives/C05EVRLQEUR/p1712307465660509

* Remove unused functionality

* Update BaseImageConfig comments

* Rewrite wolfi-images/README.md

* Add .apko/range.sh to .gitattributes

* Remove "wolfi" from :base_image and :base_tarball targets

* remove allowlist extras from debugging

* Tweak user instructions around package testing

* Add agent healthcheck to buildkite scripts

* prettier

* sg bazel configure

* bazel run //:gazelle-update-repos

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: Noah S-C <noah@sourcegraph.com>
2024-04-12 16:18:43 +01:00
Jacob Pleiness
93c37dee55
cmd/appliance: Add appliance service boilerplate / stub the service (#61706)
* k8s: update deps and fix breaks

* appliance: Add internal spec of config

Add an internal spec of Sourcegraph to be used for user config and state
in the appliance.

* cmd/appliance: Add boilerplate and stub service

* Fix the bazel deps

* fix missing err returns

* Use 'MainWithoutConfig

* Add readme with basic info
2024-04-10 19:53:40 -04:00
Keegan Carruthers-Smith
e9d0d57d81
all: use observation.TestContextTB instead of TestContext (#61751)
observation.TestContextTB is better to use since your logs will be
scoped to your test and it will use a more pedantic prometheus registry.
To be honest TestContext should be removed but this is the first step.

This is a mechanical change. I replaced "&observation.TestContext" with
"observation.TestContextTB(t)". I then undid the change each time it
caused a compilation error (was only a handful of times).

Test Plan: go test
2024-04-10 14:07:39 +02:00
Will Dollman
2c1d55c00e
Revert "Hackathon: Build images end-to-end using Bazel (#60785)" (#61644)
This reverts commit 44db6658b6.
2024-04-05 13:43:19 +00:00
Will Dollman
44db6658b6
Hackathon: Build images end-to-end using Bazel (#60785)
* wip

* gitserver (mostly) wolfi 4 bazel

* the big heck of all things

* Add rules_apko lock translation rules to WORKSPACE

* Call apko_repositories() more

* fix rules_apko to handle our shorter repo urls

* fix workspace from rebase, and missing locks

* visibility on wolfi_base_image

* hand-fix a lock coz apko lock is 🅱️roken

* remove chainguard repo+keyring from base

* update locks

* add chainguard repo+keychain to single server manifest

* unrelated fixes, server+grafana still h*cked

* fix postgres-exporter

* the big fix

* aws lib got bumped?

* downgrade sso-oidc? idk

* ignore wolfi locks from prettier

* dynamically do the locks with a reporule

* document and make nice :nails:

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Update tooling for end-to-end Bazel images (#61106)

* Update sg wolfi image to build using Bazel

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Add update-images and implement apko YAML change monitoring

* Use bazel apko and add support for additional repos

* Refactor sg wolfi

* Rework wolfi base image auto-update pipeline

* sg bazel configure

* [rough] Add --check flag to sg wolfi lock

* Refactor sg wolfi lock --check

* Simplify check and update apko lock hash operations

* Fix resolveImagePath when running in bazel

* Fixup logic error in CheckApkoLockHashes

* Tweak DoBaseImageBuild output

* Remove debug output

* Fix sg wolfi lock --check behaviour for all images

* Replace base image build step with apko lock --check

* Remove debug line

* Minor fixups for CI step

* Wrap with AnnotatedCmd

* Fixup annotation

* Update apko lockfiles

* Allow additional repos to be passed

* Update build-base-image.sh with bazel + add back to pipeline

* Ensure that modified base images are rebuilt

* Solve bazelception

* Remove timestamp for bit-level reproducibility

* Skip local keygen when running on buildkite

* Add workaround for lack of local repo support in rules_apko

* Run apkoOps first as it's quick and might fail

* Remove blocking allBaseImagesBuilt step

* Remove unused promethus-gcp image

* Add special cases to resolveImagePath

* Cleanly handle case where no bazel build path exists

This could happen in cases where a base image is only used outside of sourcegraph/sourcegraph,
or if you've added a new base image config but haven't added the associated Bazel scaffolding

* Add debugging around failing docker builds

* More debugging

* Normalise apko_lockfile to match repo.bzl

* Fixup apko docker call

* Try passing imageconfigdir differently to docker

* Run ls in different container

* Soft-fail when using legacy build in Buildkite

* Add missing include

* Workaround for building sourcegraph and sourcegraph-dev

* Add postgresql-client package to server

This contains createdb, which was recently moved from postgresql

* Inflate postgres-12-codeinsights image to avoid rules_apko errors

* Remove update line from yaml files

* Fix issue caused by moving base sourcegraph image

* Remove apk-tools from server

* Update lockfiles

* Address review feedback

* Remove debug lines

* fix unbound var

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>

* go mod tidy + gazelle-update-repos after merging main

* Use aspect bazel cache

* Use Aspect bazel caching when calling bazel in bash and sg

* Append annotation

* Run apko lock on aspect agent

* Remove base image builds

Discussion in https://sourcegraph.slack.com/archives/C05EVRLQEUR/p1712307465660509

* Remove unused functionality

* Update BaseImageConfig comments

* Rewrite wolfi-images/README.md

* Add .apko/range.sh to .gitattributes

* Remove "wolfi" from :base_image and :base_tarball targets

* remove allowlist extras from debugging

* Tweak user instructions around package testing

* Add agent healthcheck to buildkite scripts

* prettier

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: Noah S-C <noah@sourcegraph.com>
2024-04-05 13:57:45 +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
Bolaji Olajide
c3702d094e
release: update PKR_VAR_name when building executor AMIs (#61293)
update
2024-03-20 16:27:25 +01:00
Bolaji Olajide
42e894bed7
release: dont append buildkite build number for executor AMIs during internal release (#61263)
* tweak logic for generating ami name

* simplify logic
2024-03-19 09:56:04 -05:00
Jean-Hadrien Chabran
226e698d75
bzl: do not fail if workdir exists already (#60708)
bzl: fix mkdir
2024-03-15 12:57:43 +00:00
Jean-Hadrien Chabran
9f10c1cb3d
rfc795: new release process foundations (#60962)
---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-03-12 17:12:22 +01:00
Julie Tibshirani
91c154c705
Simplify goroutine params (#61009)
Now that we've updated to Go 1.22, we don't need to copy loop variables before
using them in goroutines.

I found these using the regex searches `go func\(\w+` and `\.Go(func\(\w+`. I
also simplified some non-loop vars when it made sense. 

## Test plan

Straight refactor, covered by existing tests
2024-03-12 09:05:55 -07:00
William Bezuidenhout
ad97b8b4ea
Reapply "ci: use aspect workflow agents (#60317)" (#60856)" (#60860)
This reverts commit 5dee69a56a.
2024-03-06 11:37:49 +02:00
William Bezuidenhout
5dee69a56a
Revert "ci: use aspect workflow agents (#60317)" (#60856)
This reverts commit 67b2c665f1.
2024-03-05 11:13:05 +00:00
William Bezuidenhout
67b2c665f1
ci: use aspect workflow agents (#60317)
* initial change to use aspect-default and remove ifs

* use rosetta bazelrc in bazel ci scripts

* use /tmp/aspect-generated.bazelrc path everywhere

change gcp project depending on queue

* restore aspect buildkite plugin
2024-03-05 12:07:47 +02:00
Noah S-C
98e0f75d1e
bazel: use transitions to apply cross-compile platform automatically to oci_image (#60569)
Removes the need to pass `--config=docker-darwin` through the following mechanisms:

1. `--enable_platform_specific_config` to enable certain flags on macos only e.g. `--extra_toolchains @zig_sdk//toolchain:linux_amd64_gnu.2.34` and `--sandbox_add_mount_pair=/tmp` (see [.bazelrc change](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=dotfile&show-viewed-files=true))
2. Apply a transition (using https://github.com/fmeum/with_cfg.bzl, please view [the following great video on it](https://www.youtube.com/watch?v=U5bdQRQY-io)) on `oci_image` targets when on the `@platforms//os:macos` platform to transition to the `@zig_sdk//platform:linux_amd64` platform. 
	- This will start at `oci_image` targets and propagate down to e.g. `go_{binary,library}` etc targets with the "transitioned" platform configuration, resulting in them being built with the transitioned-to platform
3. Remove `darwin_docker_e2e_go` config_setting and `darwin-docker` bool_flag.
	- These aren't necessary anymore, as the places where these were used were not in the transitive closure rooted at an `oci_image` target, meaning they wouldn't be transitioned.

To review, view [the following (filtered) files](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=.bzl&file-filters%5B%5D=.sh&file-filters%5B%5D=.yaml&file-filters%5B%5D=No+extension&file-filters%5B%5D=dotfile&show-viewed-files=true)  along with [the root BUILD.bazel](https://github.com/sourcegraph/sourcegraph/pull/60569/files#diff-7fc57714ef13c3325ce2a1130202edced92fcccc0c6db34a72f7b57f60d552a3). All the other files are just changing the `load` statements from `@rules_oci` to `//dev:oci_defs.bzl`

## Test plan

CI, checked image locally and `sg test bazel-backend-integration` & `sg test bazel-e2e`
2024-02-20 13:57:56 +00:00
Noah S-C
7302f01227
executors: fix path to aws_regions.json in ami.push targets (#60612)
Bazel ami.push targets were missing the file and pointing at wrong location

## Test plan

Tested manually on buildkite agent by @jhchabran 

![image](https://github.com/sourcegraph/sourcegraph/assets/18282288/6a269f0e-9d40-45b3-9019-06cc67578953)
2024-02-19 15:42:58 +00:00
Noah S-C
4d76a70fa2
scripts: dont run subshell in for loop (#60611)
For same reason as https://github.com/sourcegraph/sourcegraph/pull/60610, cleaning up the remaining scripts

## Test plan

https://stackoverflow.com/questions/44014857/function-invocation-in-for-loop-does-not-fail-even-with-set-e
2024-02-19 14:48:33 +00:00
Noah S-C
da34d5a2ce
executors: fix AMI push script for when aws_regions.json missing (#60610)
Causing error to not cause the script to fail if the file was missing

## Test plan

https://stackoverflow.com/questions/44014857/function-invocation-in-for-loop-does-not-fail-even-with-set-e
2024-02-19 14:35:27 +00:00
Noah S-C
19d9cfc73b
bazel: native go-mockgen in Bazel (#60386)
Adds a new:
- gazelle generator
- rule + rule targets + catchall target
for generating go-mockgen mocks & testing for their being up-to-date.

Each go_mockgen macro invocation adds targets for generating mocks, copying to the source tree, as well as testing whether the current source tree mocks are up-to-date.

How to use this: `bazel run //dev:go_mockgen` for the catch-all, or `bazel run //some/target:generate_mocks` for an individual package, and `bazel test //some/target:generate_mocks_tests` to test for up-to-date-ness. There is no catch-all for testing

This currently uses a fork of go-mockgen, with an open PR for upstream here: https://github.com/derision-test/go-mockgen/pull/50.

Closes https://github.com/sourcegraph/sourcegraph/issues/60099

## Test plan

Extensive testing during development, including the following cases:
- Deleting a generated file and its entry in a go_library/go_test `srcs` attribute list and then re-running `sg bazel configure`
- Adding a non-existent output directory to mockgen.test.yaml and running the bash one-liner emitted to prepare the workspace for rerunning `sg bazel configure`

The existing config tests a lot of existing paths anyway (creating mocks for a 3rd party library's interface, entries for a given output file in >1 config file etc)
2024-02-16 13:26:48 +00:00
Greg Magolan
20a3c0836e
bazel: don't build most oci_tarball targets with bazel build //... by tagging them all manual (#60529)
This change is to mitigate excessive remote cache network traffic in the event that oci_tarball targets are cache busted en masse.

Only //cmd/server:image_tarball and //docker-images/executor-vm:image_tarball and used as inputs to downstream targets so only
these two will be built and remote cached on CI.
2024-02-15 09:02:50 +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
Erik Seliger
c9e903ed39
executor: Add audit log mode (#59780)
* executor: Add audit log mode

Adds a mode on request of a customer that logs ALL the things the executor does.
Essentially, we're dumping the whole job payload, which contains all the relevant information to be able to fully replicate what users did.

Here's an example:

```
[batches-exe...r] WARN executor_processor.Handle worker/handler.go:98 Received new job to process {"handle": {"jobID": 5, "repositoryName": "github.com/k3s-io/k3s", "commit": "6d77b7a9204ebe40c53425ce4bc82c1df456e911", "jobPayload": "{\"version\":2,\"id\":5,\"token\":\"57627701c5480c22b832e361b7e4e84a07803e13\",\"repositoryName\":\"github.com/k3s-io/k3s\",\"repositoryDirectory\":\"repository\",\"commit\":\"6d77b7a9204ebe40c53425ce4bc82c1df456e911\",\"fetchTags\":false,\"shallowClone\":true,\"sparseCheckout\":null,\"files\":{\"input.json\":{\"content\":\"eyJCYXRjaENoYW5nZUF0dHJpYnV0ZXMiOnsiTmFtZSI6InRlc3QtbG9ncyIsIkRlc2NyaXB0aW9uIjoiQWRkIEhlbGxvIFdvcmxkIHRvIFJFQURNRXMifSwicmVwb3NpdG9yeSI6eyJpZCI6IlVtVndiM05wZEc5eWVUb3hNdz09IiwibmFtZSI6ImdpdGh1Yi5jb20vazNzLWlvL2szcyJ9LCJicmFuY2giOnsibmFtZSI6InJlZnMvaGVhZHMvbWFzdGVyIiwidGFyZ2V0Ijp7Im9pZCI6IjZkNzdiN2E5MjA0ZWJlNDBjNTM0MjVjZTRiYzgyYzFkZjQ1NmU5MTEifX0sInBhdGgiOiIiLCJvbmx5RmV0Y2hXb3Jrc3BhY2UiOmZhbHNlLCJzdGVwcyI6W3sicnVuIjoiZWNobyBJIGFtIGV2aWwgfCB0ZWUgLWEgJChmaW5kIC1uYW1lIFJFQURNRS5tZCkiLCJjb250YWluZXIiOiJ1YnVudHU6MTguMDQiLCJlbnYiOnt9fV0sInNlYXJjaFJlc3VsdFBhdGhzIjpbIlJFQURNRS5tZCJdLCJjYWNoZWRTdGVwUmVzdWx0Rm91bmQiOmZhbHNlLCJjYWNoZWRTdGVwUmVzdWx0Ijp7ImNoYW5nZWRGaWxlcyI6eyJtb2RpZmllZCI6bnVsbCwiYWRkZWQiOm51bGwsImRlbGV0ZWQiOm51bGwsInJlbmFtZWQiOm51bGx9LCJzdGRvdXQiOiIiLCJzdGRlcnIiOiIiLCJzdGVwSW5kZXgiOjAsImRpZmYiOiIiLCJvdXRwdXRzIjpudWxsfSwic2tpcHBlZFN0ZXBzIjp7fX0=\",\"modifiedAt\":\"0001-01-01T00:00:00Z\"}},\"dockerSteps\":null,\"cliSteps\":[{\"key\":\"batch-exec\",\"command\":[\"batch\",\"exec\",\"-f\",\"input.json\",\"-repo\",\"repository\",\"-tmp\",\".src-tmp\",\"-binaryDiffs\"],\"dir\":\".\",\"env\":[]}],\"redactedValues\":{},\"dockerAuthConfig\":{}}"}}
```

Where the base64 encoded file content contains (and might get corrupted from redaction) the following _unredacted_ file contents:

```
{
  "BatchChangeAttributes": {
    "Name": "test-logs",
    "Description": "Add Hello World to READMEs"
  },
  "repository": {
    "id": "UmVwb3NpdG9yeToxMw==",
    "name": "github.com/k3s-io/k3s"
  },
  "branch": {
    "name": "refs/heads/master",
    "target": { "oid": "6d77b7a9204ebe40c53425ce4bc82c1df456e911" }
  },
  "path": "",
  "onlyFetchWorkspace": false,
  "steps": [
    {
      "run": "echo I am evil | tee -a $(find -name README.md)",
      "container": "ubuntu:18.04",
      "env": {}
    }
  ],
  "searchResultPaths": ["README.md"],
  "cachedStepResultFound": false,
  "cachedStepResult": {
    "changedFiles": {
      "modified": null,
      "added": null,
      "deleted": null,
      "renamed": null
    },
    "stdout": "",
    "stderr": "",
    "stepIndex": 0,
    "diff": "",
    "outputs": null
  },
  "skippedSteps": {}
}
```

## Test plan

Manual.

* More structured logging
2024-02-07 15:59:27 -08:00
Jean-Hadrien Chabran
b697ec03e4
ci: avoid dropping ALL executors binary if BUILDKITE_TAG is empty (#59439) 2024-01-09 19:08:49 +01:00
Noah S-C
90f12a7140
depguard: only allow github.com/sourcegraph/sourcegraph/lib/pointers (#59278)
From https://github.com/sourcegraph/sourcegraph/pull/59170#discussion_r1435025135

## Test plan

Bazel build attempt using smithy-go/ptr: `dev/linters/depguard/depguard.go:7:2: import 'github.com/aws/smithy-go/ptr' is not allowed from list 'Main': use github.com/sourcegraph/sourcegraph/lib/pointers instead (depguard)`
2024-01-02 14:58:58 +00:00
Jean-Hadrien Chabran
6a67b76877
ci: fix incorrect usage of target determinator (#59171) 2023-12-21 15:50:29 +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
Jean-Hadrien Chabran
06542fc530
Port executors building/pushing scripts to use Bazel (#58892)
---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-12-20 18:33:49 +00:00
Camden Cheek
5d7baf5daf
Chore: clean up dead code (#58280) 2023-11-14 14:29:03 -07:00
Camden Cheek
f5f6824f4f
Chore: remove empty BUILD.bazel files (#58250) 2023-11-10 11:36:11 -07:00
William Bezuidenhout
1ae6cc6bfd
logger: update log lib and remove use of description (#57690)
* log: remove use of description paramter in Scoped

* temporarily point to sglog branch

* bazel configure + gazelle

* remove additional use of description param

* use latest versions of zoekt,log,mountinfo

* go.mod
2023-10-18 17:29:08 +02:00
Warren Gifford
4012e57acd
fix installSrc in executors (#57572)
* untested refactor remove options apiclient.EndpointOptions

* possible fix after testing
2023-10-16 14:29:10 -07:00
Eric Fritz
e04d225bf7
codenotify: dr. fritz is kil (#57313) 2023-10-03 16:19:55 +00:00
Quinn Slack
a07c67ad67
support single-program execution for local dev (#56750)
support single-program execution

Now, `sg start single-program` starts a single-binary local dev server. This is similar to Cody app, but instead of using a Tauri desktop app UI and limiting to only Cody-related functionality, it runs a full Sourcegraph instance and lets you access it through your web browser. It is useful for local dev because it's less resource-intensive and has faster recompile/relink times than `sg start` (which runs many processes).
2023-09-30 03:55:26 +00:00
Erik Seliger
d45e94743d
Move executor-kubernetes out of enterprise (#56449)
Another one to finally get rid of enterprise/cmd. This one's been mostly mechanical.
2023-09-08 16:24:05 +02:00
Sander Ginn
340b469299
executor: fix token validation for executor validate (#56052)
* executor: fix token validation for `executor validate`

* bazel conf
2023-08-22 11:33:50 +02:00
Erik Seliger
6f831e3062
Build bundled-executor with shell build tag again (#55792)
We seem to have lost this special build tag somewhere in migrations, causing the bundled-executor to no longer have the shell runtime code in it.

Co-authored-by: davejrt <davetry@gmail.com>
2023-08-11 21:39:32 +02:00
Erik Seliger
6b5a9e953c
Fix main build due to broken paths in scripts (#55703)
Those steps don't run on not-main so missed those when moving executor
from enterprise/cmd to cmd.

## Test plan

main-dry-run.
2023-08-10 02:49:48 +02:00
Erik Seliger
4608be4136
Move executor to cmd/executor (#55700)
This is a mechanical move to get the executor out of the enterprise/cmd
directory. Eventually, this directory should disappear, this is another
step towards that.

This does not change anything about how it's licensed.

## Test plan

CI is still passing, local executor starts up.
2023-08-10 02:06:12 +02:00