Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Sourcegraph App (single-binary branch) #46547

Merged
merged 52 commits into from
Jan 20, 2023
Merged

Sourcegraph App (single-binary branch) #46547

merged 52 commits into from
Jan 20, 2023

Conversation

emidoots
Copy link
Member

This branch is the main branch of the Sourcegraph App / single-binary product.

Most of these changes were authored by sqs originally, I picked them apart piece-by-piece, reviewed them, and improved them. There are cases where code can certainly be improved (as indicated by TODOs), and will follow up / improve that code. My primary goal has been to identify how quickly we can merge these changes (to stop diverging from main further, as at least 3 people are building upon these changes) without regressing on any behavior.

Reviewing

All commits in this PR were effectively authored by one person, and reviewed by another - either formally or informally. I have made a judgement call that this is sufficient for merge. Feedback is still very welcome (discussion of this approach in Slack).

Once the 4.4 branch cut occurs, this will be stamped and merged into main. We are doing this after the 4.4 branch cut to reduce the risk of any issues that may arise.

The people working on #app are temporarily treating this as our main branch until then, and only reviewed/approved changes are being merged into this branch - excluding changes to get CI/tests passing where appropriate.

Test plan

In some cases new tests were added, in others existing tests provide coverage, in others the only way to verify was through manual testing due to the nature of the changes.

Before merging into main I will ensure a main-dry-run branch passes on CI, executed via the sg tool.

