Age | Commit message (Collapse) | Author |
|
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.
|
|
With Go 1.16, the ioutil package was deprecated. Replace our usage of
`ioutil.TempFile()` with `os.CreateTemp()` to adapt accordingly.
|
|
With Go 1.16, the ioutil package was deprecated. Replace our usage of
`ioutil.ReadFile()` with `os.ReadFile()` to adapt accordingly.
|
|
In Gitaly, constructors for structs are typically called `NewStruct()`.
Rename `CreateFileWriter()` to `NewFileWriter()` to better match our
coding style.
|
|
Reformat sources with gofumpt.
|
|
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.
|
|
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.
|
|
Except for a single use in Praefec's tests, the "storage" module is only
used by Gitaly. Despite that, it's still located at `internal/storage`
and thus indicates that it may be a generic component for reuse.
Move it into `internal/gitaly` to clarify that it is indeed an
implementation detail of Gitaly, only.
|
|
The new "v14" version of the Gitaly module is named to match
the next GitLab release. The module versioning is needed in
order to pull gitaly as a dependency in other projects. The
change updates all imports to include v14 version. The go.mod
file was modified as well after go mod tidy execution. And
the changes in dependency licenses are reflected in the NOTICE
file.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3177
|
|
The `Cache` structure is now the single gatekeeper to interact with disk
caches. As such, we can use it to host all counters and get rid of the
global metric variables.
|
|
Now that the `Cache` structure is the only interface external callers
interact with, let's make the `LeaseKeyer` structure internal to the
cache package.
|
|
The cache LeaseKeyer needs to be able to resolve storage locations,
which is currently done via the global `config.Config` variable. This
commit converts it to instead use the locator, which is now available
starting with the preceding commit.
|
|
The cache LeaseKeyer needs to be able to resolve storage locations in
order to identify where temporary data shall be stored. This is
currently done via the global `config.Config`, which we're slowly
getting rid of.
This commit injects a locator into the LeaseKeyer such that we can get
rid of the global config dependency in a subsequent commit.
|
|
The LeaseKeyer structure is currently initialized ad-hoc in all
locations. This has been fine for now as the structure hasn't got any
members anyway. But we're about to add a locator to it, and continuing
to use struct initialization directly would not result in any hints by
the compiler that something has changed.
Let's prepare the code for the added member by introducing a constructor
and convert all call sites to use it.
|
|
We're currently using "%s" and "%v" to format errors, which is
considered to be bad style since Go 1.13 introduced new-style error
handling. Let's convert those formatting directives to "%w" to fix this
code smell and silence the linter.
|
|
Since the introduction of Praefect, our code layout started to become
confusing: while Praefect code lives in `internal/praefect`,
Gitaly-specific code is all over the place and not neatly singled out.
This makes it hard at times to tell apart Praefect- and Gitaly-specific
from generic code.
To improve the situation, this commit thus moves most of the server
specific code into a new `internal/gitaly` package. Currently, this is
the `internal/config`, `internal/server`, `internal/service` and
`internal/rubyserver` packages, which are all main components of Gitaly.
The move was realized with the following script:
#!/bin/sh
mkdir -p internal/gitaly
git mv internal/{config,server,service,rubyserver} internal/gitaly/
find . -name '*.go' -exec sed -i \
-e 's|gitlab-org/gitaly/internal/rubyserver|gitlab-org/gitaly/internal/gitaly/rubyserver|' \
-e 's|gitlab-org/gitaly/internal/server|gitlab-org/gitaly/internal/gitaly/server|' \
-e 's|gitlab-org/gitaly/internal/service|gitlab-org/gitaly/internal/gitaly/service|' \
-e 's|gitlab-org/gitaly/internal/config|gitlab-org/gitaly/internal/gitaly/config|' {} \;
In addition to that, some minor adjustments were needed for tests which
used relative paths.
|
|
Uses a struct for feature flags so there can be consistent behavior
around enabled by default.
|
|
Removes dependency on the global var config.Config to
detect location of the repository of storage at the
filesystem.
Locator interface includes set of methods from helper
package that are use in the services to get location of
the repository.
Implementation of the interface is injected into the
context via tags mechanism.
In order to break cyclic dependencies some of other funcs
was also moved.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
|
|
Currently relative paths are validated against path traversals although
in an incomplete manner. While relative paths with traversals do not cause
problems for Gitaly in itself, we need be sure that every path accessed lies
within the storage directories to ensure RPC callers can't access arbitrary
paths. This commit replaces the path traversal checks by checking that the
relative paths refer to paths within the root of the storage or the storage
root itself.
|
|
|
|
lint must use Go1.13 as it is highest supported version.
Fix deprecated use of `grpc_logrus.Extract`.
New linters introduced and replacement of old ones in favor
of new ones with same purpose.
Fix of new linter errors.
|
|
|
|
This adds an additional log message that will improve visibility of
whether the diskcache is serving stale data or not. The "freshness" of
the cache is determined by the repo's cache state file. The contents of
this file will now be logged whenever it is updated.
Additionally, the path of the cached response on disk will be logged
each time the diskcache is used. This can be used to help determine if
stale data is being served after the cache is expected to be invalid.
Each time the state file changes, we expect a new request file path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|