mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
Remove broken federation feature (#55161)
Only today did I learn about the "Federation" feature: https://docs.sourcegraph.com/admin/federation/public_repositories It's supposed to redirect users from private instances to sourcegraph.com. But it has been broken since at least a year: https://github.com/sourcegraph/sourcegraph/issues/38263#issuecomment-1205110145 It's also confusing. Here's my proposal to remove it. ## Test plan - N/A
This commit is contained in:
parent
aeabbd1cea
commit
53ef8008b0
@ -23,6 +23,7 @@ All notable changes to Sourcegraph are documented in this file.
|
||||
### Removed
|
||||
|
||||
- indexed-search has removed the deprecated environment variable ZOEKT_ENABLE_LAZY_DOC_SECTIONS [zoekt#620](https://github.com/sourcegraph/zoekt/pull/620)
|
||||
- The federation feature that could redirect users from their own Sourcegraph instance to public repositories on Sourcegraph.com has been removed. [#55161](https://github.com/sourcegraph/sourcegraph/pull/55161)
|
||||
|
||||
## 5.1.4
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ go_library(
|
||||
"//internal/authz",
|
||||
"//internal/authz/permssync",
|
||||
"//internal/conf",
|
||||
"//internal/conf/deploy",
|
||||
"//internal/database",
|
||||
"//internal/database/dbcache",
|
||||
"//internal/encryption/keyring",
|
||||
|
||||
@ -3,7 +3,6 @@ package backend
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -15,8 +14,6 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/cmd/frontend/envvar"
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
"github.com/sourcegraph/sourcegraph/internal/conf"
|
||||
"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/dbcache"
|
||||
"github.com/sourcegraph/sourcegraph/internal/errcode"
|
||||
@ -105,25 +102,12 @@ func (s *repos) GetByName(ctx context.Context, name api.RepoName) (_ *types.Repo
|
||||
}
|
||||
|
||||
newName, err := s.add(ctx, name)
|
||||
if err == nil {
|
||||
return s.store.GetByName(ctx, newName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if errcode.IsNotFound(err) && shouldRedirect(name) {
|
||||
return nil, ErrRepoSeeOther{RedirectURL: (&url.URL{
|
||||
Scheme: "https",
|
||||
Host: "sourcegraph.com",
|
||||
Path: string(name),
|
||||
RawQuery: url.Values{"utm_source": []string{deploy.Type()}}.Encode(),
|
||||
}).String()}
|
||||
}
|
||||
return s.store.GetByName(ctx, newName)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func shouldRedirect(name api.RepoName) bool {
|
||||
return !conf.Get().DisablePublicRepoRedirects &&
|
||||
extsvc.CodeHostOf(name, extsvc.PublicCodeHosts...) != nil
|
||||
}
|
||||
|
||||
var metricIsRepoCloneable = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
|
||||
@ -1365,10 +1365,10 @@ type Query {
|
||||
uri: String
|
||||
): Repository
|
||||
"""
|
||||
Looks up a repository by either name or cloneURL or hashedName. When the repository does not exist on the server
|
||||
and "disablePublicRepoRedirects" is "false" in the site configuration, it returns a Redirect to
|
||||
an external Sourcegraph URL that may have this repository instead. Otherwise, this query returns
|
||||
null.
|
||||
Looks up a repository by either name or cloneURL or hashedName. When the
|
||||
repository does not exist on the server, it returns a Redirect to an
|
||||
external Sourcegraph URL that may have this repository instead. Otherwise,
|
||||
this query returns null.
|
||||
"""
|
||||
repositoryRedirect(
|
||||
"""
|
||||
|
||||
@ -9,6 +9,5 @@
|
||||
"externalURL": "http://localhost:3080/",
|
||||
"update.channel": "release",
|
||||
"experimentalFeatures": {},
|
||||
"disablePublicRepoRedirects": true,
|
||||
"repoListUpdateInterval": 1
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ auth.sessionExpiry
|
||||
git.cloneURLToRepositoryName
|
||||
searchScopes
|
||||
extensions
|
||||
disablePublicRepoRedirects
|
||||
```
|
||||
|
||||
## Editing your site configuration if you cannot access the web UI
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
# Federation
|
||||
|
||||
Federation refers to using multiple Sourcegraph servers together, each of which is responsible for a subset of repositories.
|
||||
|
||||
Currently the only supported federation use case is [redirecting your Sourcegraph instance's users to Sourcegraph.com for _public_ repositories](public_repositories.md) (instead of mirroring, analyzing, and indexing public repositories on your Sourcegraph instance).
|
||||
|
||||
## Future plans
|
||||
|
||||
We plan to enhance federation in the future to support merging data (such as cross-references) from multiple Sourcegraph instances, sharing user accounts, etc. [Post an issue](https://github.com/sourcegraph/sourcegraph/issues) if you have a specific feature request for federation.
|
||||
@ -1,20 +0,0 @@
|
||||
# Federation: redirecting to Sourcegraph.com for public repositories
|
||||
|
||||
Sourcegraph instances can be configured to redirect users to [Sourcegraph.com](https://sourcegraph.com) for public repositories. This offloads the work of mirroring, analyzing, and indexing public repositories from your Sourcegraph instance.
|
||||
|
||||
Example: If federation is enabled, a user on your Sourcegraph instance who tries to access a public repository at `https://sourcegraph.example.com/github.com/my/publicrepo` will be redirected to the same repository on Sourcegraph.com `https://sourcegraph.com/github.com/my/publicrepo`.
|
||||
|
||||
Regardless of whether federation is enabled, private repositories are always handled entirely by your own Sourcegraph instance.
|
||||
|
||||
### Benefits
|
||||
|
||||
Enabling federation has the following benefits:
|
||||
|
||||
- It offloads the work of mirroring, analyzing, and indexing public code to Sourcegraph.com, so your own instance's performance and resource consumption are unaffected.
|
||||
- Users get full code navigation for all supported languages on Sourcegraph.com, even if your instance only has code navigation enabled for a subset of languages.
|
||||
- Sourcegraph.com will show users more cross-repository references to code (via the "Find references" feature) than your instance because Sourcegraph.com's index is already very large. Building a comparable index of public code on your instance would require a lot of time and resources.
|
||||
- It eliminates the risk of cloning and building public, untrusted code on your own instance (which may be running inside your private network). Sourcegraph.com applies strict isolation and resource quotas to mitigate this risk on our own infrastructure.
|
||||
|
||||
### Configuration
|
||||
|
||||
The `disablePublicRepoRedirects` [site configuration](../config/site_config.md) option disables redirection.
|
||||
@ -65,7 +65,6 @@ For deployment configuration, please refer to the relevant [installation guide](
|
||||
- [Batch Changes](../batch_changes/index.md)
|
||||
- [Beta and experimental features](beta_and_experimental_features.md)
|
||||
- [Code navigation](../code_navigation/index.md)
|
||||
- [Federation](federation/index.md)
|
||||
- [Pings](pings.md)
|
||||
- [Pricing and subscriptions](subscriptions/index.md)
|
||||
- [Search](search.md)
|
||||
|
||||
@ -45,9 +45,7 @@ var DockerContainer = conftypes.RawUnified{
|
||||
"type": "builtin",
|
||||
"allowSignup": true
|
||||
}
|
||||
],
|
||||
|
||||
"disablePublicRepoRedirects": true,
|
||||
]
|
||||
}`,
|
||||
}
|
||||
|
||||
@ -89,7 +87,7 @@ var App = conftypes.RawUnified{
|
||||
"codeIntelAutoIndexing.enabled": true,
|
||||
"codeIntelAutoIndexing.allowGlobalPolicies": true,
|
||||
"executors.frontendURL": "http://host.docker.internal:3080",
|
||||
"experimentalFeatures": {
|
||||
"experimentalFeatures": {
|
||||
"structuralSearch": "disabled"
|
||||
},
|
||||
"cody.enabled": true,
|
||||
@ -100,7 +98,7 @@ var App = conftypes.RawUnified{
|
||||
},
|
||||
"embeddings": {
|
||||
"enabled": true,
|
||||
"provider": "sourcegraph"
|
||||
"provider": "sourcegraph"
|
||||
}
|
||||
}`,
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ var requireRestart = []string{
|
||||
"git.cloneURLToRepositoryName",
|
||||
"searchScopes",
|
||||
"extensions",
|
||||
"disablePublicRepoRedirects",
|
||||
"auth.userOrgMap",
|
||||
"auth.providers",
|
||||
"externalURL",
|
||||
|
||||
@ -517,7 +517,6 @@ func getTestSiteWithSecrets(testSecrets testSecrets, optionalEdit ...string) str
|
||||
email = optionalEdit[0]
|
||||
}
|
||||
return fmt.Sprintf(`{
|
||||
"disablePublicRepoRedirects": true,
|
||||
"repoListUpdateInterval": 1,
|
||||
"email.address": "%s",
|
||||
"executors.accessToken": "%s",
|
||||
|
||||
@ -2494,7 +2494,7 @@ type SiteConfiguration struct {
|
||||
DisableFeedbackSurvey bool `json:"disableFeedbackSurvey,omitempty"`
|
||||
// DisableNonCriticalTelemetry description: DEPRECATED. Has no effect.
|
||||
DisableNonCriticalTelemetry bool `json:"disableNonCriticalTelemetry,omitempty"`
|
||||
// DisablePublicRepoRedirects description: Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.
|
||||
// DisablePublicRepoRedirects description: DEPRECATED! Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.
|
||||
DisablePublicRepoRedirects bool `json:"disablePublicRepoRedirects,omitempty"`
|
||||
// Dotcom description: Configuration options for Sourcegraph.com only.
|
||||
Dotcom *Dotcom `json:"dotcom,omitempty"`
|
||||
|
||||
@ -804,10 +804,11 @@
|
||||
]
|
||||
},
|
||||
"disablePublicRepoRedirects": {
|
||||
"description": "Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.",
|
||||
"description": "DEPRECATED! Disable redirects to sourcegraph.com when visiting public repositories that can't exist on this server.",
|
||||
"type": "boolean",
|
||||
"group": "External services",
|
||||
"examples": [true]
|
||||
"examples": [true],
|
||||
"deprecationMessage": "Deprecated because it's no longer supported and hasn't been working for a while."
|
||||
},
|
||||
"git.cloneURLToRepositoryName": {
|
||||
"description": "JSON array of configuration that maps from Git clone URL to repository name. Sourcegraph automatically resolves remote clone URLs to their proper code host. However, there may be non-remote clone URLs (e.g., in submodule declarations) that Sourcegraph cannot automatically map to a code host. In this case, use this field to specify the mapping. The mappings are tried in the order they are specified and take precedence over automatic mappings.",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user