Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmd
AgeCommit message (Collapse)Author
2021-09-30Merge branch 'ps-crowler' into 'master'Pavlo Strokov
repocleaner: Log warning message for repositories not known to praefect Closes #3719 See merge request gitlab-org/gitaly!3839
2021-09-30repoclean: Run background task to log unknown repositoriesPavlo Strokov
Background task runs with start of the praefect and periodically and scans gitaly nodes for the repositories. For each repository that is known to praefect it writes a warning log message. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3719
2021-09-29Merge branch 'smh-test-with-per-repo' into 'master'Toon Claes
Use PerRepositoryElector in test-with-praefect See merge request gitlab-org/gitaly!3914
2021-09-29Merge branch 'jc-fix-gitaly-logs' into 'master'James Fargher
Ensure log entries have time formatted as UTC Closes #3710 See merge request gitlab-org/gitaly!3912
2021-09-27Ensure log entries have time formatted as UTCJohn Cai
Use a formatter with logrus logs so all log entries have the time field as UTC. Also fixed a few places that weren't using the configured logger. Changelog: fixed
2021-09-24Wait for the first health check prior to serving in PraefectSami Hiltunen
Praefect currently is not waiting for a health check to complete before it takes over the sockets and starts routing RPCs. This can be a problem as the RPCs will fail due to not having any healthy nodes available if they are served prior to performing the first check. This commit fixes the issues by waiting for the first health check to complete prior to serving RPCs. Changelog: fixed
2021-09-23Merge branch 'pks-operations-drop-git2go-merge-gob-ff' into 'master'James Fargher
operations: Always return structured errors from Git2Go merges Closes #3756 See merge request gitlab-org/gitaly!3896
2021-09-21operations: Always return structured errors from Git2Go mergesPatrick Steinhardt
In commit 84bd2721e (gitaly-git2go: Return structured conflict error on merge conflict, 2021-08-26), we have changed gitaly-git2go's merge subcommand to support structured errors. This allows us to return more information why a merge failed, e.g. by returning the set of conflicting files to the caller. Drop the feature flag which guards this code and thus always enable the use of structured errors.
2021-09-21gitaly-git2go: Remove "set-config" subcommandPatrick Steinhardt
While the "set-config" subcommand can in theory still be called when doing a zero-downtime upgrade given that its corresponding RPC still existed in this release, in practice the RPC wasn't ever called anymore. As a result, we can already drop the subcommand right now without having to fear any regressions.
2021-09-20Merge branch 'pks-go-drop-1.15-support' into 'master'Toon Claes
Drop support for Go 1.15 See merge request gitlab-org/gitaly!3879
2021-09-20global: Replace deprecated usage of `ioutil.WriteFile()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.WriteFile()` with `os.WriteFile()` to adapt accordingly.
2021-09-20global: Replace deprecated usage of `ioutil.TempFile()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.TempFile()` with `os.CreateTemp()` to adapt accordingly.
2021-09-20global: Replace deprecated usage of `ioutil.TempDir()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.TempDir()` with `os.MkdirTemp()` to adapt accordingly.
2021-09-20global: Replace deprecated usage of `ioutil.ReadFile()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.ReadFile()` with `os.ReadFile()` to adapt accordingly.
2021-09-20global: Replace deprecated usage of `ioutil.Discard`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.Discard` with `io.Discard` to adapt accordingly.
2021-09-20helper: Move metatada-helpers into the metadata packagePatrick Steinhardt
While the helpers `IncomingToOutgoing()` and `OutgoingToIncoming()` both fall into the metadata categories, they're still part of the generic "helper" package. Move them over into the "metadata" package to make them easier to find.
2021-09-14Merge branch 'ps-repo-removal-cli' into 'master'Pavlo Strokov
remove-repository: A new sub-command for the praefect to remove repository See merge request gitlab-org/gitaly!3767
2021-09-14remove-repository: A new sub-command for the praefect to remove repositoryPavlo Strokov
Users of the praefect are missing tools to manage state of the cluster. One of such tools is a repository removal cli. It should be used to remove any repository from the cluster. The removal covers cleanup of the database and removal from the gitaly storages. The command tries to remove as much as possible first by removing from praefect, replication event queue and each gitaly node configured in the provided config file. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3771 Changelog: added
2021-09-13config: Extend error from loadConfig() with contextPavlo Strokov
2021-09-08Merge branch 'pks-updateref-lock-during-tx' into 'master'Toon Claes
updateref: Partially fix locking semantics See merge request gitlab-org/gitaly!3829
2021-09-06updateref: Rename `Wait()` to `Commit()`Patrick Steinhardt
Before we have converted the updateref package to always use transactional semantics in 154dbc1a2 (updateref: Safeguard against accidentally committing updates, 2020-12-15), all the `Wait()` function used to do was to call `Wait()` on git-update-ref(1). This simply closed stdin and then waited for the command to return. But since above commit, semantics have changed such that we now always use an explicit transaction, where `Wait()` is now responsible for committing the transaction by sending "commit" to the process. In this context, calling the function `Wait()` doesn't really convey its spirit anymore: yes, we wait for the command, but what we are really doing is to commit the transaction. Rename the function to `Commit()` to better highlight its modern use.
2021-09-02hook: Fix allowed errors not propagating correctly anymorePatrick Steinhardt
In 773668f55 (hook: Fix prereceive returning AllowedError for generic errors, 2021-08-13), we have refactored our allowed checks to return a generic error in case the call to `Allowed()` itself failed. The assumption here was that because the call returns an `allowed` boolean, it would not raise an error if the call wasn't allowed. As it turns out, this assumption is wrong: the GitlabNetClient in gitlab-shell will always return an error if the HTTP status code is not between 200 and 399, and access checks do return an error code in case access was denied. As a result, the error we returned to the Gitaly client wouldn't have its "GitLab: " prefix anymore and thus GitLab wouldn't recognize this error as an error that shall be returned to the user. Ideally, we'd properly fix this by inspecting errors returned by the GitLabNetClient. But this isn't possible without parsing the error messages given that the client will only return generic errors. So this commit just reverts the state to what we had before, where we simply treat all errors returned by the client as user-facing errors. This logic is broken and will reveal messages to the user which aren't intended for him in the first place, but we cannot help this for now. Changelog: fixed
2021-09-01Merge branch 'pks-go-1.17-build-tags' into 'master'Pavlo Strokov
global: Support Go-1.17-style build tags See merge request gitlab-org/gitaly!3804
2021-09-01Merge branch 'smh-cluster-repository-id' into 'master'Patrick Steinhardt
Assign repositories unique IDs in Praefect See merge request gitlab-org/gitaly!3762
2021-09-01global: Support Go-1.17-style build tagsPatrick Steinhardt
With Go 1.17, new syntax was introduced for build tags which has the intent to be much easier to use compared to the previous `+build` ones. To ease the migration, Go 1.17 supports both old-style and new-style build tags, where the recommended migration path is to have both as long as projects support older Go versions which don't yet know about the new syntax. Migrate our codebase to use both both styles. While we don't yet support Go 1.17 officially, it doesn't hurt to be prepared, and furthermore it fixes linting issues I have been observing on my machine.
2021-08-31Merge branch 'restore_concurrency' into 'master'Sami Hiltunen
Refactor backup pipeline to use commands See merge request gitlab-org/gitaly!3796
2021-08-31Link records with repository ID in CreateRepositorySami Hiltunen
When a repository is being created, all of the records need to be connected via the repository ID. This commit expands CreateRepository to take in the repository ID Praefect reserved for the repository while routing the creation request. CreateRepository then links all of the records it creates via the repository id. While the repository ID is not really used for anything yet, the newly created records being linked via the ID allow us to run a migration in the following record to just link all existing records correctly via the repository ID. Any concurrently created records would already be linked correctly by the code added in this commit.
2021-08-31Reserve repository ids when routing repository creationsSami Hiltunen
When Praefect is routing a repository creation, it needs to reserve a repository ID in order to generate later a relative path for the repository. This commit changes the PerRepositoryRouter to reserve a repository ID and return in the route. The ID reservation also acts as a fail fast check to see whether there already exists a repository with the given virtual storage and relative path.
2021-08-31Rename ParallelCreatePipeline to ParallelPipelineJames Fargher
Now that it no longer only handles create, we can make the name more generic.
2021-08-31Restore backups concurrentlyJames Fargher
Changelog: changed
2021-08-31Refactor backup pipeline to use commandsJames Fargher
In order to implement incremental backups we will be adding more operations than just Create/Restore but once we add these operations it would become difficult to also keep concurrency. So instead we encapsulate the execution of these operations into commands.
2021-08-31global: Reformat sources with gofumptPatrick Steinhardt
Reformat sources with gofumpt.
2021-08-30gitlab: Generalize GitLab mock clientPatrick Steinhardt
The GitLab mock client will currently always return success for all of its stubbed functions. In a subsequent patch, we'll want to write tests though which return various failures instead. Prepare for this by generalizing the mock client such that callers can pass arbitrary implementations of its mocked functions.
2021-08-30hook: Fix prereceive returning AllowedError for generic errorsPatrick Steinhardt
The pre-receive hook implementation is responsible for calling GitLab's `/internal/allowed` API to do access checks. In case this API endpoint tells us that a change is not allowed, we need to make the error message available to the original caller, which then knows to return the error message via the response's `PreReceiveError` field. Our current implementation of this is wrong though: while we correctly pass up information via a `NotAllowedError` in case the access check indicates that the change is not allowed, we also pass up information when invoking the endpoint itself failed. But this really is an internal error, and we don't ever want to return such information to the user. Fix this issue by returning a normal error in such cases. Changelog: fixed
2021-08-30gitaly-git2go: Return structured conflict error on merge conflictPatrick Steinhardt
We have recently started efforts to return structured error types from Gitaly RPCs to tell upstream callers why an error was raised, which is going to replace the current approach where error information is passed as plain string in a normal RPC response. The first candidate we're converting is UserMergeBranch. While it is easy in UserMergeBranch to return error details in case access checks fail, we also want to return details in case the merge failed due to conflicts. The most important info we want to return in this case is which files are conflicting as well as the revisions which do. While we already have info about the revisions, Gitaly currently cannot tell which files were conflicting: this information is only known to gitaly-git2go, and we do not pass up this information in any way. Now that we have gob serialization in place in gitaly-git2go's merge subcommand, this is an easy fix though given that we can easily return "real" errors. This commit thus introduces a new `ConflictingFilesError` which has a slice of conflicting files as field and returns it in case gob serialization is in use. Note that we do not yet use this rich information for now, but this change only lays the groundwork. As such, no change in behaviour is expected from this commit.
2021-08-30git2go: Support driving merge command via gobPatrick Steinhardt
The gitaly-git2go merge subcommand has learned to use gob for serialization of parameters and results. This commit now teaches the internal package to drive the subcommand with gob. This change is implemented behind a feature flag because of backwards compatibility.
2021-08-30gitaly-git2go: Support gob in the merge subcommandPatrick Steinhardt
Back when we have started implementing RPCs via gitaly-git2go, the initial implementations were all using JSON as representation for inputs and outputs. At a later point we noticed that this makes it hard to return typed errors, which is why later subcommands have shifted to using gob encoders. The merge subcommand is the first command we have written, and thus it also uses JSON encoding, facing the exact error handling issue mentioned above. We want to extend the command to return information about conflicting files though, which would ideally be part of the returned error type. Refactor the subcommand to optionally support gob as encoding: if the command is called with no JSON request, then we instead use gob. While this seems kind of cheap, it's easier than adding a separate flag and should always provide expected results: we never call the command without a request, and the request cannot ever be empty given that it's a JSON-encoded struct.
2021-08-30gitaly-git2go: Fix merge response always going to stdoutPatrick Steinhardt
Originally, gitaly-git2go commands would always write to their responses to stdout themselves. With the introduction of gob for serialization and deserialization of inputs and outputs, this has changed to pass in a reader and writer to all commands. The merge subcommand is still directly writing to stdout though. Fix this issue by writing to the passed-in writer instead. This is only a theoretical issue: there are no callers which would ask gitaly-git2go subcommands to write anywhere else.
2021-08-30gitaly-git2go: Split merge code into runner and actual logicPatrick Steinhardt
The gitaly-git2go merge code handles deserialization of params, deserialization of results and the actual merge logic in a single function. This makes it hard to reason about inputs and outputs of this function and thus prohibits an easy refactor of them. Refactor the code and pull out the merge logic into its own function, where all parameters are obtained as input and output is handled by the calling function. No change in behaviour is expected from this refactoring.
2021-08-30Allow selecting locator strategy from commandlineJames Fargher
This allows testing of new locator strategies without breaking any existing backups.
2021-08-26FindLicense: Implement license finding in GoKirill
This change implements the license finding in Go using github.com/go-enry/go-license-detector. Issue: https://gitlab.com/gitlab-org/gitaly/-/issues/3078 Changelog: performance
2021-08-25Merge branch 'pks-golangci-1.42.0' into 'master'Pavlo Strokov
Upgrade golangci-lint to v1.42.0 See merge request gitlab-org/gitaly!3786
2021-08-24Add PackObjectsHookWithSidechannel support to gitaly-hooksJacob Vosmaer
This RPC will not be used by default, it sits behind a feature flag. Eventually this will replace PackObjectsHook. Changelog: other
2021-08-20praefect: Fix misuse of `signal.Notify()` with unbuffered channelPatrick Steinhardt
The documentation of `signal.Notify()` mentions that the caller must ensure that the provided channel is sufficiently buffered, but we pass in an unbuffered channel. Let's fix this by creating the channel with a buffer size of "1" such that we can receive at least one signal.
2021-08-20Merge branch 'smh-dont-replicate-accept-dataloss' into 'master'Pavlo Strokov
Don't schedule replication jobs in SetAuthoritativeStorage See merge request gitlab-org/gitaly!3776
2021-08-19Do not inject replication queue into InfoServiceSami Hiltunen
InfoService previously used the replication queue to schedule replication jobs as part of the manual reconciliation command and when accepting data loss. The manual reconciler has been removed and accepting data loss relies on the automatic reconciler. As the InfoService no longer needs to queue replication jobs, this commit removes the unnecessary field and updates the call sites not to inject the queue.
2021-08-19Merge branch 'ps-parallel-sql-dependent-tests' into 'master'Sami Hiltunen
test: Parallel SQL dependent tests See merge request gitlab-org/gitaly!3778
2021-08-19test: Parallel tests dependent on the PostgreSQL databasePavlo Strokov
As now we create a new database on each call of the glsql.GetDB the test execution time increased. To mitigate that problem we make tests dependent on the PostgreSQL database parallel. It should reduce test execution time and may help us to find new issues in the code because of the shared global state.
2021-08-19test: Rename GetDB to NewDBPavlo Strokov
As now we create a new database on each call of the glsql.GetDB and do not re-use existing database created on a first call of the function we rename the function. NewDB is self-explanatory.
2021-08-19test: Remove redundant wrapper around glsql.GetDBPavlo Strokov
Previously the wrapper was used to omit repetition of the same database name in the package. As now we create a new database on each call of the glsql.GetDB with unique autogenerated name the wrapper is redundant.