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
AgeCommit message (Collapse)Author
2024-01-09Revert "Merge branch 'jliu-track-restored-repos-2' into 'master'"James Liu
This reverts commit 7de65fabe6eaf803771cf0dd5d53dbaf1e628d56, reversing changes made to 0ffc495be9bb5a8f4ff60764b545443d54210e56.
2024-01-05praefect: Intercept WalkRepos RPCJames Liu
Adds a handler to Praefect to intercept calls to the WalkRepos RPC. The handler provides an alternate implementation of listing repositories in a storage, which queries the Praefect DB rather than walking the filesystem on disk. This is required so when the RPC is invoked via Praefect, the DB is used as the source of truth rather than a random Gitaly node. The only user-facing difference between this and the original implementation is that the `modification_time` attribute of the response message is left empty, as this cannot be determined via the DB.
2024-01-05proto: Deprecate RemoveAllJames Liu
Now that we've adjusted the restore mechanism to delete individual repos as needed, this RPC is no longer required. See the following issues for more context: - https://gitlab.com/gitlab-org/gitaly/-/issues/5357 - https://gitlab.com/gitlab-org/gitaly/-/issues/5269 Changelog: deprecated
2023-12-19proto: Add definition for ProcReceiveHook RPCKarthik Nayak
For the `ProcReceiveHook` to work we need to create a RPC which is called by the `gitaly-hooks` binary. Before we create this RPC, let's note the definition of the RPC in the `hook.proto` file. In the following commits we'll define the client and the service following this definition.
2023-12-19praefect: Enable grpcui compatibilityJames Liu
Registers the gRPC reflection service with the Praefect server to enable tools like grpcui to detect the server's endpoints. With this change, it is possible to test Praefect's endpoints locally with the following: grpcui -unix -plaintext <path/to/praefect.socket>
2023-12-14Merge branch 'smh-tx-object-pool' into 'master'Justin Tobler
Enable transactions for object pools See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6562 Merged-by: Justin Tobler <jtobler@gitlab.com> Approved-by: Justin Tobler <jtobler@gitlab.com> Approved-by: Will Chandler <wchandler@gitlab.com> Reviewed-by: Will Chandler <wchandler@gitlab.com> Reviewed-by: Sami Hiltunen <shiltunen@gitlab.com> Co-authored-by: Sami Hiltunen <shiltunen@gitlab.com>
2023-12-06featureflag: Remove `TransactionalAlternatesDisconnect`Justin Tobler
The `TransactionalAlternatesDisconnect` feature flag enables transactions for the `DisconntectGitAlternates` RPC. Remove the feature flag so that transactions are always enabled when client perform object pool disconnection operations.
2023-12-05Enable transactions for LinkRepositoryToObjectPoolSami Hiltunen
This commit enables transactions for LinkRepositoryToObjectPool. This requires just recording the updated alternate link in the transaction. Transactions require the object pool and the member repository to be in the same partition. This may not be the case when Praefect attempts to reconciliate alternate link differences during replication. Moving repositories between partitions is difficult, so for now we'll simply ignore the pool linking failure in Praefect and leave accept deviating alternate links.
2023-12-05Identify pools by suffixesSami Hiltunen
Gitaly is using the repository's path to identify whether a repository is a pool. Rails' pool paths are checked exhaustively with a regex and Praefects paths are checked for a given prefix. These checks are not sufficient to identify pools with transactions as the pool path will be prefixed by the snapshot's root directory. Account for this by changing the checks to verify the suffix of the path matches the expected pool suffix. A test was removed that is asserting behavior related to invalid pool paths. Such state can't be created through the API anymore as we're verifying the pool path in a stricter manner. We've never created such paths as are being tested, so opted for removal rather than maintaining the test.
2023-11-30errors: Fix format directive for two errorsKarthik Nayak
There are 2 instances in our code base where we have two errors and want to merge them. While the best fix would be to use `errors.Join()`, for now, let's just fix the type so that the linter doesn't barf.
2023-11-30errors: Use `errors.Is()` for error comparisonsKarthik Nayak
Similar to the previous commit, fix the remaining error comparisons manually to use errors.Is().
2023-11-30errors: Use `errors.Is()` for `io.EOF` errorsKarthik Nayak
Replace all io.EOF errors comparisons with errors.Is(). This ensures that these errors work correctly with wrapped errors. This also makes way for adding an error linter in the upcoming commits. The changes in this commit were done automagically using project wide replace methods provided by the text editor.
2023-11-30datastore: Fix staticcheck for `Listen()` returning an errorKarthik Nayak
The Listen() function runs and endless loop. It always returns an errors. With this regards, it makes no sense to check if the error is nil. Remove this check.
2023-11-22featureflag: Remove `ReplicateRepositoryObjectPool`Justin Tobler
The `ReplicateRepositoryObjectPool` feature flag enables object pool replication through the `ReplicateRepository` RPC. Remove the feature flag so clients can always request object pool replication.
2023-11-20Merge branch 'smh-remove-namespace-service' into 'master'Quang-Minh Nguyen
Remove NamespaceService Closes #3803 See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6292 Merged-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Approved-by: karthik nayak <knayak@gitlab.com> Co-authored-by: Sami Hiltunen <shiltunen@gitlab.com>
2023-11-20Merge branch 'jt-docs-ref-proto' into 'master'Patrick Steinhardt
proto: Add documentation for `RefService` See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6527 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Patrick Steinhardt <psteinhardt@gitlab.com> Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com> Reviewed-by: Justin Tobler <jtobler@gitlab.com> Co-authored-by: Justin Tobler <jtobler@gitlab.com>
2023-11-16Merge branch 'jt-praefect-pool-sync' into 'master'Sami Hiltunen
praefect: Reconcile non-matching object pools during replication See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6526 Merged-by: Sami Hiltunen <shiltunen@gitlab.com> Approved-by: Will Chandler <wchandler@gitlab.com> Reviewed-by: Will Chandler <wchandler@gitlab.com> Co-authored-by: Justin Tobler <jtobler@gitlab.com>
2023-11-15Merge branch 'jt-ff-remove-transactional-link' into 'master'Will Chandler
featureflag: Remove `TransactionalLinkRepository` See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6528 Merged-by: Will Chandler <wchandler@gitlab.com> Approved-by: Will Chandler <wchandler@gitlab.com> Reviewed-by: Will Chandler <wchandler@gitlab.com> Co-authored-by: Justin Tobler <jtobler@gitlab.com>
2023-11-15featureflag: Remove `TransactionalLinkRepository`Justin Tobler
The `TransactionalLinkRepository` feature flag, when enabled, makes the `LinkRepositoryToObjectPool` RPC transactional. Remove the feature flag so that the RPC is always transactional for clients.
2023-11-15praefect: Update `CreateBranchRequest` and `CreateBranchResponse` usageJustin Tobler
The `CreateBranch` RPC has been removed and there is no longer a need for its associated request and response messages. Update call sites to now use `UserCreateBranch` messages.
2023-11-14praefect: Reconcile non-matching object pools during replicationJustin Tobler
When a Praefect replica becomes out-of-date with the primary repository, a replication job is scheduled to sync repository state. If the primary and secondary replica are linked to non-matching object pools, the replication job will always fail. In this scenario, to reconcile the different object pools the target repository should first disconnect from its object pool and then be linked to the matching source repository object pool. Update Praefect replication jobs to support synchronizing repositories with non-matching object pools.
2023-11-13repository: Remove RenameRepository RPCKarthik Nayak
Remove the RenameRepository RPC as its no longer being used. With this we delete all associated code and tests around this RPC and also delete the proto definitions. While it might have been easier to review as isolated commits, the code is highly intertwined making isolation harder, as such the whole deletion is taken care of in this commit.
2023-11-08praefect: Support object pool disconnection in Praefect replicatorJustin Tobler
When a secondary repository replica in Praefect is out of sync with the primary replica, Praefect creates a replication job that performs the `ReplicateRepository` RPC to replicate the up-to-date primary onto the secondary. As part of this operation the replicator also checks if the source repository is linked to an object pool and if so links the target to the matching object pool on the secondary. If the primary is not linked to an object pool and the secondary is linked to an object pool, no change is made to the target repository object pool relationship and the replication job continues normally. This is problematic because it allows secondary repositories to diverge from the primary. Also if the repository attempts to link to a new object pool via the `LinkRepositoryToObjectPool` RPC, the secondary repositories will always fail due to already being linked to an object pool. To prevent this from occurring, the target repository should also perform the `DisconnectGitAlternates` RPC if it is determined that the source repository is not linked to an object pool. This change updates the Praefect replicator to perform object pool disconnects to ensure the target repository remains consistent with the source.
2023-11-08praefect: Add tests for Praefect replicatorJustin Tobler
As part of the Praefect replication job, a target repository the object pool link of the source repository. Add tests to verify that the Praefect replicator replicates object pool links.
2023-11-01Remove NamespaceServiceSami Hiltunen
NamespaceService has been unused for a long time so let's remove it. It was part of the hashed storage migration which was already finished in GitLab 13.0. Some tests were relying on the NamespaceService methods. Replace the usage with storage scoped mutators or accessors from other services.
2023-10-23Remove name resolving error testSami Hiltunen
We have a test asserting a specific error is returned when attempting to resolve a non-existent name. The 'not-existing.com' address used in the test has since been registered and no longer results in a resolving error. Remove the test to have the pipeline pass. We're probably fine even if we don't test for this specific case.
2023-10-11praefect: Remove DatalossCheck RPC and messagesJohn Cai
The DatalossCheck RPC has been replaced by the Dataloss RPC. Let's remove the code, the RPC definition, and associated messages.
2023-10-11Fix TestProxyWrites setupSami Hiltunen
TestProxyWrites is not creating the test repository in the Gitaly storages. This causes the test to error out with a repositroy not found error when running with WAL. Fix the test setup to actually create the target repository in the Gitaly storages.
2023-10-11Setup repository correctly in TestCoordinator_grpcErrorHandlingSami Hiltunen
TestCoordinator_grpcErrorHandling is not creating the test repository on the Gitaly storages configured as part of a virtual storage. This causes the test to fail when WAL is enabled as the UserCreateBranch errors with unexpected error due to the repository not existing. Setup the repository in the storages to avoid this.
2023-10-05praefect/remove_repository: Replace use of ctxlogrus with injected loggerPatrick Steinhardt
The ctxlogrus package is going away with the replacement being log fields extracted from the context via `log.DebugContext()` et al. Refactor the code to stop using ctxlogrus by injecting a logger and using the new context-based logging methods.
2023-10-05praefect/transactions: Replace use of ctxlogrus with injected loggerPatrick Steinhardt
The ctxlogrus package is going away with the replacement being log fields extracted from the context via `log.DebugContext()` et al. Refactor the code to stop using ctxlogrus by injecting a logger and using the new context-based logging methods.
2023-10-04requestinfohandler: Absorb functionality of the field extractorPatrick Steinhardt
Merge the functionality that the field extractor provides into our requestinfohandler logic. This unifies two related functionalities and will eventually make it easier to move away from the tags mechanism that is going away in go-grpc-middleware v2. Add tests to make sure that the requestinfohandler interceptors work as expected.
2023-10-04middleware: Rename metadatahandler to requestinfohandlerPatrick Steinhardt
We have two different mechanisms to inject information about the current gRPC call into the context: - The metadatahandler injects data about the metadata, e.g. the peer information and whether a call is an accessor or a mutator. - The field extractor that gets set up via go-grpc-middleware's tags interceptor and that injects data about the request. The tagging mechanism used by the field extractor is going away in the go-grpc-middleware dependency though without replacement. Furthermore, both functionalities are related to each other and can thus easily share the same infrastructure. We are thus about to merge them. As a first step, let's rename the metadatahandler to requestinfohandler such that it better reflects the new reponsibility when it will start to handle both gRPC call metadata and request information.
2023-10-04praefect/replicator: Disentangle use of the correlation ID keyPatrick Steinhardt
In order to retain correlation IDs of replication jobs between the time they are added to the database and the time when they are processed, we store the correlation ID as part of the database entry. We store this field generically in the `params` section, which is backend by a JSON encoded column, where we use key-value pairs. The way we use the key here is a bit of a mess though, as we reuse the same key that our metadatahandler uses to inject the correlation ID for logging purposes. It goes without saying though that it is not a good idea to conflate a string for representation (logging) and for storing data consistently (the replication parameters). While the key is in fact the same right now, it could totally be that it might change for our logging infrastructure at some point or even go away. Separate the concerns by introducing a new constant in the `datastore` package that holds the key we want to use in the database. When logging data, we now consistently use the key from `correlation.FieldName`, which is shared across GitLab. And for the database, we consistently use the newly introduced constant.
2023-10-04sentryhandler: Allow overriding function that reports eventsPatrick Steinhardt
We don't have any tests that verify that the sentryhandler interceptors work as expected. With the current layout this is also quite impossible to do, because the event that is to be reported will be passed to the `sentry.CaptureEvent()` function without giving us a way to intercept the captured event. Refactor the code such that it becomes possible to replace the function that reports events. Like that, we can intercept the capture function and thus exercise the code more readily.
2023-09-29praefect/per_repository: Convert to use context-aware loggingPatrick Steinhardt
Inject a logger into the Praefect per-repository router and convert it to use context-aware logging.
2023-09-29praefect/coordinator: Convert to use context-aware loggingPatrick Steinhardt
Inject a logger into the Praefect coordinator and convert it to use context-aware logging.
2023-09-29global: Trivial conversions to use context-aware loggingPatrick Steinhardt
Start using the new context-aware logging facilities in places where we have a logger available.
2023-09-29global: Inject logger into service serversPatrick Steinhardt
Many callsites extract the logger via the passed-in context by using the `ctxlogrus` package. The ability to add loggers to the context via this package is going away upstream though in favor of a new set of logging functions that accept a context as input parameter themselves. We're thus going to introduce an equivalent interface, but that will require our service servers to have a logger available to them. Prepare for this change by injecting the logger into both Gitaly and Praefect servers.
2023-09-28Revert "Merge branch 'pks-log-self-contained-middleware' into 'master'"Quang-Minh Nguyen
This reverts merge request !6408
2023-09-27Merge branch 'pks-log-self-contained-middleware' into 'master'Toon Claes
log: Unify setup of the logging interceptors See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6408 Merged-by: Toon Claes <toon@gitlab.com> Approved-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Approved-by: Toon Claes <toon@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
2023-09-26log: Drop `Errorf()` function from `Logger` interfacePatrick Steinhardt
Remove the `Errorf()` function from the `Logger` interface. Please refer to the preceding commit that removes `Debugf()` for the motivation behind this change.
2023-09-26log: Drop `Warnf()` function from `Logger` interfacePatrick Steinhardt
Remove the `Warnf()` function from the `Logger` interface. Please refer to the preceding commit that removes `Debugf()` for the motivation behind this change.
2023-09-26log: Drop `Infof()` function from `Logger` interfacePatrick Steinhardt
Remove the `Infof()` function from the `Logger` interface. Please refer to the preceding commit that removes `Debugf()` for the motivation behind this change.
2023-09-26log: Drop `Debugf()` function from `Logger` interfacePatrick Steinhardt
Next to `Debug()` and related functions our `Logger` interface also provides `Debugf()` and related functions that takes a formatting string as well as a set of arguments for it. There are multiple reasons though why we don't want to expose these functions: - They do not exist in the `slog` package, which thus causes our own internal interface to diverge from our desired target solution. - It is discouraged to put variable data into the message itself. Instead, callsites are encouraged to add any variable data as structured log data. - It often gets abused in contexts where it's not required at all to call the formatting variant as all we pass in is a static string. - We have a pending addition of logging functions that also take a context parameter as input. The formatting family would cause us to require four more functions that take such a context as input. Let's remove `Debugf()` in favor of `Debug()`. Most of the existing callsites are converted to instead use structured logging data.
2023-09-25log: Unify setup of the logging interceptorsPatrick Steinhardt
Constructing the logging interceptors is quite involved and requires the caller to set up multiple different structures. Besides being hard to understand, it also requires us to expose the fact that we're using the logrus go-grpc-middleware to our callers. Refactor the code to unify all of the plumbing into the logger itself. All the caller needs to pass in now is any additional fields producers they wish to install, but other than that things are self-contained. As this change requires the need to pass in the logrus message producer, it ensures that we can install non-logrus loggers as interceptors. Note that this requires us to change some of our tests to also install the `log.PerRPCLogHandler`. This is required because our own logging interceptor plays some games with the log message such that it can also include gRPC statistics and thus defers writing the log message to a later point. This late rpoint is the per-RPC log handler, which thus becomes mandatory in order to observe any log messages.
2023-09-25praefect: Inline setup of log message producerPatrick Steinhardt
Inline the setup of the log message producer in the Praefect server setup. This change makes a subsequent refactoring of how the logging interceptors are constructed more straight-forward.
2023-09-21log: Hide away the `logrus.Entry` interfacePatrick Steinhardt
The `log.LogrusLogger` type directly wraps the `logrus.Entry`, thus exposing all of its functions. We don't want anybody to call them in the ideal case so that we can ensure that we use our own logging interface almost exclusively throughout the codebase. Let's hide the `logrus.Entry` by making it a private member of the `log.LogrusLogger`. While this requires us to explicitly implement some of the expected interface-level functions, by now it's really only four of them and thus manageable. There are still some very limited callsites in our tests that require access to the `logrus.Entry`, which will be addressed in another iteration. Meanwhile, we expose an explicit `LogrusEntry()` getter that makes the entry accessible to those usecases.
2023-09-19service: Simplify injection of dependencies for Repository serverPatrick Steinhardt
While we already have a `service.Dependencies` type around for quite a long time, we still pass in dependencies explicitly when constructing the actual server. This makes it harder than necessary to make a server require more dependencies as you will have to adjust all callsites where the server is currently getting constructed. Simplify the code to instead inject the `service.Dependencies` type into the server directly. This will allow us to propagate dependencies more readily in the future.
2023-09-18global: Replace some uses of the `logrus` packagePatrick Steinhardt
Remove some more uses of the `logrus` package in our codebase where it's not strictly required.