Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/blobstore/shared/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions cmd/blobstore/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ import (
"github.com/sourcegraph/sourcegraph/cmd/blobstore/internal/blobstore"
"github.com/sourcegraph/sourcegraph/internal/actor"
"github.com/sourcegraph/sourcegraph/internal/conf"
"github.com/sourcegraph/sourcegraph/internal/env"
"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
"github.com/sourcegraph/sourcegraph/internal/goroutine"
"github.com/sourcegraph/sourcegraph/internal/instrumentation"
"github.com/sourcegraph/sourcegraph/internal/observation"
"github.com/sourcegraph/sourcegraph/internal/service"
"github.com/sourcegraph/sourcegraph/internal/trace"
)

const port = "9000"

func shutdownOnSignal(ctx context.Context, server *http.Server) error {
// Listen for shutdown signals. When we receive one attempt to clean up,
// but do an insta-shutdown if we receive more than one signal.
Expand Down Expand Up @@ -75,10 +73,7 @@ func Start(ctx context.Context, observationCtx *observation.Context, config *Con
defer cancel()
g, ctx := errgroup.WithContext(ctx)

host := ""
if env.InsecureDev {
host = "127.0.0.1"
}
host, port := deploy.BlobstoreHostPort()
addr := net.JoinHostPort(host, port)
server := &http.Server{
ReadTimeout: 75 * time.Second,
Expand Down
1 change: 1 addition & 0 deletions cmd/server/shared/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cmd/server/shared/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"path/filepath"

sglog "github.com/sourcegraph/log"

"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
)

func maybeBlobstore(logger sglog.Logger) []string {
Expand All @@ -14,7 +16,7 @@ func maybeBlobstore(logger sglog.Logger) []string {
}

// Point at local blobstore endpoint.
SetDefaultEnv("PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", "http://127.0.0.1:9000")
SetDefaultEnv("PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint())
SetDefaultEnv("PRECISE_CODE_INTEL_UPLOAD_BACKEND", "blobstore")

// cmd/server-specific blobstore env vars
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"
"time"

"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
"github.com/sourcegraph/sourcegraph/internal/env"
"github.com/sourcegraph/sourcegraph/lib/errors"
)
Expand Down Expand Up @@ -40,7 +41,7 @@ func (c *Config) Load() {

if c.Backend == "blobstore" || c.Backend == "s3" {
c.S3Region = c.Get("PRECISE_CODE_INTEL_UPLOAD_AWS_REGION", "us-east-1", "The target AWS region.")
c.S3Endpoint = c.Get("PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", "http://blobstore:9000", "The target AWS endpoint.")
c.S3Endpoint = c.Get("PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint(), "The target AWS endpoint.")
c.S3UsePathStyle = c.GetBool("PRECISE_CODE_INTEL_UPLOAD_AWS_USE_PATH_STYLE", "false", "Whether to use path calling (vs subdomain calling).")
ec2RoleCredentials := c.GetBool("PRECISE_CODE_INTEL_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS", "false", "Whether to use the EC2 metadata API, or use the provided static credentials.")

Expand Down
1 change: 1 addition & 0 deletions enterprise/internal/embeddings/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion enterprise/internal/embeddings/uploadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/sourcegraph/sourcegraph/lib/errors"

"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
"github.com/sourcegraph/sourcegraph/internal/env"
"github.com/sourcegraph/sourcegraph/internal/observation"
"github.com/sourcegraph/sourcegraph/internal/uploadstore"
Expand Down Expand Up @@ -41,7 +42,7 @@ func (c *EmbeddingsUploadStoreConfig) Load() {

if c.Backend == "blobstore" || c.Backend == "s3" {
c.S3Region = c.Get("EMBEDDINGS_UPLOAD_AWS_REGION", "us-east-1", "The target AWS region.")
c.S3Endpoint = c.Get("EMBEDDINGS_UPLOAD_AWS_ENDPOINT", "http://blobstore:9000", "The target AWS endpoint.")
c.S3Endpoint = c.Get("EMBEDDINGS_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint(), "The target AWS endpoint.")
c.S3UsePathStyle = c.GetBool("EMBEDDINGS_UPLOAD_AWS_USE_PATH_STYLE", "false", "Whether to use path calling (vs subdomain calling).")
ec2RoleCredentials := c.GetBool("EMBEDDINGS_UPLOAD_AWS_USE_EC2_ROLE_CREDENTIALS", "false", "Whether to use the EC2 metadata API, or use the provided static credentials.")

Expand Down
6 changes: 5 additions & 1 deletion internal/conf/deploy/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions internal/conf/deploy/endpoints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package deploy

import (
"github.com/sourcegraph/sourcegraph/internal/env"
)

// BlobstoreEndpoint returns the default blobstore endpoint that should be used for this deployment
// type.
func BlobstoreDefaultEndpoint() string {
if IsApp() {
return "http://127.0.0.1:49000"
}
if IsSingleBinary() {
return "http://127.0.0.1:9000"
}
return "http://blobstore:9000"
}

// BlobstoreHostPort returns the host/port that should be listened on for this deployment type.
func BlobstoreHostPort() (string, string) {
if IsApp() {
return "127.0.0.1", "49000"
}
if env.InsecureDev || IsSingleBinary() {
return "127.0.0.1", "9000"
}
return "", "9000"
}
6 changes: 3 additions & 3 deletions internal/singleprogram/singleprogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Init(logger log.Logger) CleanupFunc {

setDefaultEnv(logger, "SYMBOLS_URL", "http://127.0.0.1:3184")
setDefaultEnv(logger, "SEARCHER_URL", "http://127.0.0.1:3181")
setDefaultEnv(logger, "BLOBSTORE_URL", "http://127.0.0.1:9000")
setDefaultEnv(logger, "BLOBSTORE_URL", deploy.BlobstoreDefaultEndpoint())
setDefaultEnv(logger, "EMBEDDINGS_URL", "http://127.0.0.1:9991")

// The syntax-highlighter might not be running, but this is a better default than an internal
Expand All @@ -69,9 +69,9 @@ func Init(logger log.Logger) CleanupFunc {
// setDefaultEnv(logger, "JAEGER_SERVER_URL", "http://localhost:16686")

// Use blobstore on localhost.
setDefaultEnv(logger, "PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", "http://localhost:9000")
setDefaultEnv(logger, "PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint())
setDefaultEnv(logger, "PRECISE_CODE_INTEL_UPLOAD_BACKEND", "blobstore")
setDefaultEnv(logger, "EMBEDDINGS_UPLOAD_AWS_ENDPOINT", "http://localhost:9000")
setDefaultEnv(logger, "EMBEDDINGS_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint())

// Need to override this because without a host (eg ":3080") it listens only on localhost, which
// is not accessible from the containers
Expand Down