Should any issues arise from merging these changes, we will do our best to "roll forward" (i.e. fix the issues as our #1 priority) not revert, due to the potential for introducing merge conflicts across the company.

@cla-bot cla-bot bot added the cla-signed label Jan 16, 2023
@github-actions
Copy link
Contributor

Problem: the label i-acknowledge-this-goes-into-the-release is absent.
👉 What to do: we're in the next Sourcegraph release code freeze period. If you are 100% sure your changes should get released or provide no risk to the release, add the label your PR with i-acknowledge-this-goes-into-the-release.

@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Jan 16, 2023

Codenotify: Notifying subscribers in CODENOTIFY files for diff 02c985e...a0f7a95.

Notify File(s)
@bobheadxi enterprise/dev/ci/integration/executors/config/site-config.json
enterprise/dev/ci/integration/executors/docker-compose.yml
enterprise/dev/ci/integration/executors/run.sh
enterprise/dev/ci/internal/ci/operations.go
enterprise/dev/ci/internal/ci/pipeline.go
enterprise/dev/ci/scripts/release-app.sh
@efritz cmd/worker/main.go
cmd/worker/shared/config.go
cmd/worker/shared/main.go
cmd/worker/shared/service.go
enterprise/cmd/executor/internal/command/observability.go
enterprise/cmd/executor/internal/run/util.go
enterprise/cmd/executor/main.go
enterprise/cmd/executor/shared/service.go
enterprise/cmd/executor/shared/shared.go
enterprise/cmd/frontend/internal/codeintel/init.go
enterprise/cmd/frontend/internal/executorqueue/init.go
enterprise/cmd/frontend/internal/executorqueue/queuehandler.go
enterprise/cmd/frontend/internal/executorqueue/queuehandler_test.go
enterprise/cmd/frontend/internal/executorqueue/queues/batches/queue.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/queue.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/transform.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/transform_test.go
enterprise/cmd/precise-code-intel-worker/main.go
enterprise/cmd/precise-code-intel-worker/shared/service.go
enterprise/cmd/precise-code-intel-worker/shared/shared.go
enterprise/cmd/worker/main.go
enterprise/cmd/worker/shared/service.go
enterprise/cmd/worker/shared/shared.go
internal/workerutil/observability.go
@eseliger enterprise/cmd/frontend/internal/executorqueue/init.go
enterprise/cmd/frontend/internal/executorqueue/queuehandler.go
enterprise/cmd/frontend/internal/executorqueue/queuehandler_test.go
enterprise/cmd/frontend/internal/executorqueue/queues/batches/queue.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/queue.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/transform.go
enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/transform_test.go
internal/extsvc/github/common.go
@indradhanush cmd/repo-updater/main.go
enterprise/cmd/repo-updater/main.go
enterprise/cmd/repo-updater/shared/service.go
@keegancsmith cmd/searcher/main.go
cmd/searcher/shared/service.go
cmd/searcher/shared/shared.go
cmd/symbols/main.go
cmd/symbols/shared/main.go
cmd/symbols/shared/service.go
cmd/symbols/shared/sqlite.go
cmd/symbols/types/types.go
internal/symbols/client.go
internal/symbols/client_test.go
@ryanslade cmd/repo-updater/main.go
@sashaostrikov cmd/repo-updater/main.go
@unknwon enterprise/cmd/repo-updater/main.go
enterprise/cmd/repo-updater/shared/service.go

@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Jan 16, 2023

Codenotify: Notifying subscribers in OWNERS files for diff 02c985e...a0f7a95.

Notify File(s)
@sourcegraph/dev-experience enterprise/dev/ci/integration/executors/config/site-config.json
enterprise/dev/ci/integration/executors/docker-compose.yml
enterprise/dev/ci/integration/executors/run.sh
enterprise/dev/ci/internal/ci/operations.go
enterprise/dev/ci/internal/ci/pipeline.go
enterprise/dev/ci/scripts/release-app.sh

@github-actions
Copy link
Contributor

Problem: the label i-acknowledge-this-goes-into-the-release is absent.
👉 What to do: we're in the next Sourcegraph release code freeze period. If you are 100% sure your changes should get released or provide no risk to the release, add the label your PR with i-acknowledge-this-goes-into-the-release.

@github-actions
Copy link
Contributor

Problem: the label i-acknowledge-this-goes-into-the-release is absent.
👉 What to do: we're in the next Sourcegraph release code freeze period. If you are 100% sure your changes should get released or provide no risk to the release, add the label your PR with i-acknowledge-this-goes-into-the-release.

@github-actions
Copy link
Contributor

Problem: the label i-acknowledge-this-goes-into-the-release is absent.
👉 What to do: we're in the next Sourcegraph release code freeze period. If you are 100% sure your changes should get released or provide no risk to the release, add the label your PR with i-acknowledge-this-goes-into-the-release.

Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

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

I started reviewing, but this is a monster change. Your rationale in the description makes sense to me, written by SQS, reviewed by you so it is ready to land. I am approving to approve the CI gods. Perfect time to land this large change since we have a whole month before next branch cut just in case we missed something.

func LoadConfig() {
searcherURL = env.Get("SEARCHER_URL", "k8s+http://searcher:3181", "searcher server URL")
highlight.LoadConfig()
symbols.LoadConfig()
Copy link
Member

Choose a reason for hiding this comment

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

side-note: this is an inconsistency @abeatrix recently pointed out to me when we were pairing. symbols is the only service discovery user which isn't setup in this file. It is also the only service discovery we do which isn't advertised through the serviceconnections

shared.Main(func(_ database.DB, _ conftypes.UnifiedWatchable) enterprise.Services {
return enterprise.DefaultServices()
})
osscmd.DeprecatedSingleServiceMainOSS(shared.Service)
Copy link
Member

Choose a reason for hiding this comment

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

why is it deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you look at the func definition (follow the go-to-def chain) you'll see a comment about this:

basically the idea is that we should stop shipping individual binaries (and images) for each service, instead we can have sourcegraph --as=gitserver run the gitserver service and so on. One image for all services.

Basically marked as deprecated just to signal this change is coming, and not to add new services using this approach.

emidoots and others added 16 commits January 19, 2023 16:57
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
…s in the same process

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Add support for multi-platform builds to enterprise/cmd/sourcegraph/build.sh.

Used without any command-line options,
it will build for the current platform, preserving current behavior.

With `--target` command-line options,
it will build for the specified target(s).

Because of OS-dependent coding in various places, windows builds fail.

Different architectures work (arm64 and amd64, for example).

Sample usage:

build.sh --target=linux/amd64 --target darwin/arm64
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
…ingleServiceMain

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
emidoots and others added 22 commits January 19, 2023 16:57
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
…me process

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
…and dev deployments only

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Builds and packages Sourcegraph App for:

- macOS (Universal .zip with single binary)
- Linux (amd64 .zip with single binary, .deb, .rpm)

Uploads to:

- Google Cloud Storage (`sourcegraph-app-releases` bucket)
- Homebrew (temporary repo https://github.com/sourcegraph/homebrew-sourcegraph-app while we consider whether to use sourcegraph/homebrew-sourcegraph)
- GitHub releases on https://github.com/sourcegraph/sourcegraph-app (temporary repo while we consider whether to post releases on the main sourcegraph/sourcegraph repository)

All this occurs when you push a commit to the `app/release-snapshot` branch with `git push -f origin HEAD:app/release-snapshot`. This is sufficient for now. In the future, we can automate nightlies and releases.
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
* executor: improve error logging when running commands

Prior to this change one could get ambiguous errors when executor does its
startup checks, especially in the case of the single-binary deployment where
some of these binaries may not e.g. be installed:

```
ERROR service run/util.go:40 Failed to get src-cli version {"error": "exit status 126"}
```

This change makes it so that the error at least includes what the command output was:

```
ERROR service run/util.go:41 Failed to get src-cli version {"error": "'src version -client-only': error: exit status 126 output: No preset version installed for command src\nPlease install a version by running one of the following:\n\nasdf install golang 1.19.3\n\nor add one of the following versions in your config file at /Users/stephen@sourcegraph.com/work/sourcegraph/.tool-versions\ngolang 1.18.1\n"}
```

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
See executorcmd package comment for details.

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
In `singleprogram` mode package `conf` always behaves as a server (there is only
one process, after all) - but `internal/singleprogram` is imported by pkg `svcmain`
and as a result this init would cause `DEPLOY_TYPE` to incorrectly always be `single-program`
in all deployment types. To fix this

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
`EXECUTOR_QUEUE_DISABLE_ACCESS_TOKEN_INSECURE` may now also be used in
`sourcegraph/server` as well, to aid in our usage of it in regression
tests.

An `_INSECURE` suffix has been added to the env var to highlight that
it is insecure to use this option.

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
…ncing)

Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
@emidoots
Copy link
Member Author

sg ci build main-dry-run passed and I finally feel confident enough to move forward with this. Here goes!

@emidoots emidoots merged commit be4f440 into main Jan 20, 2023
@emidoots emidoots deleted the app branch January 20, 2023 00:35
sg.config.yaml Show resolved Hide resolved
internal/conf/confdefaults/confdefaults.go Show resolved Hide resolved
@@ -159,8 +145,5 @@ func Main() {
},
}

if err := app.RunContext(context.Background(), os.Args); err != nil {
println(err.Error())
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • This may be the reason CI is hanging

Comment on lines +60 to +62
log.SentrySink{
ClientOptions: sentry.ClientOptions{SampleRate: 0.2},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Wasn't enabled for executors

},
),
)
logger := log.Scoped("sourcegraph", "Sourcegraph")
Copy link
Contributor

Choose a reason for hiding this comment

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

Mis-scoped for non-single-binary?

}

env.Lock()
env.HandleHelpFlag()
Copy link
Contributor

Choose a reason for hiding this comment

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

Conflicts with executor's own help flag.

// Start the debug server. The ready boolean state it publishes will become true when *all*
// services report ready.
var allReadyWG sync.WaitGroup
go debugserver.NewServerRoutine(allReady, allDebugserverEndpoints...).Start()
Copy link
Contributor

Choose a reason for hiding this comment

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

Executor spawns debug server on its own (it's not just a service entrypoint)

@efritz
Copy link
Contributor

efritz commented Jan 20, 2023

Started to address executor issues in #46717 with @eseliger.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants