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
2023-11-30errors: Use `errors.Is()` instead of switch on errorsKarthik Nayak
Currently in many places of our codebase, we have: switch err { case ErrMissingLeaseFile: c.errTotal.WithLabelValues("ErrMissingLeaseFile").Inc() case ErrPendingExists: c.errTotal.WithLabelValues("ErrPendingExists").Inc() } while this works, its not compatible with wrapped errors. So let's fix this by using `errors.Is()` instead.
2023-10-17Log startup item duration in millisecondsWill Chandler
The cache walker and repository counters log their duration upon completion. However, they do so in nanoseconds, while our other logged durations are in milliseconds. Convert these items to log in milliseconds Changelog: changed
2023-10-05cache: 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-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 `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-21log: Simplify Debug et al to accept single argument onlyPatrick Steinhardt
The functions `Debug()`, `Info()` and related accept multiple arguments. The first hunch would be that the logger would format those arguments via a call to `fmt.Sprintf()`, and that's seemingly also the assumption that many of our callsites had. But in fact, the logrus logger will call `fmt.Sprint()`, which joins the arguments by spaces when neither of the arguments is a string. While not being obvious, the current definition also conflicts with the `slog` package. While the respective functions there also accept a variable number of arguments, they will instead be interpreted as key value pairs of structured data. Let's simplify our calling conventions such that the functions only accept a single message parameter and adjust callsites that misused these functions accordingly. This fixes a source of misformatted log messages and prepares us for the conversion to the `slog` package.
2023-09-15log: Encapsulate our use of the `ctxlogrus` packagePatrick Steinhardt
The `ctxlogrus` package is about to go away. Let's encapsulate it so that the transition will become easier for us at a later point.
2023-09-15log: Wrap the logrus loggerPatrick Steinhardt
Introduce a wrapper for the logrus logging infrastructure. This is a first step towards abstracting away the actual implementation of our logs behind a type that we can iterate on and will thus pave the way towards adoption of the `slog` package. Note that this is only one step of this transition. The interface does not yet roundtrip to itself, e.g. calling `log.Logger.WithError()` will result in a `logrus.Entry`, not in a `log.Logger`. This will be handled at a later point.
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-21dontpanic: Use injected logging instancePatrick Steinhardt
We're using the global logging instance provided by `log.Default()`, which is about to go away soon. Refactor the code to instead pass in a proprely configured logging instance.
2023-08-18cache/diskcache: Inject logger instead of using global onePatrick Steinhardt
We're using the global logging instance provided by the logrus package, which is discouraged. Inject a logger such that we can use a properly configured logger instead.
2023-05-16featureflag: Move into standalone packagePatrick Steinhardt
The feature flag logic is currently hosted inside of `internal/metadata/featureflag`. And while they do have something to do with metadata, they really are a standalone concept. Move the package to `internal/featureflag` to reflect this.
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-02-16tests: Fix incorrect executable permissionsJames Fargher
Avoid giving the executable permission to normal files. Prefer using PublicFile and rely on umask restricting permissions further.
2023-02-08Extract file and executable permissionsJames Fargher
Bulk update all file and executable permissions to use the new perm package. Strictly speaking changing os.ModePerm to perm.PublicFile is a permission change (it goes from executable to normal), but since ModePerm is only used in tests this should be safe.
2023-02-08Change inconsistent 655 permission to non-executable 644James Fargher
655 is executable by group and other but not user. This doesn't make a lot of sense. So we change it here to non-executable-shared.
2023-02-07cache: Convert tests to work with SHA256 object formatPatrick Steinhardt
Convert tests to work with the SHA256 object format by removing the need for seed repositories.
2023-02-02Replace Mkdir(All) permissions with new perm package constantsJames Fargher
There should be no actual permissions changes here. This is a like-for-like replacement.
2022-10-14global: Reorder `testing.TB` before `context.Context` argumentsPatrick Steinhardt
A few weeks ago we have decided that `testing.TB` arguments should be first, `context.Context` second. This is rather a matter of perssnal taste instead of correctness, but we should strive for consistency. Reorder all arguments to match the agreed-upon style.
2022-09-29cache: Convert file cleanup to use `os.ReadDir()`pks-refactor-ioutil-readdir-usagesPatrick Steinhardt
Go 1.15 has deprecated the `ioutil` package and made replacements available in the `io` or `os` packages. While we have already migrated most callsites away, one notable omission was `ioutil.ReadDir()` as this function doesn't have an exact replacement: the new `os.ReadDir()` function does not stat all directory entries anymore. Refactor the cleanup of stale cached files in the `cache` package to use the new function.
2022-09-29cache: Convert lease cleanup to use `os.ReadDir()`Patrick Steinhardt
Go 1.15 has deprecated the `ioutil` package and made replacements available in the `io` or `os` packages. While we have already migrated most callsites away, one notable omission was `ioutil.ReadDir()` as this function doesn't have an exact replacement: the new `os.ReadDir()` function does not stat all directory entries anymore. Refactor the cleanup of stale leases in the `cache` package to use the new function.
2022-09-23safe: Check error code when closing writersPatrick Steinhardt
Check error codes when closing a `safe.LockingFileWriter` or `safe.Writer` and drop the corresponding exclude from our linting rules.
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-11gittest: Convert callers of CloneRepo to use CreateRepositoryPatrick Steinhardt
Convert all callers of CloneRepo to use CreateRepository.
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-06featureflag: Use type-safe way to extract feature flagsPatrick Steinhardt
To extract feature flags from the current context you can call the `AllFlags()` function. Just from looking at that function's name it's not clear though what it returns. As it turns out, it returns the flag as plain strings in the format of "${flag_name}:${flag_value}". This format is quite inaccessible to callers given that they'd have to manually split name and value and then also know to parse the value. This makes for an easy-to-misuse interface. Replace `AllFlags()` with a new type-safe `FromContext()` function that returns a map of `FeatureFlag`s mapped to their respective value. Like this it's immediately clear what you obtain and enjoy all the comfort of using the various functions on the feature flag itself. Refactor callers to use this new function.
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.
2021-12-14tests: Convert to use testhelper contextsPatrick Steinhardt
We're about to disallow use of "normal" contexts created via the `context` package given that they do not perform sanity checks for feature flags. Instead, contexts should be created via the testhelper package. Convert tests to use the testhelper context.
2021-12-14cache: Rework keyer tests to be independentPatrick Steinhardt
The keyer tests are all dependent on each other, and furthermore they're written in terms of one long test. This makes it hard to see the different parts we're trying to test, and furthermore it makes it harder than necessary to refactor those tests. Split up these tests into several subtests and have each of them use a separate cache such that there can be no interdependencies.
2021-12-10cache: Get rid of short timeoutsPatrick Steinhardt
Refactor the code to avoid timeouts. Unfortunately, there is no way right now to verify that the cache walker did its thing, so we still have to use a timeout there. We hopefully avoid any flakiness though by setting a high timeout value.
2021-12-03featureflag: Consolidate feature flags context APIPatrick Steinhardt
Consolidate the feature flags context APIs such that we have the same set of functions for creating feature flags in incoming and outgoing contexts.
2021-10-07cache: Add ability to stop disk walkersPatrick Steinhardt
The disk cache spawns a set of walkers which regularly walk the cache to check for cache members which are older than a given threshold. These walkers currently cannot be stopped at all, leading to a Goroutine leakage in our tests. Implement a new `StopWalkers()` function which stops them and use it in our tests.
2021-10-07dontpanic: Refactor code to allow stopping of `GoForever()`Patrick Steinhardt
The dontpanic package provides a `GoForever()` function which allows the caller to run a function forever even if it panics. While this is a useful thing to have, the current design also causes leakage of Goroutines because we do not have a way to stop these functions even in the context of tests. Introduce a new `Forever` structure which now hosts the `Go()` function. Like this, we can also easily introduce a `Cancel()` function which causes us to abort execution of the function. Callers are not yet adjusted to make use of the `Cancel()` function.
2021-10-07testhelper: Unify setup of test suitesPatrick Steinhardt
Setup of a test package's main function is quite repetitive: we call a separate `testMain()` function such that we can use `defer` calls, this function calls `MustHaveNoChildProcess()` and `Configure()`, and then we return the result of `m.Run()`. This is almost always exactly the same, with some exceptions where we need to have additional setup code. Unify this code via a single `testhelper.Run()` function which does all of this. It allows us greater flexibility in the setup code such that we can easily perform additional validation after the tests without having to modify all callsites. Note that this change removes calls to the goleak package in some places. These will resurface in a later commit in this patch series, where we instead move this call into `testhelper.Run()` such that it is executed by default.
2021-09-20golangci: Disallow usage of "io/ioutil" packagePatrick Steinhardt
The "io/ioutil" package has been deprecated in Go 1.16 and thus shouldn't be used in our codebase anymore. Disallow its usage by adding the "depguard" linter with a single entry for this specific package. Note that we still use the package in some places where we used to rely on `ioutil.ReadDir()`'s old behaviour of stat'ting all directory entries. Conversion of these is not part of this patch series given that it would be a change in behaviour compared to all the other changes which aren't. Those sites are thus annotated with `nolint` directives.
2021-09-20global: Replace trivial cases of deprecated `ioutil.ReadDir()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. In addition to being moved into the os package, `ioutil.ReadDir()` was also changed to not stat(3P) all dir entries anymore. As a result, the caller now has to do so manually. This is a performance improvement in some cases where the caller didn't require any of the file information, but really only wanted to read the directory's entries. Adapt trivial usecases of `ioutil.ReadDir()` which do not require this information with usage of `os.ReadDir()`. This leaves a few callsites of the old `ioutil.ReadDir()` function for future conversion.
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.ReadAll()`Patrick Steinhardt
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.ReadAll()` with `io.ReadAll()` to adapt accordingly.
2021-09-07safe: Rename `CreateFileWriter()` to be more idiomaticPatrick Steinhardt
In Gitaly, constructors for structs are typically called `NewStruct()`. Rename `CreateFileWriter()` to `NewFileWriter()` to better match our coding style.
2021-08-31global: Reformat sources with gofumptPatrick Steinhardt
Reformat sources with gofumpt.
2021-08-05gittest: Rename `CloneRepoAtStorage()` to `CloneRepo()`Patrick Steinhardt
Rename `CloneRepoAtStorage()` to `CloneRepo()`. We always have storages available, and there are no other gittest functions to clone a repo anymore, so having the shorter name should suffice.
2021-08-05gittest: Drop cleanup function from `CloneRepoAtStorage()`Patrick Steinhardt
`CloneRepoAtStorage()` currently returns a cleanup function. Since Go has `t.Cleanup()`, this is considered bad style, so let's remove it and convert all callers.
2021-08-05gittest: Make relative path of `CloneRepoAtStorage` optionalPatrick Steinhardt
Most tests don't really care about the relative path of the repository that is to be created. Furthermore, manually specifying a relative path will lead to repository paths outside of our typicaly hashed storage paths, and as thus they don't really match what we'd see in production. Put the relative path into an optional `CloneRepoOpts` structure: if unset, we'll compute random hashed storage-style repository paths. Most callers are converted to not pass a relative path at all, while a small bunch of tests which relies on deterministic paths are converted to use the options struct.
2021-07-28lint: Fix deprecated import github.com/golang/protobuf/protoPavlo Strokov
The dependency github.com/golang/protobuf is deprecated and should be replaced with google.golang.org/protobuf. This change replaces usage of the proto package. The packages have incompatible API that is why the code changes were done to migrate. The exclusion rule removed from the golanci-lint tool configuration file to prevent future use of the deprecated package.
2021-07-22cache: Convert to use the locatorPatrick Steinhardt
Convert the cache package to use the locator interface to determine locations of cache and state directories. This will eventually allow us to get rid of the old interface.