diff --git a/.github/test.CODEOWNERS b/.github/test.CODEOWNERS index 5a29f634aad..ba1a4484980 100644 --- a/.github/test.CODEOWNERS +++ b/.github/test.CODEOWNERS @@ -96,13 +96,13 @@ /cmd/repo-updater/internal/authz/**/* @unknwon -/enterprise/cmd/worker/**/* @efritz +/cmd/worker/**/* @efritz -/enterprise/cmd/worker/internal/batches/**/* @eseliger +/cmd/worker/internal/batches/**/* @eseliger -/enterprise/cmd/worker/internal/executorqueue/**/* @efritz @eseliger +/cmd/worker/internal/executorqueue/**/* @efritz @eseliger -/enterprise/cmd/worker/internal/executors/**/* @efritz +/cmd/worker/internal/executors/**/* @efritz /enterprise/dev/ci/**/* @bobheadxi diff --git a/cmd/frontend/graphqlbackend/BUILD.bazel b/cmd/frontend/graphqlbackend/BUILD.bazel index af4975cd73c..df7f8d5d0cc 100644 --- a/cmd/frontend/graphqlbackend/BUILD.bazel +++ b/cmd/frontend/graphqlbackend/BUILD.bazel @@ -243,7 +243,7 @@ go_library( "//cmd/frontend/hubspot/hubspotutil", "//cmd/frontend/internal/processrestart", "//cmd/frontend/internal/search/logs", - "//enterprise/cmd/worker/shared/sourcegraphoperator", + "//cmd/worker/shared/sourcegraphoperator", "//internal/actor", "//internal/adminanalytics", "//internal/api", diff --git a/cmd/frontend/graphqlbackend/external_accounts.go b/cmd/frontend/graphqlbackend/external_accounts.go index 5d8f7fc716b..0ade76a4e12 100644 --- a/cmd/frontend/graphqlbackend/external_accounts.go +++ b/cmd/frontend/graphqlbackend/external_accounts.go @@ -8,7 +8,7 @@ import ( "github.com/graph-gophers/graphql-go" "github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend/graphqlutil" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/authz/permssync" diff --git a/cmd/frontend/internal/auth/sourcegraphoperator/BUILD.bazel b/cmd/frontend/internal/auth/sourcegraphoperator/BUILD.bazel index 60b927bfe7d..8cffce48906 100644 --- a/cmd/frontend/internal/auth/sourcegraphoperator/BUILD.bazel +++ b/cmd/frontend/internal/auth/sourcegraphoperator/BUILD.bazel @@ -15,7 +15,7 @@ go_library( "//cmd/frontend/auth", "//cmd/frontend/external/session", "//cmd/frontend/internal/auth/openidconnect", - "//enterprise/cmd/worker/shared/sourcegraphoperator", + "//cmd/worker/shared/sourcegraphoperator", "//internal/actor", "//internal/auth", "//internal/auth/providers", @@ -47,7 +47,7 @@ go_test( "//cmd/frontend/auth", "//cmd/frontend/external/session", "//cmd/frontend/internal/auth/openidconnect", - "//enterprise/cmd/worker/shared/sourcegraphoperator", + "//cmd/worker/shared/sourcegraphoperator", "//internal/actor", "//internal/auth", "//internal/auth/providers", diff --git a/cmd/frontend/internal/auth/sourcegraphoperator/associate.go b/cmd/frontend/internal/auth/sourcegraphoperator/associate.go index 83ffec51b15..0b91ad0f8ba 100644 --- a/cmd/frontend/internal/auth/sourcegraphoperator/associate.go +++ b/cmd/frontend/internal/auth/sourcegraphoperator/associate.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/auth/providers" "github.com/sourcegraph/sourcegraph/internal/database" diff --git a/cmd/frontend/internal/auth/sourcegraphoperator/associate_test.go b/cmd/frontend/internal/auth/sourcegraphoperator/associate_test.go index e9fda9136d0..5eebc52683c 100644 --- a/cmd/frontend/internal/auth/sourcegraphoperator/associate_test.go +++ b/cmd/frontend/internal/auth/sourcegraphoperator/associate_test.go @@ -11,7 +11,7 @@ import ( "github.com/sourcegraph/log/logtest" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/auth/providers" diff --git a/cmd/frontend/internal/auth/sourcegraphoperator/config.go b/cmd/frontend/internal/auth/sourcegraphoperator/config.go index bbc17f53fc6..363e888f81d 100644 --- a/cmd/frontend/internal/auth/sourcegraphoperator/config.go +++ b/cmd/frontend/internal/auth/sourcegraphoperator/config.go @@ -6,7 +6,7 @@ import ( "github.com/sourcegraph/log" "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/auth/openidconnect" - osssourcegraphoperator "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + osssourcegraphoperator "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/auth/providers" "github.com/sourcegraph/sourcegraph/internal/cloud" diff --git a/cmd/frontend/internal/auth/sourcegraphoperator/middleware.go b/cmd/frontend/internal/auth/sourcegraphoperator/middleware.go index 5a728cd2da0..2cd6f9389bf 100644 --- a/cmd/frontend/internal/auth/sourcegraphoperator/middleware.go +++ b/cmd/frontend/internal/auth/sourcegraphoperator/middleware.go @@ -11,7 +11,7 @@ import ( "github.com/sourcegraph/sourcegraph/cmd/frontend/auth" "github.com/sourcegraph/sourcegraph/cmd/frontend/external/session" "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/auth/openidconnect" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/actor" internalauth "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/auth/providers" diff --git a/cmd/server/BUILD.bazel b/cmd/server/BUILD.bazel index ecd5d904fbe..b94693ee2e1 100644 --- a/cmd/server/BUILD.bazel +++ b/cmd/server/BUILD.bazel @@ -98,7 +98,7 @@ DEPS = [ "//enterprise/cmd/migrator", "//cmd/repo-updater", "//enterprise/cmd/symbols", - "//enterprise/cmd/worker", + "//cmd/worker", ] ZOEKT_DEPS = [ diff --git a/cmd/sourcegraph/BUILD.bazel b/cmd/sourcegraph/BUILD.bazel index 7c9b4951f7c..e249cb653bd 100644 --- a/cmd/sourcegraph/BUILD.bazel +++ b/cmd/sourcegraph/BUILD.bazel @@ -14,9 +14,9 @@ go_library( "//cmd/repo-updater/shared", "//cmd/searcher/shared", "//cmd/sourcegraph/osscmd", + "//cmd/worker/shared", "//enterprise/cmd/embeddings/shared", "//enterprise/cmd/symbols/shared", - "//enterprise/cmd/worker/shared", "//internal/sanitycheck", "//internal/service", "//internal/service/localcodehost", diff --git a/cmd/sourcegraph/main.go b/cmd/sourcegraph/main.go index 6a42200931c..42aa8b066b9 100644 --- a/cmd/sourcegraph/main.go +++ b/cmd/sourcegraph/main.go @@ -16,9 +16,9 @@ import ( precise_code_intel_worker_shared "github.com/sourcegraph/sourcegraph/cmd/precise-code-intel-worker/shared" repoupdater_shared "github.com/sourcegraph/sourcegraph/cmd/repo-updater/shared" searcher_shared "github.com/sourcegraph/sourcegraph/cmd/searcher/shared" + worker_shared "github.com/sourcegraph/sourcegraph/cmd/worker/shared" embeddings_shared "github.com/sourcegraph/sourcegraph/enterprise/cmd/embeddings/shared" symbols_shared "github.com/sourcegraph/sourcegraph/enterprise/cmd/symbols/shared" - worker_shared "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared" "github.com/sourcegraph/sourcegraph/ui/assets" _ "github.com/sourcegraph/sourcegraph/ui/assets/enterprise" // Select enterprise assets diff --git a/cmd/worker/BUILD.bazel b/cmd/worker/BUILD.bazel index 055de14a10c..315ade4a93c 100644 --- a/cmd/worker/BUILD.bazel +++ b/cmd/worker/BUILD.bazel @@ -1,7 +1,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@container_structure_test//:defs.bzl", "container_structure_test") -load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball") load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("//dev:oci_defs.bzl", "image_repository") go_library( name = "worker_lib", @@ -59,3 +60,9 @@ container_structure_test( "requires-network", ], ) + +oci_push( + name = "candidate_push", + image = ":image", + repository = image_repository("worker"), +) diff --git a/enterprise/cmd/worker/internal/auth/BUILD.bazel b/cmd/worker/internal/auth/BUILD.bazel similarity index 84% rename from enterprise/cmd/worker/internal/auth/BUILD.bazel rename to cmd/worker/internal/auth/BUILD.bazel index 7fed0b1a0b6..1a3ea3533d4 100644 --- a/enterprise/cmd/worker/internal/auth/BUILD.bazel +++ b/cmd/worker/internal/auth/BUILD.bazel @@ -4,12 +4,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "auth", srcs = ["sourcegraph_operator_cleaner.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/auth", + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/auth", visibility = ["//visibility:public"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/shared/sourcegraphoperator", + "//cmd/worker/shared/sourcegraphoperator", "//internal/actor", "//internal/auth", "//internal/cloud", @@ -33,7 +33,7 @@ go_test( "requires-network", ], deps = [ - "//enterprise/cmd/worker/shared/sourcegraphoperator", + "//cmd/worker/shared/sourcegraphoperator", "//internal/auth", "//internal/cloud", "//internal/database", diff --git a/enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner.go b/cmd/worker/internal/auth/sourcegraph_operator_cleaner.go similarity index 98% rename from enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner.go rename to cmd/worker/internal/auth/sourcegraph_operator_cleaner.go index 98aee4d0c01..2de5eead3cc 100644 --- a/enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner.go +++ b/cmd/worker/internal/auth/sourcegraph_operator_cleaner.go @@ -8,7 +8,7 @@ import ( "github.com/sourcegraph/sourcegraph/cmd/worker/job" workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/cloud" diff --git a/enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go b/cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go similarity index 98% rename from enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go rename to cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go index 1c9d59fe6b7..0afed3673dc 100644 --- a/enterprise/cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go +++ b/cmd/worker/internal/auth/sourcegraph_operator_cleaner_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/exp/slices" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator" + "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator" "github.com/sourcegraph/sourcegraph/internal/auth" "github.com/sourcegraph/sourcegraph/internal/cloud" "github.com/sourcegraph/sourcegraph/internal/database" diff --git a/enterprise/cmd/worker/internal/batches/BUILD.bazel b/cmd/worker/internal/batches/BUILD.bazel similarity index 73% rename from enterprise/cmd/worker/internal/batches/BUILD.bazel rename to cmd/worker/internal/batches/BUILD.bazel index 08a71461c03..a67585d10f5 100644 --- a/enterprise/cmd/worker/internal/batches/BUILD.bazel +++ b/cmd/worker/internal/batches/BUILD.bazel @@ -11,14 +11,14 @@ go_library( "scheduler_job.go", "workspace_resolver_job.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches", + visibility = ["//cmd/worker:__subpackages__"], deps = [ + "//cmd/worker/internal/batches/janitor", + "//cmd/worker/internal/batches/workers", + "//cmd/worker/internal/executorqueue", "//cmd/worker/job", "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/internal/batches/janitor", - "//enterprise/cmd/worker/internal/batches/workers", - "//enterprise/cmd/worker/internal/executorqueue", "//internal/actor", "//internal/batches/scheduler", "//internal/batches/sources", diff --git a/enterprise/cmd/worker/internal/batches/CODENOTIFY b/cmd/worker/internal/batches/CODENOTIFY similarity index 100% rename from enterprise/cmd/worker/internal/batches/CODENOTIFY rename to cmd/worker/internal/batches/CODENOTIFY diff --git a/enterprise/cmd/worker/internal/batches/bulk_operation_processor_job.go b/cmd/worker/internal/batches/bulk_operation_processor_job.go similarity index 94% rename from enterprise/cmd/worker/internal/batches/bulk_operation_processor_job.go rename to cmd/worker/internal/batches/bulk_operation_processor_job.go index 17f579edcf6..91c06f8a5a1 100644 --- a/enterprise/cmd/worker/internal/batches/bulk_operation_processor_job.go +++ b/cmd/worker/internal/batches/bulk_operation_processor_job.go @@ -3,8 +3,8 @@ package batches import ( "context" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/cmd/worker/job" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/batches/sources" "github.com/sourcegraph/sourcegraph/internal/env" diff --git a/enterprise/cmd/worker/internal/batches/dbstore.go b/cmd/worker/internal/batches/dbstore.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/dbstore.go rename to cmd/worker/internal/batches/dbstore.go diff --git a/enterprise/cmd/worker/internal/batches/janitor/BUILD.bazel b/cmd/worker/internal/batches/janitor/BUILD.bazel similarity index 80% rename from enterprise/cmd/worker/internal/batches/janitor/BUILD.bazel rename to cmd/worker/internal/batches/janitor/BUILD.bazel index 8a0c3f03ec9..0c6b5e92359 100644 --- a/enterprise/cmd/worker/internal/batches/janitor/BUILD.bazel +++ b/cmd/worker/internal/batches/janitor/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "resetters.go", "spec_expire.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/janitor", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/janitor", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//internal/batches/store", "//internal/batches/types", diff --git a/enterprise/cmd/worker/internal/batches/janitor/cache_entry_cleaner.go b/cmd/worker/internal/batches/janitor/cache_entry_cleaner.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/janitor/cache_entry_cleaner.go rename to cmd/worker/internal/batches/janitor/cache_entry_cleaner.go diff --git a/enterprise/cmd/worker/internal/batches/janitor/changeset_detached_cleaner.go b/cmd/worker/internal/batches/janitor/changeset_detached_cleaner.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/janitor/changeset_detached_cleaner.go rename to cmd/worker/internal/batches/janitor/changeset_detached_cleaner.go diff --git a/enterprise/cmd/worker/internal/batches/janitor/observability.go b/cmd/worker/internal/batches/janitor/observability.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/janitor/observability.go rename to cmd/worker/internal/batches/janitor/observability.go diff --git a/enterprise/cmd/worker/internal/batches/janitor/resetters.go b/cmd/worker/internal/batches/janitor/resetters.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/janitor/resetters.go rename to cmd/worker/internal/batches/janitor/resetters.go diff --git a/enterprise/cmd/worker/internal/batches/janitor/spec_expire.go b/cmd/worker/internal/batches/janitor/spec_expire.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/janitor/spec_expire.go rename to cmd/worker/internal/batches/janitor/spec_expire.go diff --git a/enterprise/cmd/worker/internal/batches/janitor_config.go b/cmd/worker/internal/batches/janitor_config.go similarity index 86% rename from enterprise/cmd/worker/internal/batches/janitor_config.go rename to cmd/worker/internal/batches/janitor_config.go index 0ebd8fd5db2..8cccdb8ee7b 100644 --- a/enterprise/cmd/worker/internal/batches/janitor_config.go +++ b/cmd/worker/internal/batches/janitor_config.go @@ -1,7 +1,7 @@ package batches import ( - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executorqueue" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/internal/env" "github.com/sourcegraph/sourcegraph/lib/errors" ) diff --git a/enterprise/cmd/worker/internal/batches/janitor_job.go b/cmd/worker/internal/batches/janitor_job.go similarity index 93% rename from enterprise/cmd/worker/internal/batches/janitor_job.go rename to cmd/worker/internal/batches/janitor_job.go index 7e21a93a125..a36566a9d0e 100644 --- a/enterprise/cmd/worker/internal/batches/janitor_job.go +++ b/cmd/worker/internal/batches/janitor_job.go @@ -3,9 +3,9 @@ package batches import ( "context" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/janitor" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/cmd/worker/job" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/janitor" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/env" "github.com/sourcegraph/sourcegraph/internal/goroutine" diff --git a/enterprise/cmd/worker/internal/batches/reconciler_job.go b/cmd/worker/internal/batches/reconciler_job.go similarity index 94% rename from enterprise/cmd/worker/internal/batches/reconciler_job.go rename to cmd/worker/internal/batches/reconciler_job.go index aaf8b6f0f1b..a6b02c41a29 100644 --- a/enterprise/cmd/worker/internal/batches/reconciler_job.go +++ b/cmd/worker/internal/batches/reconciler_job.go @@ -3,8 +3,8 @@ package batches import ( "context" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/cmd/worker/job" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/batches/sources" "github.com/sourcegraph/sourcegraph/internal/env" diff --git a/enterprise/cmd/worker/internal/batches/scheduler_job.go b/cmd/worker/internal/batches/scheduler_job.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/scheduler_job.go rename to cmd/worker/internal/batches/scheduler_job.go diff --git a/enterprise/cmd/worker/internal/batches/workers/BUILD.bazel b/cmd/worker/internal/batches/workers/BUILD.bazel similarity index 93% rename from enterprise/cmd/worker/internal/batches/workers/BUILD.bazel rename to cmd/worker/internal/batches/workers/BUILD.bazel index 23d75c32251..39cdbfcc4ec 100644 --- a/enterprise/cmd/worker/internal/batches/workers/BUILD.bazel +++ b/cmd/worker/internal/batches/workers/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "bulk_processor_worker.go", "reconciler_worker.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/workers", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/workers", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//internal/actor", "//internal/api", diff --git a/enterprise/cmd/worker/internal/batches/workers/batch_spec_resolution_worker.go b/cmd/worker/internal/batches/workers/batch_spec_resolution_worker.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/batch_spec_resolution_worker.go rename to cmd/worker/internal/batches/workers/batch_spec_resolution_worker.go diff --git a/enterprise/cmd/worker/internal/batches/workers/batch_spec_workspace_creator.go b/cmd/worker/internal/batches/workers/batch_spec_workspace_creator.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/batch_spec_workspace_creator.go rename to cmd/worker/internal/batches/workers/batch_spec_workspace_creator.go diff --git a/enterprise/cmd/worker/internal/batches/workers/batch_spec_workspace_creator_test.go b/cmd/worker/internal/batches/workers/batch_spec_workspace_creator_test.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/batch_spec_workspace_creator_test.go rename to cmd/worker/internal/batches/workers/batch_spec_workspace_creator_test.go diff --git a/enterprise/cmd/worker/internal/batches/workers/bulk_processor_worker.go b/cmd/worker/internal/batches/workers/bulk_processor_worker.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/bulk_processor_worker.go rename to cmd/worker/internal/batches/workers/bulk_processor_worker.go diff --git a/enterprise/cmd/worker/internal/batches/workers/reconciler_worker.go b/cmd/worker/internal/batches/workers/reconciler_worker.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/reconciler_worker.go rename to cmd/worker/internal/batches/workers/reconciler_worker.go diff --git a/enterprise/cmd/worker/internal/batches/workers/reconciler_worker_test.go b/cmd/worker/internal/batches/workers/reconciler_worker_test.go similarity index 100% rename from enterprise/cmd/worker/internal/batches/workers/reconciler_worker_test.go rename to cmd/worker/internal/batches/workers/reconciler_worker_test.go diff --git a/enterprise/cmd/worker/internal/batches/workspace_resolver_job.go b/cmd/worker/internal/batches/workspace_resolver_job.go similarity index 93% rename from enterprise/cmd/worker/internal/batches/workspace_resolver_job.go rename to cmd/worker/internal/batches/workspace_resolver_job.go index 6b1234faa8a..b91a5f63eee 100644 --- a/enterprise/cmd/worker/internal/batches/workspace_resolver_job.go +++ b/cmd/worker/internal/batches/workspace_resolver_job.go @@ -3,8 +3,8 @@ package batches import ( "context" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/cmd/worker/job" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches/workers" "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/env" "github.com/sourcegraph/sourcegraph/internal/goroutine" diff --git a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel b/cmd/worker/internal/codeintel/BUILD.bazel similarity index 85% rename from enterprise/cmd/worker/internal/codeintel/BUILD.bazel rename to cmd/worker/internal/codeintel/BUILD.bazel index edef019169f..ac02c0abb1d 100644 --- a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel +++ b/cmd/worker/internal/codeintel/BUILD.bazel @@ -18,13 +18,13 @@ go_library( "uploads_expirer.go", "uploads_janitor.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/codeintel", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/codeintel", + visibility = ["//cmd/worker:__subpackages__"], deps = [ + "//cmd/worker/internal/executorqueue", "//cmd/worker/job", "//cmd/worker/shared/init/codeintel", "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/internal/executorqueue", "//internal/codeintel/autoindexing", "//internal/codeintel/dependencies", "//internal/codeintel/policies", diff --git a/enterprise/cmd/worker/internal/codeintel/autoindexing_dependencies.go b/cmd/worker/internal/codeintel/autoindexing_dependencies.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/autoindexing_dependencies.go rename to cmd/worker/internal/codeintel/autoindexing_dependencies.go diff --git a/enterprise/cmd/worker/internal/codeintel/autoindexing_scheduler.go b/cmd/worker/internal/codeintel/autoindexing_scheduler.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/autoindexing_scheduler.go rename to cmd/worker/internal/codeintel/autoindexing_scheduler.go diff --git a/enterprise/cmd/worker/internal/codeintel/autoindexing_summary.go b/cmd/worker/internal/codeintel/autoindexing_summary.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/autoindexing_summary.go rename to cmd/worker/internal/codeintel/autoindexing_summary.go diff --git a/enterprise/cmd/worker/internal/codeintel/dependencies_crates_syncer.go b/cmd/worker/internal/codeintel/dependencies_crates_syncer.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/dependencies_crates_syncer.go rename to cmd/worker/internal/codeintel/dependencies_crates_syncer.go diff --git a/enterprise/cmd/worker/internal/codeintel/dependencies_packages.go b/cmd/worker/internal/codeintel/dependencies_packages.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/dependencies_packages.go rename to cmd/worker/internal/codeintel/dependencies_packages.go diff --git a/enterprise/cmd/worker/internal/codeintel/lsifuploadstore_expirer.go b/cmd/worker/internal/codeintel/lsifuploadstore_expirer.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/lsifuploadstore_expirer.go rename to cmd/worker/internal/codeintel/lsifuploadstore_expirer.go diff --git a/enterprise/cmd/worker/internal/codeintel/metrics_reporter.go b/cmd/worker/internal/codeintel/metrics_reporter.go similarity index 96% rename from enterprise/cmd/worker/internal/codeintel/metrics_reporter.go rename to cmd/worker/internal/codeintel/metrics_reporter.go index ca94462cea0..ce56f92a7c9 100644 --- a/enterprise/cmd/worker/internal/codeintel/metrics_reporter.go +++ b/cmd/worker/internal/codeintel/metrics_reporter.go @@ -3,9 +3,9 @@ package codeintel import ( "context" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/cmd/worker/job" "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/codeintel" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executorqueue" workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing" diff --git a/enterprise/cmd/worker/internal/codeintel/policies.go b/cmd/worker/internal/codeintel/policies.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/policies.go rename to cmd/worker/internal/codeintel/policies.go diff --git a/enterprise/cmd/worker/internal/codeintel/ranking.go b/cmd/worker/internal/codeintel/ranking.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/ranking.go rename to cmd/worker/internal/codeintel/ranking.go diff --git a/enterprise/cmd/worker/internal/codeintel/sentinel.go b/cmd/worker/internal/codeintel/sentinel.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/sentinel.go rename to cmd/worker/internal/codeintel/sentinel.go diff --git a/enterprise/cmd/worker/internal/codeintel/uploads_backfiller.go b/cmd/worker/internal/codeintel/uploads_backfiller.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/uploads_backfiller.go rename to cmd/worker/internal/codeintel/uploads_backfiller.go diff --git a/enterprise/cmd/worker/internal/codeintel/uploads_commitgraph.go b/cmd/worker/internal/codeintel/uploads_commitgraph.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/uploads_commitgraph.go rename to cmd/worker/internal/codeintel/uploads_commitgraph.go diff --git a/enterprise/cmd/worker/internal/codeintel/uploads_expirer.go b/cmd/worker/internal/codeintel/uploads_expirer.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/uploads_expirer.go rename to cmd/worker/internal/codeintel/uploads_expirer.go diff --git a/enterprise/cmd/worker/internal/codeintel/uploads_janitor.go b/cmd/worker/internal/codeintel/uploads_janitor.go similarity index 100% rename from enterprise/cmd/worker/internal/codeintel/uploads_janitor.go rename to cmd/worker/internal/codeintel/uploads_janitor.go diff --git a/enterprise/cmd/worker/internal/codemonitors/BUILD.bazel b/cmd/worker/internal/codemonitors/BUILD.bazel similarity index 68% rename from enterprise/cmd/worker/internal/codemonitors/BUILD.bazel rename to cmd/worker/internal/codemonitors/BUILD.bazel index 8238cdc9db3..07296b1d326 100644 --- a/enterprise/cmd/worker/internal/codemonitors/BUILD.bazel +++ b/cmd/worker/internal/codemonitors/BUILD.bazel @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "codemonitors", srcs = ["codemonitor_job.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/codemonitors", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/codemonitors", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", diff --git a/enterprise/cmd/worker/internal/codemonitors/codemonitor_job.go b/cmd/worker/internal/codemonitors/codemonitor_job.go similarity index 100% rename from enterprise/cmd/worker/internal/codemonitors/codemonitor_job.go rename to cmd/worker/internal/codemonitors/codemonitor_job.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel b/cmd/worker/internal/embeddings/repo/BUILD.bazel similarity index 90% rename from enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel rename to cmd/worker/internal/embeddings/repo/BUILD.bazel index 431cac1dfae..16f9cad7e6f 100644 --- a/enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel +++ b/cmd/worker/internal/embeddings/repo/BUILD.bazel @@ -10,8 +10,8 @@ go_library( "scheduler.go", "worker.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/repo", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/embeddings/repo", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/searcher/diff", "//cmd/worker/job", diff --git a/enterprise/cmd/worker/internal/embeddings/repo/document_ranks.go b/cmd/worker/internal/embeddings/repo/document_ranks.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/document_ranks.go rename to cmd/worker/internal/embeddings/repo/document_ranks.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/handler.go b/cmd/worker/internal/embeddings/repo/handler.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/handler.go rename to cmd/worker/internal/embeddings/repo/handler.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/handler_test.go b/cmd/worker/internal/embeddings/repo/handler_test.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/handler_test.go rename to cmd/worker/internal/embeddings/repo/handler_test.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/janitor.go b/cmd/worker/internal/embeddings/repo/janitor.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/janitor.go rename to cmd/worker/internal/embeddings/repo/janitor.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/scheduler.go b/cmd/worker/internal/embeddings/repo/scheduler.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/scheduler.go rename to cmd/worker/internal/embeddings/repo/scheduler.go diff --git a/enterprise/cmd/worker/internal/embeddings/repo/worker.go b/cmd/worker/internal/embeddings/repo/worker.go similarity index 100% rename from enterprise/cmd/worker/internal/embeddings/repo/worker.go rename to cmd/worker/internal/embeddings/repo/worker.go diff --git a/enterprise/cmd/worker/internal/executormultiqueue/BUILD.bazel b/cmd/worker/internal/executormultiqueue/BUILD.bazel similarity index 62% rename from enterprise/cmd/worker/internal/executormultiqueue/BUILD.bazel rename to cmd/worker/internal/executormultiqueue/BUILD.bazel index 10d40272a98..a094a11ed46 100644 --- a/enterprise/cmd/worker/internal/executormultiqueue/BUILD.bazel +++ b/cmd/worker/internal/executormultiqueue/BUILD.bazel @@ -3,13 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "executormultiqueue", srcs = ["multiqueue_metrics_reporter.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executormultiqueue", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executormultiqueue", + visibility = ["//cmd/worker:__subpackages__"], deps = [ + "//cmd/worker/internal/batches", + "//cmd/worker/internal/executorqueue", "//cmd/worker/job", "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/internal/batches", - "//enterprise/cmd/worker/internal/executorqueue", "//internal/codeintel/autoindexing", "//internal/env", "//internal/executor/types", diff --git a/enterprise/cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go b/cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go similarity index 92% rename from enterprise/cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go rename to cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go index 0bdea65a1c5..00c46edcb81 100644 --- a/enterprise/cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go +++ b/cmd/worker/internal/executormultiqueue/multiqueue_metrics_reporter.go @@ -3,10 +3,10 @@ package executormultiqueue import ( "context" + dbstore "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/cmd/worker/job" workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" - dbstore "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executorqueue" "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing" "github.com/sourcegraph/sourcegraph/internal/env" executortypes "github.com/sourcegraph/sourcegraph/internal/executor/types" diff --git a/enterprise/cmd/worker/internal/executorqueue/BUILD.bazel b/cmd/worker/internal/executorqueue/BUILD.bazel similarity index 90% rename from enterprise/cmd/worker/internal/executorqueue/BUILD.bazel rename to cmd/worker/internal/executorqueue/BUILD.bazel index aad5acc78b6..372c7375657 100644 --- a/enterprise/cmd/worker/internal/executorqueue/BUILD.bazel +++ b/cmd/worker/internal/executorqueue/BUILD.bazel @@ -12,8 +12,8 @@ go_library( "queue_allocation.go", "reporter.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executorqueue", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executorqueue", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//internal/codeintel/uploads/shared", "//internal/env", diff --git a/enterprise/cmd/worker/internal/executorqueue/CODENOTIFY b/cmd/worker/internal/executorqueue/CODENOTIFY similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/CODENOTIFY rename to cmd/worker/internal/executorqueue/CODENOTIFY diff --git a/enterprise/cmd/worker/internal/executorqueue/aws_reporter.go b/cmd/worker/internal/executorqueue/aws_reporter.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/aws_reporter.go rename to cmd/worker/internal/executorqueue/aws_reporter.go diff --git a/enterprise/cmd/worker/internal/executorqueue/config.go b/cmd/worker/internal/executorqueue/config.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/config.go rename to cmd/worker/internal/executorqueue/config.go diff --git a/enterprise/cmd/worker/internal/executorqueue/external_emitter.go b/cmd/worker/internal/executorqueue/external_emitter.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/external_emitter.go rename to cmd/worker/internal/executorqueue/external_emitter.go diff --git a/enterprise/cmd/worker/internal/executorqueue/gcp_reporter.go b/cmd/worker/internal/executorqueue/gcp_reporter.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/gcp_reporter.go rename to cmd/worker/internal/executorqueue/gcp_reporter.go diff --git a/enterprise/cmd/worker/internal/executorqueue/prometheus.go b/cmd/worker/internal/executorqueue/prometheus.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/prometheus.go rename to cmd/worker/internal/executorqueue/prometheus.go diff --git a/enterprise/cmd/worker/internal/executorqueue/queue_allocation.go b/cmd/worker/internal/executorqueue/queue_allocation.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/queue_allocation.go rename to cmd/worker/internal/executorqueue/queue_allocation.go diff --git a/enterprise/cmd/worker/internal/executorqueue/queue_allocation_test.go b/cmd/worker/internal/executorqueue/queue_allocation_test.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/queue_allocation_test.go rename to cmd/worker/internal/executorqueue/queue_allocation_test.go diff --git a/enterprise/cmd/worker/internal/executorqueue/reporter.go b/cmd/worker/internal/executorqueue/reporter.go similarity index 100% rename from enterprise/cmd/worker/internal/executorqueue/reporter.go rename to cmd/worker/internal/executorqueue/reporter.go diff --git a/enterprise/cmd/worker/internal/executors/BUILD.bazel b/cmd/worker/internal/executors/BUILD.bazel similarity index 87% rename from enterprise/cmd/worker/internal/executors/BUILD.bazel rename to cmd/worker/internal/executors/BUILD.bazel index 1bae7aeac92..e0024e52eba 100644 --- a/enterprise/cmd/worker/internal/executors/BUILD.bazel +++ b/cmd/worker/internal/executors/BUILD.bazel @@ -10,8 +10,8 @@ go_library( "metricsserver_job.go", "multiqueue_cache_cleaner.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executors", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executors", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", diff --git a/enterprise/cmd/worker/CODENOTIFY b/cmd/worker/internal/executors/CODENOTIFY similarity index 100% rename from enterprise/cmd/worker/CODENOTIFY rename to cmd/worker/internal/executors/CODENOTIFY diff --git a/enterprise/cmd/worker/internal/executors/janitor_config.go b/cmd/worker/internal/executors/janitor_config.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/janitor_config.go rename to cmd/worker/internal/executors/janitor_config.go diff --git a/enterprise/cmd/worker/internal/executors/janitor_job.go b/cmd/worker/internal/executors/janitor_job.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/janitor_job.go rename to cmd/worker/internal/executors/janitor_job.go diff --git a/enterprise/cmd/worker/internal/executors/metricsserver_config.go b/cmd/worker/internal/executors/metricsserver_config.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/metricsserver_config.go rename to cmd/worker/internal/executors/metricsserver_config.go diff --git a/enterprise/cmd/worker/internal/executors/metricsserver_job.go b/cmd/worker/internal/executors/metricsserver_job.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/metricsserver_job.go rename to cmd/worker/internal/executors/metricsserver_job.go diff --git a/enterprise/cmd/worker/internal/executors/multiqueue_cache_cleaner.go b/cmd/worker/internal/executors/multiqueue_cache_cleaner.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/multiqueue_cache_cleaner.go rename to cmd/worker/internal/executors/multiqueue_cache_cleaner.go diff --git a/enterprise/cmd/worker/internal/executors/multiqueue_cache_cleaner_test.go b/cmd/worker/internal/executors/multiqueue_cache_cleaner_test.go similarity index 100% rename from enterprise/cmd/worker/internal/executors/multiqueue_cache_cleaner_test.go rename to cmd/worker/internal/executors/multiqueue_cache_cleaner_test.go diff --git a/enterprise/cmd/worker/internal/githubapps/BUILD.bazel b/cmd/worker/internal/githubapps/BUILD.bazel similarity index 62% rename from enterprise/cmd/worker/internal/githubapps/BUILD.bazel rename to cmd/worker/internal/githubapps/BUILD.bazel index 2849171669f..f56c8f01036 100644 --- a/enterprise/cmd/worker/internal/githubapps/BUILD.bazel +++ b/cmd/worker/internal/githubapps/BUILD.bazel @@ -3,12 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "githubapps", srcs = ["job.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/githubapps", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/githubapps", + visibility = ["//cmd/worker:__subpackages__"], deps = [ + "//cmd/worker/internal/githubapps/worker", "//cmd/worker/job", "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/internal/githubapps/worker", "//internal/env", "//internal/goroutine", "//internal/observation", diff --git a/enterprise/cmd/worker/internal/githubapps/job.go b/cmd/worker/internal/githubapps/job.go similarity index 94% rename from enterprise/cmd/worker/internal/githubapps/job.go rename to cmd/worker/internal/githubapps/job.go index 0686e8fc83f..45d75288086 100644 --- a/enterprise/cmd/worker/internal/githubapps/job.go +++ b/cmd/worker/internal/githubapps/job.go @@ -6,9 +6,9 @@ import ( "github.com/sourcegraph/log" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/githubapps/worker" "github.com/sourcegraph/sourcegraph/cmd/worker/job" workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/githubapps/worker" "github.com/sourcegraph/sourcegraph/internal/env" "github.com/sourcegraph/sourcegraph/internal/goroutine" "github.com/sourcegraph/sourcegraph/internal/observation" diff --git a/enterprise/cmd/worker/internal/githubapps/worker/BUILD.bazel b/cmd/worker/internal/githubapps/worker/BUILD.bazel similarity index 85% rename from enterprise/cmd/worker/internal/githubapps/worker/BUILD.bazel rename to cmd/worker/internal/githubapps/worker/BUILD.bazel index f3f56f37a15..79246424b17 100644 --- a/enterprise/cmd/worker/internal/githubapps/worker/BUILD.bazel +++ b/cmd/worker/internal/githubapps/worker/BUILD.bazel @@ -4,8 +4,8 @@ load("//dev:go_defs.bzl", "go_test") go_library( name = "worker", srcs = ["installation_backfill.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/githubapps/worker", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/githubapps/worker", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//internal/database", "//internal/extsvc/github", diff --git a/enterprise/cmd/worker/internal/githubapps/worker/installation_backfill.go b/cmd/worker/internal/githubapps/worker/installation_backfill.go similarity index 100% rename from enterprise/cmd/worker/internal/githubapps/worker/installation_backfill.go rename to cmd/worker/internal/githubapps/worker/installation_backfill.go diff --git a/enterprise/cmd/worker/internal/githubapps/worker/installation_backfill_test.go b/cmd/worker/internal/githubapps/worker/installation_backfill_test.go similarity index 100% rename from enterprise/cmd/worker/internal/githubapps/worker/installation_backfill_test.go rename to cmd/worker/internal/githubapps/worker/installation_backfill_test.go diff --git a/enterprise/cmd/worker/internal/insights/BUILD.bazel b/cmd/worker/internal/insights/BUILD.bazel similarity index 75% rename from enterprise/cmd/worker/internal/insights/BUILD.bazel rename to cmd/worker/internal/insights/BUILD.bazel index 0c2980e0174..fd8a29f5c27 100644 --- a/enterprise/cmd/worker/internal/insights/BUILD.bazel +++ b/cmd/worker/internal/insights/BUILD.bazel @@ -7,8 +7,8 @@ go_library( "job.go", "query_runner_job.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/insights", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/insights", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", diff --git a/enterprise/cmd/worker/internal/insights/data_retention_job.go b/cmd/worker/internal/insights/data_retention_job.go similarity index 100% rename from enterprise/cmd/worker/internal/insights/data_retention_job.go rename to cmd/worker/internal/insights/data_retention_job.go diff --git a/enterprise/cmd/worker/internal/insights/job.go b/cmd/worker/internal/insights/job.go similarity index 100% rename from enterprise/cmd/worker/internal/insights/job.go rename to cmd/worker/internal/insights/job.go diff --git a/enterprise/cmd/worker/internal/insights/query_runner_job.go b/cmd/worker/internal/insights/query_runner_job.go similarity index 100% rename from enterprise/cmd/worker/internal/insights/query_runner_job.go rename to cmd/worker/internal/insights/query_runner_job.go diff --git a/enterprise/cmd/worker/internal/own/BUILD.bazel b/cmd/worker/internal/own/BUILD.bazel similarity index 68% rename from enterprise/cmd/worker/internal/own/BUILD.bazel rename to cmd/worker/internal/own/BUILD.bazel index 272abffe352..0314f7c5a4a 100644 --- a/enterprise/cmd/worker/internal/own/BUILD.bazel +++ b/cmd/worker/internal/own/BUILD.bazel @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "own", srcs = ["job.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/own", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/own", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", diff --git a/enterprise/cmd/worker/internal/own/job.go b/cmd/worker/internal/own/job.go similarity index 100% rename from enterprise/cmd/worker/internal/own/job.go rename to cmd/worker/internal/own/job.go diff --git a/enterprise/cmd/worker/internal/permissions/BUILD.bazel b/cmd/worker/internal/permissions/BUILD.bazel similarity index 93% rename from enterprise/cmd/worker/internal/permissions/BUILD.bazel rename to cmd/worker/internal/permissions/BUILD.bazel index 5e2659e53bc..ace2cd2af25 100644 --- a/enterprise/cmd/worker/internal/permissions/BUILD.bazel +++ b/cmd/worker/internal/permissions/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "perms_syncer_cleaner.go", "perms_syncer_scheduler.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/permissions", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/permissions", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/frontend/globals", "//cmd/worker/job", diff --git a/enterprise/cmd/worker/internal/permissions/bitbucket_projects.go b/cmd/worker/internal/permissions/bitbucket_projects.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/bitbucket_projects.go rename to cmd/worker/internal/permissions/bitbucket_projects.go diff --git a/enterprise/cmd/worker/internal/permissions/bitbucket_projects_test.go b/cmd/worker/internal/permissions/bitbucket_projects_test.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/bitbucket_projects_test.go rename to cmd/worker/internal/permissions/bitbucket_projects_test.go diff --git a/enterprise/cmd/worker/internal/permissions/config.go b/cmd/worker/internal/permissions/config.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/config.go rename to cmd/worker/internal/permissions/config.go diff --git a/enterprise/cmd/worker/internal/permissions/main_test.go b/cmd/worker/internal/permissions/main_test.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/main_test.go rename to cmd/worker/internal/permissions/main_test.go diff --git a/enterprise/cmd/worker/internal/permissions/perms_syncer_cleaner.go b/cmd/worker/internal/permissions/perms_syncer_cleaner.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/perms_syncer_cleaner.go rename to cmd/worker/internal/permissions/perms_syncer_cleaner.go diff --git a/enterprise/cmd/worker/internal/permissions/perms_syncer_cleaner_test.go b/cmd/worker/internal/permissions/perms_syncer_cleaner_test.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/perms_syncer_cleaner_test.go rename to cmd/worker/internal/permissions/perms_syncer_cleaner_test.go diff --git a/enterprise/cmd/worker/internal/permissions/perms_syncer_scheduler.go b/cmd/worker/internal/permissions/perms_syncer_scheduler.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/perms_syncer_scheduler.go rename to cmd/worker/internal/permissions/perms_syncer_scheduler.go diff --git a/enterprise/cmd/worker/internal/permissions/perms_syncer_scheduler_test.go b/cmd/worker/internal/permissions/perms_syncer_scheduler_test.go similarity index 100% rename from enterprise/cmd/worker/internal/permissions/perms_syncer_scheduler_test.go rename to cmd/worker/internal/permissions/perms_syncer_scheduler_test.go diff --git a/enterprise/cmd/worker/internal/permissions/testdata/vcr/client.yaml b/cmd/worker/internal/permissions/testdata/vcr/client.yaml similarity index 100% rename from enterprise/cmd/worker/internal/permissions/testdata/vcr/client.yaml rename to cmd/worker/internal/permissions/testdata/vcr/client.yaml diff --git a/enterprise/cmd/worker/internal/search/BUILD.bazel b/cmd/worker/internal/search/BUILD.bazel similarity index 91% rename from enterprise/cmd/worker/internal/search/BUILD.bazel rename to cmd/worker/internal/search/BUILD.bazel index 189f73327b0..97e6f95cd77 100644 --- a/enterprise/cmd/worker/internal/search/BUILD.bazel +++ b/cmd/worker/internal/search/BUILD.bazel @@ -9,8 +9,8 @@ go_library( "exhaustive_search_repo_revision.go", "job.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/search", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/search", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/job", "//cmd/worker/shared/init/db", diff --git a/enterprise/cmd/worker/internal/search/exhaustive_search.go b/cmd/worker/internal/search/exhaustive_search.go similarity index 100% rename from enterprise/cmd/worker/internal/search/exhaustive_search.go rename to cmd/worker/internal/search/exhaustive_search.go diff --git a/enterprise/cmd/worker/internal/search/exhaustive_search_repo.go b/cmd/worker/internal/search/exhaustive_search_repo.go similarity index 100% rename from enterprise/cmd/worker/internal/search/exhaustive_search_repo.go rename to cmd/worker/internal/search/exhaustive_search_repo.go diff --git a/enterprise/cmd/worker/internal/search/exhaustive_search_repo_revision.go b/cmd/worker/internal/search/exhaustive_search_repo_revision.go similarity index 100% rename from enterprise/cmd/worker/internal/search/exhaustive_search_repo_revision.go rename to cmd/worker/internal/search/exhaustive_search_repo_revision.go diff --git a/enterprise/cmd/worker/internal/search/exhaustive_search_test.go b/cmd/worker/internal/search/exhaustive_search_test.go similarity index 100% rename from enterprise/cmd/worker/internal/search/exhaustive_search_test.go rename to cmd/worker/internal/search/exhaustive_search_test.go diff --git a/enterprise/cmd/worker/internal/search/job.go b/cmd/worker/internal/search/job.go similarity index 100% rename from enterprise/cmd/worker/internal/search/job.go rename to cmd/worker/internal/search/job.go diff --git a/enterprise/cmd/worker/internal/telemetry/BUILD.bazel b/cmd/worker/internal/telemetry/BUILD.bazel similarity index 91% rename from enterprise/cmd/worker/internal/telemetry/BUILD.bazel rename to cmd/worker/internal/telemetry/BUILD.bazel index 13fa3300180..d18aea9a511 100644 --- a/enterprise/cmd/worker/internal/telemetry/BUILD.bazel +++ b/cmd/worker/internal/telemetry/BUILD.bazel @@ -4,8 +4,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "telemetry", srcs = ["telemetry_job.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetry", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetry", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/shared/init/db", "//internal/conf", diff --git a/enterprise/cmd/worker/internal/telemetry/mocks_test.go b/cmd/worker/internal/telemetry/mocks_test.go similarity index 97% rename from enterprise/cmd/worker/internal/telemetry/mocks_test.go rename to cmd/worker/internal/telemetry/mocks_test.go index 6e5591a7f9a..b8148e3b33d 100644 --- a/enterprise/cmd/worker/internal/telemetry/mocks_test.go +++ b/cmd/worker/internal/telemetry/mocks_test.go @@ -13,8 +13,8 @@ import ( // MockBookmarkStore is a mock implementation of the bookmarkStore interface // (from the package -// github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetry) -// used for unit testing. +// github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetry) used +// for unit testing. type MockBookmarkStore struct { // GetBookmarkFunc is an instance of a mock function object controlling // the behavior of the method GetBookmark. @@ -60,8 +60,8 @@ func NewStrictMockBookmarkStore() *MockBookmarkStore { // surrogateMockBookmarkStore is a copy of the bookmarkStore interface (from // the package -// github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetry). -// It is redefined here as it is unexported in the source package. +// github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetry). It is +// redefined here as it is unexported in the source package. type surrogateMockBookmarkStore interface { GetBookmark(context.Context) (int, error) UpdateBookmark(context.Context, int) error diff --git a/enterprise/cmd/worker/internal/telemetry/telemetry_job.go b/cmd/worker/internal/telemetry/telemetry_job.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetry/telemetry_job.go rename to cmd/worker/internal/telemetry/telemetry_job.go diff --git a/enterprise/cmd/worker/internal/telemetry/telemetry_job_test.go b/cmd/worker/internal/telemetry/telemetry_job_test.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetry/telemetry_job_test.go rename to cmd/worker/internal/telemetry/telemetry_job_test.go diff --git a/enterprise/cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel b/cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel similarity index 81% rename from enterprise/cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel rename to cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel index 78676907d92..9afb16b8f89 100644 --- a/enterprise/cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel +++ b/cmd/worker/internal/telemetrygatewayexporter/BUILD.bazel @@ -8,8 +8,8 @@ go_library( "queue_metrics.go", "telemetrygatewayexporter.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetrygatewayexporter", - visibility = ["//enterprise/cmd/worker:__subpackages__"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetrygatewayexporter", + visibility = ["//cmd/worker:__subpackages__"], deps = [ "//cmd/worker/shared/init/db", "//internal/conf", diff --git a/enterprise/cmd/worker/internal/telemetrygatewayexporter/exporter.go b/cmd/worker/internal/telemetrygatewayexporter/exporter.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetrygatewayexporter/exporter.go rename to cmd/worker/internal/telemetrygatewayexporter/exporter.go diff --git a/enterprise/cmd/worker/internal/telemetrygatewayexporter/queue_cleanup.go b/cmd/worker/internal/telemetrygatewayexporter/queue_cleanup.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetrygatewayexporter/queue_cleanup.go rename to cmd/worker/internal/telemetrygatewayexporter/queue_cleanup.go diff --git a/enterprise/cmd/worker/internal/telemetrygatewayexporter/queue_metrics.go b/cmd/worker/internal/telemetrygatewayexporter/queue_metrics.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetrygatewayexporter/queue_metrics.go rename to cmd/worker/internal/telemetrygatewayexporter/queue_metrics.go diff --git a/enterprise/cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go b/cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go similarity index 100% rename from enterprise/cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go rename to cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go diff --git a/cmd/worker/shared/BUILD.bazel b/cmd/worker/shared/BUILD.bazel index c05b640ade1..695cdd63ebc 100644 --- a/cmd/worker/shared/BUILD.bazel +++ b/cmd/worker/shared/BUILD.bazel @@ -10,22 +10,43 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/shared", visibility = ["//visibility:public"], deps = [ + "//cmd/frontend/globals", + "//cmd/worker/internal/auth", + "//cmd/worker/internal/batches", + "//cmd/worker/internal/codeintel", + "//cmd/worker/internal/codemonitors", "//cmd/worker/internal/codygateway", + "//cmd/worker/internal/embeddings/repo", "//cmd/worker/internal/encryption", + "//cmd/worker/internal/executormultiqueue", + "//cmd/worker/internal/executors", + "//cmd/worker/internal/githubapps", "//cmd/worker/internal/gitserver", + "//cmd/worker/internal/insights", "//cmd/worker/internal/licensecheck", "//cmd/worker/internal/migrations", "//cmd/worker/internal/outboundwebhooks", + "//cmd/worker/internal/own", + "//cmd/worker/internal/permissions", "//cmd/worker/internal/ratelimit", "//cmd/worker/internal/repostatistics", + "//cmd/worker/internal/search", + "//cmd/worker/internal/telemetry", + "//cmd/worker/internal/telemetrygatewayexporter", "//cmd/worker/internal/webhooks", "//cmd/worker/internal/zoektrepos", "//cmd/worker/job", "//cmd/worker/shared/init/db", + "//internal/auth/userpasswd", + "//internal/authz", + "//internal/authz/providers", + "//internal/authz/subrepoperms", + "//internal/conf", "//internal/database", "//internal/debugserver", "//internal/encryption/keyring", "//internal/env", + "//internal/extsvc/versions", "//internal/goroutine", "//internal/goroutine/recorder", "//internal/httpserver", @@ -36,5 +57,6 @@ go_library( "//internal/symbols", "//lib/errors", "@com_github_prometheus_client_golang//prometheus", + "@com_github_sourcegraph_log//:log", ], ) diff --git a/cmd/worker/shared/main.go b/cmd/worker/shared/main.go index be44d87f9b3..69e4c8a8038 100644 --- a/cmd/worker/shared/main.go +++ b/cmd/worker/shared/main.go @@ -10,25 +10,45 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "github.com/sourcegraph/log" - "github.com/sourcegraph/sourcegraph/internal/env" - "github.com/sourcegraph/sourcegraph/internal/goroutine/recorder" - + "github.com/sourcegraph/sourcegraph/cmd/frontend/globals" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/auth" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/batches" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/codeintel" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/codemonitors" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/codygateway" + repoembeddings "github.com/sourcegraph/sourcegraph/cmd/worker/internal/embeddings/repo" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/encryption" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executormultiqueue" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/executors" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/githubapps" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/gitserver" + workerinsights "github.com/sourcegraph/sourcegraph/cmd/worker/internal/insights" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/licensecheck" workermigrations "github.com/sourcegraph/sourcegraph/cmd/worker/internal/migrations" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/outboundwebhooks" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/own" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/permissions" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/ratelimit" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/repostatistics" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/search" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetry" + "github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetrygatewayexporter" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/webhooks" "github.com/sourcegraph/sourcegraph/cmd/worker/internal/zoektrepos" workerjob "github.com/sourcegraph/sourcegraph/cmd/worker/job" workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" + "github.com/sourcegraph/sourcegraph/internal/authz" + "github.com/sourcegraph/sourcegraph/internal/authz/providers" + srp "github.com/sourcegraph/sourcegraph/internal/authz/subrepoperms" + "github.com/sourcegraph/sourcegraph/internal/conf" "github.com/sourcegraph/sourcegraph/internal/database" "github.com/sourcegraph/sourcegraph/internal/encryption/keyring" + "github.com/sourcegraph/sourcegraph/internal/env" + "github.com/sourcegraph/sourcegraph/internal/extsvc/versions" "github.com/sourcegraph/sourcegraph/internal/goroutine" + "github.com/sourcegraph/sourcegraph/internal/goroutine/recorder" "github.com/sourcegraph/sourcegraph/internal/httpserver" "github.com/sourcegraph/sourcegraph/internal/observation" "github.com/sourcegraph/sourcegraph/internal/oobmigration" @@ -47,22 +67,67 @@ type namedBackgroundRoutine struct { JobName string } -func LoadConfig(additionalJobs map[string]workerjob.Job, registerEnterpriseMigrators oobmigration.RegisterMigratorsFunc) *Config { +func LoadConfig(registerEnterpriseMigrators oobmigration.RegisterMigratorsFunc) *Config { symbols.LoadConfig() registerMigrators := oobmigration.ComposeRegisterMigratorsFuncs(register.RegisterOSSMigrators, registerEnterpriseMigrators) builtins := map[string]workerjob.Job{ - "webhook-log-janitor": webhooks.NewJanitor(), - "out-of-band-migrations": workermigrations.NewMigrator(registerMigrators), - "gitserver-metrics": gitserver.NewMetricsJob(), - "record-encrypter": encryption.NewRecordEncrypterJob(), - "repo-statistics-compactor": repostatistics.NewCompactor(), - "zoekt-repos-updater": zoektrepos.NewUpdater(), - "outbound-webhook-sender": outboundwebhooks.NewSender(), - "license-check": licensecheck.NewJob(), - "cody-gateway-usage-check": codygateway.NewUsageJob(), - "rate-limit-config": ratelimit.NewRateLimitConfigJob(), + "webhook-log-janitor": webhooks.NewJanitor(), + "out-of-band-migrations": workermigrations.NewMigrator(registerMigrators), + "gitserver-metrics": gitserver.NewMetricsJob(), + "record-encrypter": encryption.NewRecordEncrypterJob(), + "repo-statistics-compactor": repostatistics.NewCompactor(), + "zoekt-repos-updater": zoektrepos.NewUpdater(), + "outbound-webhook-sender": outboundwebhooks.NewSender(), + "license-check": licensecheck.NewJob(), + "cody-gateway-usage-check": codygateway.NewUsageJob(), + "rate-limit-config": ratelimit.NewRateLimitConfigJob(), + "codehost-version-syncing": versions.NewSyncingJob(), + "insights-job": workerinsights.NewInsightsJob(), + "insights-query-runner-job": workerinsights.NewInsightsQueryRunnerJob(), + "insights-data-retention-job": workerinsights.NewInsightsDataRetentionJob(), + "batches-janitor": batches.NewJanitorJob(), + "batches-scheduler": batches.NewSchedulerJob(), + "batches-reconciler": batches.NewReconcilerJob(), + "batches-bulk-processor": batches.NewBulkOperationProcessorJob(), + "batches-workspace-resolver": batches.NewWorkspaceResolverJob(), + "executors-janitor": executors.NewJanitorJob(), + "executors-metricsserver": executors.NewMetricsServerJob(), + "executors-multiqueue-metrics-reporter": executormultiqueue.NewMultiqueueMetricsReporterJob(), + "codemonitors-job": codemonitors.NewCodeMonitorJob(), + "bitbucket-project-permissions": permissions.NewBitbucketProjectPermissionsJob(), + "permission-sync-job-cleaner": permissions.NewPermissionSyncJobCleaner(), + "permission-sync-job-scheduler": permissions.NewPermissionSyncJobScheduler(), + "export-usage-telemetry": telemetry.NewTelemetryJob(), + "telemetrygateway-exporter": telemetrygatewayexporter.NewJob(), + + "codeintel-policies-repository-matcher": codeintel.NewPoliciesRepositoryMatcherJob(), + "codeintel-autoindexing-summary-builder": codeintel.NewAutoindexingSummaryBuilder(), + "codeintel-autoindexing-dependency-scheduler": codeintel.NewAutoindexingDependencySchedulerJob(), + "codeintel-autoindexing-scheduler": codeintel.NewAutoindexingSchedulerJob(), + "codeintel-commitgraph-updater": codeintel.NewCommitGraphUpdaterJob(), + "codeintel-metrics-reporter": codeintel.NewMetricsReporterJob(), + "codeintel-upload-backfiller": codeintel.NewUploadBackfillerJob(), + "codeintel-upload-expirer": codeintel.NewUploadExpirerJob(), + "codeintel-upload-janitor": codeintel.NewUploadJanitorJob(), + "codeintel-ranking-file-reference-counter": codeintel.NewRankingFileReferenceCounter(), + "codeintel-uploadstore-expirer": codeintel.NewPreciseCodeIntelUploadExpirer(), + "codeintel-crates-syncer": codeintel.NewCratesSyncerJob(), + "codeintel-sentinel-cve-scanner": codeintel.NewSentinelCVEScannerJob(), + "codeintel-package-filter-applicator": codeintel.NewPackagesFilterApplicatorJob(), + + "auth-sourcegraph-operator-cleaner": auth.NewSourcegraphOperatorCleaner(), + + "repo-embedding-janitor": repoembeddings.NewRepoEmbeddingJanitorJob(), + "repo-embedding-job": repoembeddings.NewRepoEmbeddingJob(), + "repo-embedding-scheduler": repoembeddings.NewRepoEmbeddingSchedulerJob(), + + "own-repo-indexing-queue": own.NewOwnRepoIndexingQueue(), + + "github-apps-installation-validation-job": githubapps.NewGitHubApsInstallationJob(), + + "exhaustive-search-job": search.NewSearchJob(), } var config Config @@ -71,9 +136,6 @@ func LoadConfig(additionalJobs map[string]workerjob.Job, registerEnterpriseMigra for name, job := range builtins { config.Jobs[name] = job } - for name, job := range additionalJobs { - config.Jobs[name] = job - } // Setup environment variables loadConfigs(config.Jobs) @@ -316,3 +378,34 @@ func jobNames(jobs map[string]workerjob.Job) []string { return names } + +// SetAuthzProviders waits for the database to be initialized, then periodically refreshes the +// global authz providers. This changes the repositories that are visible for reads based on the +// current actor stored in an operation's context, which is likely an internal actor for many of +// the jobs configured in this service. This also enables repository update operations to fetch +// permissions from code hosts. +func setAuthzProviders(ctx context.Context, observationCtx *observation.Context) { + observationCtx = observation.ContextWithLogger(observationCtx.Logger.Scoped("authz-provider", ""), observationCtx) + db, err := workerdb.InitDB(observationCtx) + if err != nil { + return + } + + // authz also relies on UserMappings being setup. + globals.WatchPermissionsUserMapping() + + for range time.NewTicker(providers.RefreshInterval()).C { + allowAccessByDefault, authzProviders, _, _, _ := providers.ProvidersFromConfig(ctx, conf.Get(), db.ExternalServices(), db) + authz.SetProviders(allowAccessByDefault, authzProviders) + } +} + +func getEnterpriseInit(logger log.Logger) func(database.DB) { + return func(db database.DB) { + var err error + authz.DefaultSubRepoPermsChecker, err = srp.NewSubRepoPermsClient(db.SubRepoPerms()) + if err != nil { + logger.Fatal("Failed to create sub-repo client", log.Error(err)) + } + } +} diff --git a/cmd/worker/shared/service.go b/cmd/worker/shared/service.go index c26e4031113..0b8fc44ddb8 100644 --- a/cmd/worker/shared/service.go +++ b/cmd/worker/shared/service.go @@ -3,9 +3,11 @@ package shared import ( "context" + "github.com/sourcegraph/sourcegraph/internal/auth/userpasswd" "github.com/sourcegraph/sourcegraph/internal/debugserver" "github.com/sourcegraph/sourcegraph/internal/env" "github.com/sourcegraph/sourcegraph/internal/observation" + "github.com/sourcegraph/sourcegraph/internal/oobmigration/migrations/register" "github.com/sourcegraph/sourcegraph/internal/service" ) @@ -14,11 +16,17 @@ type svc struct{} func (svc) Name() string { return "worker" } func (svc) Configure() (env.Config, []debugserver.Endpoint) { - return LoadConfig(nil, nil), nil + return LoadConfig(register.RegisterEnterpriseMigrators), nil } func (svc) Start(ctx context.Context, observationCtx *observation.Context, ready service.ReadyFunc, config env.Config) error { - return Start(ctx, observationCtx, ready, config.(*Config), nil) + go setAuthzProviders(ctx, observationCtx) + + // internal/auth/providers.{GetProviderByConfigID,GetProviderbyServiceType} are potentially in the call-graph in worker, + // so we init the built-in auth provider just in case. + userpasswd.Init() + + return Start(ctx, observationCtx, ready, config.(*Config), getEnterpriseInit(observationCtx.Logger)) } var Service service.Service = svc{} diff --git a/enterprise/cmd/worker/shared/sourcegraphoperator/BUILD.bazel b/cmd/worker/shared/sourcegraphoperator/BUILD.bazel similarity index 79% rename from enterprise/cmd/worker/shared/sourcegraphoperator/BUILD.bazel rename to cmd/worker/shared/sourcegraphoperator/BUILD.bazel index 075a6af7264..06287c6e226 100644 --- a/enterprise/cmd/worker/shared/sourcegraphoperator/BUILD.bazel +++ b/cmd/worker/shared/sourcegraphoperator/BUILD.bazel @@ -6,7 +6,7 @@ go_library( "account.go", "associate.go", ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared/sourcegraphoperator", + importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/shared/sourcegraphoperator", visibility = ["//visibility:public"], deps = [ "//internal/auth", diff --git a/enterprise/cmd/worker/shared/sourcegraphoperator/account.go b/cmd/worker/shared/sourcegraphoperator/account.go similarity index 100% rename from enterprise/cmd/worker/shared/sourcegraphoperator/account.go rename to cmd/worker/shared/sourcegraphoperator/account.go diff --git a/enterprise/cmd/worker/shared/sourcegraphoperator/associate.go b/cmd/worker/shared/sourcegraphoperator/associate.go similarity index 100% rename from enterprise/cmd/worker/shared/sourcegraphoperator/associate.go rename to cmd/worker/shared/sourcegraphoperator/associate.go diff --git a/dev/check/go-dbconn-import.sh b/dev/check/go-dbconn-import.sh index efc37d99bf9..6e6ba9f252e 100755 --- a/dev/check/go-dbconn-import.sh +++ b/dev/check/go-dbconn-import.sh @@ -16,7 +16,6 @@ allowed_prefix=( github.com/sourcegraph/sourcegraph/cmd/worker github.com/sourcegraph/sourcegraph/cmd/repo-updater github.com/sourcegraph/sourcegraph/cmd/migrator - github.com/sourcegraph/sourcegraph/enterprise/cmd/worker github.com/sourcegraph/sourcegraph/enterprise/cmd/migrator github.com/sourcegraph/sourcegraph/cmd/precise-code-intel-worker github.com/sourcegraph/sourcegraph/enterprise/cmd/symbols diff --git a/doc/code_navigation/explanations/uploads.md b/doc/code_navigation/explanations/uploads.md index f1461d6d0ac..292902f22c4 100644 --- a/doc/code_navigation/explanations/uploads.md +++ b/doc/code_navigation/explanations/uploads.md @@ -29,7 +29,7 @@ Processing of a code graph index file may occur due to malformed input or due to At any point, the upload record may be deleted. This can happen because the record is being replaced by a newer upload, due to [age of the upload record](../how-to/configure_data_retention.md), or due to explicit deletion by the user. Deleting a record that could be used to resolve to code navigation queries will first move into the `DELETING` state. Moving temporarily into this state allows Sourcegraph to smoothly transition the set of code graph uploads that are visible for query resolution. -Changing the state of an upload to or from the `COMPLETED` state requires that the [repository commit graph](#repository-commit-graph) be [updated](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Eenterprise/cmd/worker/internal/codeintel/uploads/internal/commitgraph/updater%5C.go+func+%28u+*Updater%29+update%28ctx&patternType=literal). This process can be computationally expensive for the worker service and/or postgres database. +Changing the state of an upload to or from the `COMPLETED` state requires that the [repository commit graph](#repository-commit-graph) be [updated](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%cmd/worker/internal/codeintel/uploads/internal/commitgraph/updater%5C.go+func+%28u+*Updater%29+update%28ctx&patternType=literal). This process can be computationally expensive for the worker service and/or postgres database. ## Lifecycle of an upload (via UI) After successful upload of an index file, the Sourcegraph CLI will display a URL on the target instance that shows the progress of that upload. diff --git a/doc/dev/background-information/architecture/architecture.dot b/doc/dev/background-information/architecture/architecture.dot index 0d39b1efbed..74b7d6dd873 100644 --- a/doc/dev/background-information/architecture/architecture.dot +++ b/doc/dev/background-information/architecture/architecture.dot @@ -68,7 +68,7 @@ digraph architecture { worker [ label="worker" fillcolor="#22ffff" - URL="https://github.com/sourcegraph/sourcegraph/tree/main/enterprise/cmd/worker" + URL="https://github.com/sourcegraph/sourcegraph/tree/main/cmd/worker" ] subgraph cluster_search { diff --git a/doc/dev/background-information/architecture/architecture.svg b/doc/dev/background-information/architecture/architecture.svg index 9de5ee8a48f..1f66e9833e6 100644 --- a/doc/dev/background-information/architecture/architecture.svg +++ b/doc/dev/background-information/architecture/architecture.svg @@ -297,7 +297,7 @@ worker - + worker diff --git a/doc/dev/background-information/bazel/containers.md b/doc/dev/background-information/bazel/containers.md index 0c58e425fd9..bf49ac98b60 100644 --- a/doc/dev/background-information/bazel/containers.md +++ b/doc/dev/background-information/bazel/containers.md @@ -148,13 +148,13 @@ Example: ``` # Create a tarball that can be loaded in Docker of the worker service: -bazel build //enterprise/cmd/worker:image_tarball --config darwin-docker +bazel build //cmd/worker:image_tarball --config darwin-docker # Load the image in Docker: -docker load --input $(bazel cquery //enterprise/cmd/worker:image_tarball --config darwin-docker --output=files) +docker load --input $(bazel cquery //cmd/worker:image_tarball --config darwin-docker --output=files) # Run the container structure tests -bazel test //enterprise/cmd/worker:image_test --config darwin-docker +bazel test //cmd/worker:image_test --config darwin-docker ``` Finally, _if and only if_ we want our image to be released on registries, we need to add the `oci_push` rule. It will take care of definining which registry to push on, as well as tagging the image, through a process referred as `stamping` that we will cover a bit further. diff --git a/doc/dev/background-information/bazel/index.md b/doc/dev/background-information/bazel/index.md index d475146462b..81714b1ee92 100644 --- a/doc/dev/background-information/bazel/index.md +++ b/doc/dev/background-information/bazel/index.md @@ -91,7 +91,7 @@ Finally, let's say we have defined in our Bazel project some third party depende - `bazel query //[pkg] --output location` prints where the buildfile for `pkg` is. - ex: `bazel query @com_github_cloudflare_circl//dh/x448 --output location` which allows to inspect the autogenerated buildfile. - `bazel query "allpaths(pkg1, pkg2)"` list all knowns connections from `pkg1` to `pkg2` - - ex `bazel query "allpaths(//enterprise/cmd/worker, @go_googleapis//google/api)"` + - ex `bazel query "allpaths(//cmd/worker, @go_googleapis//google/api)"` - This is very useful when you want to understand what connects a given package to another. #### Running bazel built services locally with `sg start` diff --git a/doc/dev/background-information/codeintel/index.md b/doc/dev/background-information/codeintel/index.md index 0d675227df8..022ab463464 100644 --- a/doc/dev/background-information/codeintel/index.md +++ b/doc/dev/background-information/codeintel/index.md @@ -11,7 +11,7 @@ Code navigation-specific code: - [lib/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/lib/codeintel) - [dev/codeintel-qa](https://github.com/sourcegraph/sourcegraph/tree/main/dev/codeintel-qa) - [enterprise/internal/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/enterprise/internal/codeintel) -- [enterprise/cmd/worker/internal/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/enterprise/cmd/worker/internal/codeintel) +- [cmd/worker/internal/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/cmd/worker/internal/codeintel) - [cmd/frontend/internal/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/cmd/frontend/internal/codeintel) - [cmd/frontend/internal/executorqueue/queues/codeintel](https://github.com/sourcegraph/sourcegraph/tree/main/cmd/frontend/internal/executorqueue/queues/codeintel) diff --git a/doc/dev/background-information/data-usage-pipeline.md b/doc/dev/background-information/data-usage-pipeline.md index a7061335f08..4f447436303 100644 --- a/doc/dev/background-information/data-usage-pipeline.md +++ b/doc/dev/background-information/data-usage-pipeline.md @@ -10,14 +10,14 @@ to certain managed instances (cloud) where the customer has signed a correspondi This process is a background job that can be enabled that will periodically scrape the `event_logs` table in the primary database and send it to Sourcegraph centralized analytics. [Events](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:internal/database/event_logs.go+Event+type:symbol+select:symbol.struct&patternType=standard) stored in `event_logs` are product events performed by users or the system. More information can be found in [RFC 719: Managed Instance Telemetry](https://docs.google.com/document/d/1N9aO0uTlvwXI7FzdPjIUCn_d1tRkJUfsc0urWigRf6s/edit). -The [job interval](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Eenterprise/cmd/worker/internal/telemetry/telemetry_job%5C.go+JobCooldownDuration&patternType=standard) determines how often the job is executed. The [batch size option](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Eenterprise/cmd/worker/internal/telemetry/telemetry_job%5C.go+getBatchSize+type:symbol&patternType=standard) determines how many records can be pulled in a single scrape. The batch size has a [default value](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%5Eenterprise/cmd/worker/internal/telemetry/telemetry_job%5C.go+MaxEventsCountDefault&patternType=standard) and can be overridden with a site setting: +The [job interval](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%cmd/worker/internal/telemetry/telemetry_job%5C.go+JobCooldownDuration&patternType=standard) determines how often the job is executed. The [batch size option](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%cmd/worker/internal/telemetry/telemetry_job%5C.go+getBatchSize+type:symbol&patternType=standard) determines how many records can be pulled in a single scrape. The batch size has a [default value](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24+file:%cmd/worker/internal/telemetry/telemetry_job%5C.go+MaxEventsCountDefault&patternType=standard) and can be overridden with a site setting: ``` json "exportUsageTelemetry": { "batchSize": 100, } ``` -The scraping job maintains state using a bookmark stored in the primary postgres database in the table `event_logs_scrape_state`. [If the bookmark is not found, one will be inserted](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/enterprise/cmd/worker/internal/telemetry/telemetry_job.go?L424-440) such that the bookmark is the most recent event at the time. +The scraping job maintains state using a bookmark stored in the primary postgres database in the table `event_logs_scrape_state`. [If the bookmark is not found, one will be inserted](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/cmd/worker/internal/telemetry/telemetry_job.go?L424-440) such that the bookmark is the most recent event at the time. The scraping process has a crude at-least once semantics guarantee. If any scrape should fail, the bookmark state will not be updated causing future scrapes to retry the same set of events. diff --git a/doc/dev/background-information/telemetry/architecture.md b/doc/dev/background-information/telemetry/architecture.md index dac084fdf0e..d08c05aaf1e 100644 --- a/doc/dev/background-information/telemetry/architecture.md +++ b/doc/dev/background-information/telemetry/architecture.md @@ -24,7 +24,7 @@ Note that before events are stored into `telemetry_events_export_queue`, [sensit ## Exporting events -The [`telemetrygatewayexporter`](https://github.com/sourcegraph/sourcegraph/blob/main/enterprise/cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go) running in the worker service spawns a set of background jobs that handle: +The [`telemetrygatewayexporter`](https://github.com/sourcegraph/sourcegraph/blob/main/cmd/worker/internal/telemetrygatewayexporter/telemetrygatewayexporter.go) running in the worker service spawns a set of background jobs that handle: 1. Reporting metrics on the `telemetry_events_export_queue` 2. Cleaning up already-exported entries in the `telemetry_events_export_queue` diff --git a/enterprise/cmd/worker/BUILD.bazel b/enterprise/cmd/worker/BUILD.bazel deleted file mode 100644 index 5f0053f5a2e..00000000000 --- a/enterprise/cmd/worker/BUILD.bazel +++ /dev/null @@ -1,68 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") -load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball") -load("@rules_pkg//:pkg.bzl", "pkg_tar") -load("@container_structure_test//:defs.bzl", "container_structure_test") -load("//dev:oci_defs.bzl", "image_repository") - -go_library( - name = "worker_lib", - srcs = ["main.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker", - visibility = ["//visibility:private"], - deps = [ - "//enterprise/cmd/worker/shared", - "//internal/sanitycheck", - "//internal/service/svcmain", - ], -) - -go_binary( - name = "worker", - embed = [":worker_lib"], - visibility = ["//visibility:public"], - x_defs = { - "github.com/sourcegraph/sourcegraph/internal/version.version": "{STABLE_VERSION}", - "github.com/sourcegraph/sourcegraph/internal/version.timestamp": "{VERSION_TIMESTAMP}", - }, -) - -pkg_tar( - name = "tar_worker", - srcs = [":worker"], -) - -oci_image( - name = "image", - base = "@wolfi_base", - entrypoint = [ - "/sbin/tini", - "--", - "/worker", - ], - tars = [":tar_worker"], - user = "sourcegraph", -) - -oci_tarball( - name = "image_tarball", - image = ":image", - repo_tags = ["worker:candidate"], -) - -container_structure_test( - name = "image_test", - timeout = "short", - configs = ["image_test.yaml"], - driver = "docker", - image = ":image", - tags = [ - "exclusive", - "requires-network", - ], -) - -oci_push( - name = "candidate_push", - image = ":image", - repository = image_repository("worker"), -) diff --git a/enterprise/cmd/worker/README.md b/enterprise/cmd/worker/README.md deleted file mode 100644 index 1acb7dd7989..00000000000 --- a/enterprise/cmd/worker/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Enterprise worker - -The enterprise worker supplements the [OSS worker](../../../cmd/worker) with additional enterprise-relevant background jobs. diff --git a/enterprise/cmd/worker/image_test.yaml b/enterprise/cmd/worker/image_test.yaml deleted file mode 100644 index d197fa98aeb..00000000000 --- a/enterprise/cmd/worker/image_test.yaml +++ /dev/null @@ -1,15 +0,0 @@ -schemaVersion: "2.0.0" - -commandTests: - - name: "binary is runnable" - command: "/worker" - envVars: - - key: "SANITY_CHECK" - value: "true" - - - name: "not running as root" - command: "/usr/bin/id" - args: - - -u - excludedOutput: ["^0"] - exitCode: 0 diff --git a/enterprise/cmd/worker/internal/executors/CODENOTIFY b/enterprise/cmd/worker/internal/executors/CODENOTIFY deleted file mode 100644 index 16cb819f7ff..00000000000 --- a/enterprise/cmd/worker/internal/executors/CODENOTIFY +++ /dev/null @@ -1,3 +0,0 @@ -# See https://github.com/sourcegraph/codenotify for documentation. - -**/* @efritz diff --git a/enterprise/cmd/worker/main.go b/enterprise/cmd/worker/main.go deleted file mode 100644 index 8cfc53077b2..00000000000 --- a/enterprise/cmd/worker/main.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared" - "github.com/sourcegraph/sourcegraph/internal/sanitycheck" - "github.com/sourcegraph/sourcegraph/internal/service/svcmain" -) - -var config = svcmain.Config{} - -func main() { - sanitycheck.Pass() - svcmain.SingleServiceMain(shared.Service, config) -} diff --git a/enterprise/cmd/worker/shared/BUILD.bazel b/enterprise/cmd/worker/shared/BUILD.bazel deleted file mode 100644 index 1882ab65787..00000000000 --- a/enterprise/cmd/worker/shared/BUILD.bazel +++ /dev/null @@ -1,44 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "shared", - srcs = [ - "service.go", - "shared.go", - ], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/shared", - visibility = ["//visibility:public"], - deps = [ - "//cmd/frontend/globals", - "//cmd/worker/job", - "//cmd/worker/shared", - "//cmd/worker/shared/init/db", - "//enterprise/cmd/worker/internal/auth", - "//enterprise/cmd/worker/internal/batches", - "//enterprise/cmd/worker/internal/codeintel", - "//enterprise/cmd/worker/internal/codemonitors", - "//enterprise/cmd/worker/internal/embeddings/repo", - "//enterprise/cmd/worker/internal/executormultiqueue", - "//enterprise/cmd/worker/internal/executors", - "//enterprise/cmd/worker/internal/githubapps", - "//enterprise/cmd/worker/internal/insights", - "//enterprise/cmd/worker/internal/own", - "//enterprise/cmd/worker/internal/permissions", - "//enterprise/cmd/worker/internal/search", - "//enterprise/cmd/worker/internal/telemetry", - "//enterprise/cmd/worker/internal/telemetrygatewayexporter", - "//internal/auth/userpasswd", - "//internal/authz", - "//internal/authz/providers", - "//internal/authz/subrepoperms", - "//internal/conf", - "//internal/database", - "//internal/debugserver", - "//internal/env", - "//internal/extsvc/versions", - "//internal/observation", - "//internal/oobmigration/migrations/register", - "//internal/service", - "@com_github_sourcegraph_log//:log", - ], -) diff --git a/enterprise/cmd/worker/shared/service.go b/enterprise/cmd/worker/shared/service.go deleted file mode 100644 index 539da69ea37..00000000000 --- a/enterprise/cmd/worker/shared/service.go +++ /dev/null @@ -1,33 +0,0 @@ -package shared - -import ( - "context" - - "github.com/sourcegraph/sourcegraph/cmd/worker/shared" - "github.com/sourcegraph/sourcegraph/internal/auth/userpasswd" - "github.com/sourcegraph/sourcegraph/internal/debugserver" - "github.com/sourcegraph/sourcegraph/internal/env" - "github.com/sourcegraph/sourcegraph/internal/observation" - "github.com/sourcegraph/sourcegraph/internal/oobmigration/migrations/register" - "github.com/sourcegraph/sourcegraph/internal/service" -) - -type svc struct{} - -func (svc) Name() string { return "worker" } - -func (svc) Configure() (env.Config, []debugserver.Endpoint) { - return shared.LoadConfig(additionalJobs, register.RegisterEnterpriseMigrators), nil -} - -func (svc) Start(ctx context.Context, observationCtx *observation.Context, ready service.ReadyFunc, config env.Config) error { - go setAuthzProviders(ctx, observationCtx) - - // internal/auth/providers.{GetProviderByConfigID,GetProviderbyServiceType} are potentially in the call-graph in worker, - // so we init the built-in auth provider just in case. - userpasswd.Init() - - return shared.Start(ctx, observationCtx, ready, config.(*shared.Config), getEnterpriseInit(observationCtx.Logger)) -} - -var Service service.Service = svc{} diff --git a/enterprise/cmd/worker/shared/shared.go b/enterprise/cmd/worker/shared/shared.go deleted file mode 100644 index 4e5140e10ce..00000000000 --- a/enterprise/cmd/worker/shared/shared.go +++ /dev/null @@ -1,113 +0,0 @@ -package shared - -import ( - "context" - "time" - - "github.com/sourcegraph/log" - - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/auth" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/githubapps" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/own" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/search" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetrygatewayexporter" - - "github.com/sourcegraph/sourcegraph/cmd/frontend/globals" - "github.com/sourcegraph/sourcegraph/cmd/worker/job" - workerdb "github.com/sourcegraph/sourcegraph/cmd/worker/shared/init/db" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/batches" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/codeintel" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/codemonitors" - repoembeddings "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/repo" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executormultiqueue" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/executors" - workerinsights "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/insights" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/permissions" - "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetry" - "github.com/sourcegraph/sourcegraph/internal/authz" - "github.com/sourcegraph/sourcegraph/internal/authz/providers" - srp "github.com/sourcegraph/sourcegraph/internal/authz/subrepoperms" - "github.com/sourcegraph/sourcegraph/internal/conf" - "github.com/sourcegraph/sourcegraph/internal/database" - "github.com/sourcegraph/sourcegraph/internal/extsvc/versions" - "github.com/sourcegraph/sourcegraph/internal/observation" -) - -var additionalJobs = map[string]job.Job{ - "codehost-version-syncing": versions.NewSyncingJob(), - "insights-job": workerinsights.NewInsightsJob(), - "insights-query-runner-job": workerinsights.NewInsightsQueryRunnerJob(), - "insights-data-retention-job": workerinsights.NewInsightsDataRetentionJob(), - "batches-janitor": batches.NewJanitorJob(), - "batches-scheduler": batches.NewSchedulerJob(), - "batches-reconciler": batches.NewReconcilerJob(), - "batches-bulk-processor": batches.NewBulkOperationProcessorJob(), - "batches-workspace-resolver": batches.NewWorkspaceResolverJob(), - "executors-janitor": executors.NewJanitorJob(), - "executors-metricsserver": executors.NewMetricsServerJob(), - "executors-multiqueue-metrics-reporter": executormultiqueue.NewMultiqueueMetricsReporterJob(), - "codemonitors-job": codemonitors.NewCodeMonitorJob(), - "bitbucket-project-permissions": permissions.NewBitbucketProjectPermissionsJob(), - "permission-sync-job-cleaner": permissions.NewPermissionSyncJobCleaner(), - "permission-sync-job-scheduler": permissions.NewPermissionSyncJobScheduler(), - "export-usage-telemetry": telemetry.NewTelemetryJob(), - "telemetrygateway-exporter": telemetrygatewayexporter.NewJob(), - - "codeintel-policies-repository-matcher": codeintel.NewPoliciesRepositoryMatcherJob(), - "codeintel-autoindexing-summary-builder": codeintel.NewAutoindexingSummaryBuilder(), - "codeintel-autoindexing-dependency-scheduler": codeintel.NewAutoindexingDependencySchedulerJob(), - "codeintel-autoindexing-scheduler": codeintel.NewAutoindexingSchedulerJob(), - "codeintel-commitgraph-updater": codeintel.NewCommitGraphUpdaterJob(), - "codeintel-metrics-reporter": codeintel.NewMetricsReporterJob(), - "codeintel-upload-backfiller": codeintel.NewUploadBackfillerJob(), - "codeintel-upload-expirer": codeintel.NewUploadExpirerJob(), - "codeintel-upload-janitor": codeintel.NewUploadJanitorJob(), - "codeintel-ranking-file-reference-counter": codeintel.NewRankingFileReferenceCounter(), - "codeintel-uploadstore-expirer": codeintel.NewPreciseCodeIntelUploadExpirer(), - "codeintel-crates-syncer": codeintel.NewCratesSyncerJob(), - "codeintel-sentinel-cve-scanner": codeintel.NewSentinelCVEScannerJob(), - "codeintel-package-filter-applicator": codeintel.NewPackagesFilterApplicatorJob(), - - "auth-sourcegraph-operator-cleaner": auth.NewSourcegraphOperatorCleaner(), - - "repo-embedding-janitor": repoembeddings.NewRepoEmbeddingJanitorJob(), - "repo-embedding-job": repoembeddings.NewRepoEmbeddingJob(), - "repo-embedding-scheduler": repoembeddings.NewRepoEmbeddingSchedulerJob(), - - "own-repo-indexing-queue": own.NewOwnRepoIndexingQueue(), - - "github-apps-installation-validation-job": githubapps.NewGitHubApsInstallationJob(), - - "exhaustive-search-job": search.NewSearchJob(), -} - -// SetAuthzProviders waits for the database to be initialized, then periodically refreshes the -// global authz providers. This changes the repositories that are visible for reads based on the -// current actor stored in an operation's context, which is likely an internal actor for many of -// the jobs configured in this service. This also enables repository update operations to fetch -// permissions from code hosts. -func setAuthzProviders(ctx context.Context, observationCtx *observation.Context) { - observationCtx = observation.ContextWithLogger(observationCtx.Logger.Scoped("authz-provider", ""), observationCtx) - db, err := workerdb.InitDB(observationCtx) - if err != nil { - return - } - - // authz also relies on UserMappings being setup. - globals.WatchPermissionsUserMapping() - - for range time.NewTicker(providers.RefreshInterval()).C { - allowAccessByDefault, authzProviders, _, _, _ := providers.ProvidersFromConfig(ctx, conf.Get(), db.ExternalServices(), db) - authz.SetProviders(allowAccessByDefault, authzProviders) - } -} - -func getEnterpriseInit(logger log.Logger) func(database.DB) { - return func(db database.DB) { - var err error - authz.DefaultSubRepoPermsChecker, err = srp.NewSubRepoPermsClient(db.SubRepoPerms()) - if err != nil { - logger.Fatal("Failed to create sub-repo client", log.Error(err)) - } - } -} diff --git a/mockgen.test.yaml b/mockgen.test.yaml index 227410d92ce..07cc3585478 100644 --- a/mockgen.test.yaml +++ b/mockgen.test.yaml @@ -339,8 +339,8 @@ path: github.com/sourcegraph/zoekt interfaces: - Streamer -- filename: enterprise/cmd/worker/internal/telemetry/mocks_test.go - path: github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/telemetry +- filename: cmd/worker/internal/telemetry/mocks_test.go + path: github.com/sourcegraph/sourcegraph/cmd/worker/internal/telemetry interfaces: - bookmarkStore - filename: internal/codeintel/ranking/mocks_test.go diff --git a/sg.config.yaml b/sg.config.yaml index a0ae4fc34fb..b41cb134c04 100644 --- a/sg.config.yaml +++ b/sg.config.yaml @@ -280,12 +280,11 @@ commands: if [ -n "$DELVE" ]; then export GCFLAGS='all=-N -l' fi - go build -gcflags="$GCFLAGS" -o .bin/worker github.com/sourcegraph/sourcegraph/enterprise/cmd/worker + go build -gcflags="$GCFLAGS" -o .bin/worker github.com/sourcegraph/sourcegraph/cmd/worker watch: - lib - internal - cmd/worker - - enterprise/cmd/worker cody-gateway: cmd: | @@ -990,7 +989,7 @@ bazelCommands: # frontend processes need this to be so that the paths to the assets are rendered correctly WEBPACK_DEV_SERVER: 1 worker: - target: //enterprise/cmd/worker + target: //cmd/worker precmd: | export SOURCEGRAPH_LICENSE_GENERATION_KEY=$(cat ../dev-private/enterprise/dev/test-license-generation-key.pem) repo-updater: