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/client
AgeCommit message (Collapse)Author
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-18log: Roundtrip `log.Logger` typePatrick Steinhardt
The `log.Logger` type still converts to a `logrus.Entry` when calling functions like `WithField()` or `WithError()`. This was hard to change though because a lot of callsites still relied on this conversion. By now we have have fixed all blockers though, which allows us to finally do the conversion and have the `log.Logger` type roundtrip to itself. To do so, we inline the `logrus.FieldLogger` interface and adapt the specific functions to return a `Logger` instead of a `logrus.Entry`. This change also demonstrates that all internal interfaces now use the interface exclusively and that we are free to adapt the interface as required from now on. Note that we also have to add two additional functions to the interface to create the logging interceptors for the gRPC server. This is because we have no way to create these interceptors manually from a `log.Logger` anymore and thus need its help to do so for us.
2023-09-18testhelper: Return our own logger instead of `logrus.FieldLogger`Patrick Steinhardt
Refactor out testhelper functions that create a logger to return our own internal `log.LogrusLogger` instead of a `logrus.FieldLogger`. Add an abstraction layer around adding hooks into the logger such that tests don't need to reach into the logrus logger in general.
2023-09-07client: Split out Gitaly-specific client logicPatrick Steinhardt
Split out Gitaly-specific client logic for SSHReceivePack, SSHUploadPack and SSHUploadArchive. This is the last remaining part to ensure that none of our own internal packages use the public `client` package.
2023-09-07golangci-lint: Don't exclude error checks for `pool.Close()`Patrick Steinhardt
With our migration to use the internal pool functionality we have also converted all callsites to use `testhelper.MustClose()` to close the pool with proper error checking in place. Because of that, we only have a single callsite left where we don't check the error code when closing the pools, which thus makes our linter rule superfluous where we don't require error checks for that function. Remove the rule and add error checking to the last remaining callsite that doesn't.
2023-09-07client: Move `FailOnNonTempDialError` logic into internal packagePatrick Steinhardt
Move the `FailOnNonTempDialError` logic into our internal client package. Like this we can reuse the functionality internally without having to rely on our public interface, which allows us to iterate on its internal implementation without breaking the public API.
2023-09-07client: Move `HealthCheckDialer` logic into internal packagePatrick Steinhardt
Move the `HealthCheckDialer` logic into our internal client package. Like this we can reuse the functionality internally without having to rely on our public interface, which allows us to iterate on its internal implementation without breaking the public API.
2023-09-07client: Move `Pool` logic into internal packagePatrick Steinhardt
Move the `Pool` logic into our internal client package. Like this we can reuse the functionality internally without having to rely on our public interface, which allows us to iterate on its internal implementation without breaking the public API.
2023-09-07client: Move `DialSidechannel()` logic into internal packagePatrick Steinhardt
Move the `DialSidechannel()` logic into our internal sidechannel package. Like this we can reuse the functionality internally without having to rely on our public interface, which allows us to iterate on its internal implementation without breaking the public API.
2023-08-31Replace NewLogger calls with SharedLogger calls in testsSami Hiltunen
This commit wires the tests to call SharedLogger instead of NewLogger so they'll use the test case's shared logger. This way the log output is printed to the same logger and is ordered.
2023-08-31Replace use of NewDiscardingLogEntry with the recording loggerSami Hiltunen
Gitaly now has a helper for recording log output and outputting it only in tests. Replace the usage of the discarding logger with the recording logger. These changes are search and replace so these call sites didn't even need a log entry to begin with but rather use a FieldLogger. NewDiscardingLogEntry is removed as it is no longer used.
2023-08-31Replace discarding logger with new recording loggerSami Hiltunen
Gitaly now has a new logger for tests which outputs the logs on test failure only. Replace all usage of discarding logger with it to capture logs instead of discarding them. NewDiscardingLogger is unexported as it is no longer used except for newServerLogger.
2023-08-30Move TestMain into testhelper_test.goWill Chandler
Our style guide states that the `TestMain` function should be placed in a file named `testhelper_test.go` for consistency's sake. A number of packages were placing the test in a standard test file. In cases where `TestMain` was the only function in that file rename it to `testhelper_test.go`. If there were other functions, relocate `TestMain` into a new `testhelper_test.go` file.
2023-08-21client: Use discarding logger for DNS resolver by defaultPatrick Steinhardt
The `DefaultDNSResolverBuilderConfig()` constructs a default config that is to be used by dependents on the Gitaly configuration. Part of this default config is the logger, which we set to `log.Default()`. This is arguably unexpected though, because the default logger will cause us to print message to standard output. Let's refactor the code to instead use a discarding logger by default. If clients want to have logging for this code, they should instead supply their own logger.
2023-08-15grpc: Convert to use `logrus.FieldLogger` interfacePatrick Steinhardt
Convert the dnsresolver, backchannel and sidechannel packages to accept logging interfaces instead of an explicit `logrus.Entry`. Later down the road we will provide our own interfaces to abstract the `logrus` package away from our own internal interfaces, so this change is an early step into that direction. Note that this requires a change in the backchannel package to convert the field logger to an `logrus.Entry` by calling `WithField()` first. We do this by adding a "component" field that points to backchannel, which has the added benefit that we can now more clearly identify when log messages come from inside that subsystem. Furthermore note that we need to change the logging middleware tests to not import our public "client" package anymore and instead use our internal one. This change is required due to a new cyclic dependency between the "internal/log" tests and the "client" package.
2023-06-29Add LookupTimeout configuration to DNS resolverQuang-Minh Nguyen
Gitaly's homegrown DNS resolver triggers DNS queries via UDP. Those queries run independently in dedicated goroutines. They are controlled by a timeout context. Recently, the lookup timeout is hard-coded to 15 seconds. This commit adds LookupTimeout configuration to the DNS resolver. Apart from providing a new config to clients, the new config is used to control and prevent goroutines from being leaked after the test suite is done. In the grpc-go versions before v1.56, the resolver is closed when the bound connection is closed. After v1.56, the resolver runs more independently. The connection doesn't wait for the resolver to finish anymore. After the test suite finishes, there might be some in-flight DNS queries are managed by the DNS resolver. When the connection is closed, those queries don't make sense anymore. They can stay until they finish. Unfortunately, the goroutine detector in the test suite complains about leaked goroutines. The resolver of a connection is not accessible from the outside. Hence, the test sets a low lookup timeout and sleeps for a while until the pending DNS queries go away.
2023-06-13fix: suggestions from code reviewsword
2023-06-09feat: add stats field in SSHUploadPackWithSidechannelResponsesword
2023-05-17client: Refactor `Dial()` to use optionsPatrick Steinhardt
The `client.Dial()` function already accepts a set of optional parameters. Furthermore, we're about to add another optional parameter, which will make the function's signature quite unwieldy. Refactor the function to instead accept options.
2023-05-17gitaly/client: Move into `internal/grpc` packagePatrick Steinhardt
Our internal client package is hosted in `internal/gitaly/client` even though it isn't Gitaly-specific at all. Move it into our new gRPC specific package to avoid confusion.
2023-05-16dnsresolver: Move package into `internal/grpc/`Patrick Steinhardt
We've grown quite a bunch of packages that provide various different functionality in the context of gRPC. But it is not easy to identify them as there is no common hierarchy for gRPC-related functionality. We're thus introducing a new `internal/grpc` package that will host various bits and pieces related to gRPC. Move the `internal/dnsresolver` package into this new package.
2023-05-16listenmux: Move package into `internal/grpc/`Patrick Steinhardt
We've grown quite a bunch of packages that provide various different functionality in the context of gRPC. But it is not easy to identify them as there is no common hierarchy for gRPC-related functionality. We're thus introducing a new `internal/grpc` package that will host various bits and pieces related to gRPC. Move the `internal/listenmux` package into this new package.
2023-05-16sidechannel: Move package into `internal/grpc/`Patrick Steinhardt
We've grown quite a bunch of packages that provide various different functionality in the context of gRPC. But it is not easy to identify them as there is no common hierarchy for gRPC-related functionality. We're thus introducing a new `internal/grpc` package that will host various bits and pieces related to gRPC. Move the `internal/sidechannel` package into this new package.
2023-05-16backchannel: Move package into `internal/grpc/`Patrick Steinhardt
We've grown quite a bunch of packages that provide various different functionality in the context of gRPC. But it is not easy to identify them as there is no common hierarchy for gRPC-related functionality. We're thus introducing a new `internal/grpc` package that will host various bits and pieces related to gRPC. Move the `internal/backchannel` package into this new package.
2023-05-10go: Bump module version from v15 to v16Patrick Steinhardt
We're about to release Gitaly v16.0. As we've landed a bunch of previously announced removals it's thus time to bump our Go module version from v15 to v16.
2023-05-05Use google.golang.org/grpc/interop/grpc_testingMikhail Mazurskiy
google.golang.org/grpc/test/grpc_testing was deleted in gRPC v1.55, see https://github.com/grpc/grpc-go/pull/6164.
2023-03-24middleware: Stop using go-grpc-middleware chainsJames Fargher
go-grpc-middleware have deprecated their middleware chaining methods in favor of the grpc libraries builtin chaining.
2023-03-16lint: Fix discouraged error wrapping verbQuang-Minh Nguyen
We encourage wrapping error with %w when constructing a new error. The new error contains the original error so that it is able to be unwrapped later. This commit converts all error wrapping to %w.
2023-02-22tracing: Replace opentracing calls by new tracing.StartSpan* helpersQuang-Minh Nguyen
In the prior commit, some new utility methods were implemented to wrap around tracing libraries. This commit replaces the existing calls to opentracing library by new methods. Some some advanced usage still holds references to opentracing, though.
2023-02-08dnsresolver: Support DNS scheme in client dial functionsQuang-Minh Nguyen
Previously, we implemented a custom DNS resolver. This resolver handles all Gitaly URL having dns scheme. The exposed dial functions in client package should work well with this scheme. In fact, we added some tests to verify. However, it turns out the tests use `grpc.Dial`, instead of exposed aforementioned dial functions. Hence, after rolling the resolver, the client could not use URLs with DNS scheme. This commit fixes this problem. In addition, the test is strengthen to cover such cases. Changelog: fixed
2023-02-07global: Convert generic packages to test with SHA256 object formatPatrick Steinhardt
There's a bunch of generic packages that really don't depend much on the repository object format. Convert them to test with the SHA256 object format.
2023-02-03Expose our custom DNS resolver as a gRPC client dial optionQuang-Minh Nguyen
gRPC depends on the target's scheme to determine which resolver to use. Built-in DNS Resolver registers itself with "dns" scheme. We should use a different scheme for this resolver. However, Ruby, and other cares-based clients, don't support custom resolver. At GitLab, the gRPC target configuration is shared between components. To ensure the compatibility between clients, this custom resolver use same "dns" scheme. We don't want to mess up the default global registry. Clients are expected to inject this resolver via exposed WithGitalyDNSResolver dial option.
2023-01-18Add round-robin client-side loadbalancing to default dial optionQuang-Minh Nguyen
This commit sets the client-side load-balancing strategy to round-robin via grpc.WithDefaultServiceConfig dial option. This strategy is only effective if the host target can be resolved to multiple addresses. So, it's fairly safe to set it by default.
2023-01-18Handle unhandled connection closing in testsQuang-Minh Nguyen
2022-10-05global: Reformat sources with gofumpt v0.4.0Patrick Steinhardt
Reformat surces with the newly upgraded gofumpt v0.4.0.
2022-09-30golangci-lint: Restore default revive lintswc/fix-revive-lintsWill Chandler
With 7e87131ed (golangci-lint: Allow `testing.T` as first parameter, 2022-08-10) we set `context-as-argument` the sole argument to `revive:rules`. This causes golangci-lint to disable all revive lints that were previously enabled by default. Re-enable the default revive lints by explicitly listing them in our config. This triggers a large number of lint errors, resolve these as well in this commit.
2022-09-23grpc: Fix missing error checks for `Serve()` functionPatrick Steinhardt
The `grpc.Server.Serve()` function will return an error when the gRPC server has either failed unexpectedly or in case it wasn't properly shut down. We don't check this error in many places though, which both causes the errcheck linter to complain and hides issues we have with some of our test setups. Fix the missing error checks via a new `testhelper.MustServe()` helper function that does the error checking for us. This surfaces some test errors for tests that forget to shut down the server or that manually close the listener, which should be handled by gRPC itself. All of those errors are fixed while at it. Drop the corresponding linting exceptions.
2022-09-23sidechannel: Check `Close()` errors returned by the waiterPatrick Steinhardt
We don't properly check the error when closing the `SidechannelWaiter` in many places. Fix this and drop the corresponding linting exceptions.
2022-08-26Let client users specify interceptorsash2k/client-fixesMikhail Mazurskiy
Do not assume client users want the same tracing interceptors with the same configuration.
2022-08-11golangci-lint: Enforce consistent naming of `testing.TB` variablesPatrick Steinhardt
Enforce consistent naming of `testing.TB` variables, which should be called `tb`, and adapt tests that violate this rule.
2022-08-11golangci-lint: Allow `testing.T` as first parameterPatrick Steinhardt
We currently exclude a revive rule that `context.Context` should be the first parameter for our test sources. This can be handled better though because golangci-lint allows us to exclude certain types from this rule. Adapt the rule to allow `testing.T` et al before `context.Context` and remove the excluded rule. Interestingly, this now surfaces a whole bunch of `nolint: revive` annotations that aren't needed anymore, so we fix them in the same commit.
2022-07-27client: Convert to use `grpc_testing` test servicePatrick Steinhardt
Convert the client's dialling tests to use the `grpc_testing` test service instead of the `grpc_proxy` one.
2022-07-18test: Disable all test with tag sha256Toon Claes
We're about to add the ability to test with SHA256 hashes. We assume none of the tests work with this object format. With this change we add the build constraint to not run any test when the tag 'gitaly_test_sha256' is set.
2022-07-07global: Rewrite callers of `testhelper.ModifyEnvironment()`Patrick Steinhardt
Rewrite callers of `testhelper.ModifyEnviroment()`, which is about to be removed in favor of either `t.Setenv()` or `testhelper.Unsetenv()`.
2022-05-20Update go package name from v14 to v15John Cai
This commit changes the major version in the package name from v14 to v15 Updating go.mod & go.sum with new module name v15 Update Makefile to bump major version to v15 Update the gitaly package name in the Makefile. Also update gitaly-git2go-v14 -> gitaly-git2go-v15. We need to keep gitaly-git2go-v14 for a release however, for zero downtime upgrades. This pulls directly from a sha that is v14. Update package name from v14->v15 for auth, client, cmd, internal packages This commit changes the package name from v14 to v15 in go and proto files in the internal, auth, client, cmd packages. proto: Update major package number in package name tools: Change major version number in package name from v14 to v15 gitaly-git2go: Change the package name from v14 to v15 update module updater for v15 Update the documentation for the module updater to reflect v15
2022-01-27Automatically clean up testhelper.ContextSami Hiltunen
testhelper.Context() currently return a cancellation function as a second return value. Majority of the tests do not need to explicitly cancel the context but they simply defer its cancellation to clean up after the test. Given this, we can reduce the test verbosity and make testhelper.Context easier to compose by removing the unnecessary second return value. This adds a t.Cleanup function to automatically cancel the context at the end of the tests and omits the returned cancellation function. Tests which simply `defer cancel()` have had the extra call removed. Some tests explicitly call the cancellation, and these tests have been modified to add context.WithCancel around the testhelper.Context call. There are a few loctions where testing.TB was passed down to test helpers that create the context.
2022-01-20client: Expose sidechannel server methodsJacob Vosmaer
This makes it easier to test sidechannel RPC's in downstream consumers (gitlab-workhorse, gitlab-shell). Changelog: other
2022-01-18Merge branch 'jv-ssh-sidechannel-2' into 'master'Patrick Steinhardt
Add SSHUploadPackWithSidechannel Closes gitlab-com/gl-infra/scalability#1513 See merge request gitlab-org/gitaly!4251
2022-01-17client: add UploadPackWithSidechannelJacob Vosmaer
This adds UploadPackWithSidechannel which will be used internally by gitaly-ssh, and externally by gitlab-shell.
2022-01-17testhelper: ModifyEnvironment cleans after itselfToon Claes
Prior to this change, ModifyEnvironment was returning a function to revert the changes done. This was typically passed to defer or to t.Cleanup(). This change moves calling t.Cleanup() to the ModifyEnvironment function itself.