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-08-21operations: Drop unused test setup with seed repositoryPatrick Steinhardt
The test setup fucntion `setupOperationsService()` both set up the service and a seeded repository. We have replaced all usages of it with its variant though that don't create a repository, making this function unused. Remove it and rename `setupOperationsServiceWithoutRepo()` to fill in its role.
2023-07-28operations: Implement SHA256 support for UserUpdateSubmodulesPatrick Steinhardt
Implement SHA256 support for UserUpdateSubmodules and start testing with this object format. Changelog: added
2023-07-12Don't assert repository path in TestUserUpdateSubmoduleSami Hiltunen
TestUserUpdateSubmodule is asserting the repository's path in an error message. This should be avoided as the repository path may change. Fix the test to not assert the exact repository path.
2023-06-29Merge branch 'pks-praefect-unify-errrepositorynotset' into 'master'Pavlo Strokov
praefect/coordinator: Unify ErrRepositoryNotSet errors with Gitaly See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5975 Merged-by: Pavlo Strokov <pstrokov@gitlab.com> Approved-by: Pavlo Strokov <pstrokov@gitlab.com> Reviewed-by: karthik nayak <knayak@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
2023-06-28operations: Remove Submodules in git feature flagJohn Cai
Now that the submodules implementation without Git2Go has been running in production for several weeks without issue, let's remove the feature flag.
2023-06-28praefect/coordinator: Unify ErrRepositoryNotSet errors with GitalyPatrick Steinhardt
The coordinator prefixes most of its errors with "repo scoped", which makes the errors mismatch those returned by Gitaly. Consequentially, Praefect does not act as an actually-transparent proxy. This can be painfully felt in our tests, where we need to distinguish between both errors. Drop the prefix and return the error directly to unify the errors that both Gitaly and Praefect would return.
2023-06-20localrepo: Enable WriteCommit to signJohn Cai
Teach the localrepo WriteCommit API to sign commits if a signing key is provided. Also adjust merge and submodule tests to test with the feature flag.
2023-06-12config/locator: Use ErrRepositoryNotSet errorsPatrick Steinhardt
The `ValidateRepository()` function of the `config.Locator` doesn't explicitly check whether the passed-in repository is set. And right now it doesn't need to because all RPCs use `service.ValidateRepository()` anyway to verify that the repository is indeed set. We're about to remove this helper in favor of `locator.ValidateRepository()` in a future patch series, at which point the locator would become exposed to any unset repositories. Explicitly handle unset repositories in the `config.Locator` and return the same error as `service.ValidateRepository()`. Refactor tests to check for `ErrRepositoryNotSet` explicitly and rename the error message in order to make sure that there cannot be any tests left that check for the old error message.
2023-05-31operations: Replace UserUpdateSubmodule implementation with tree helpersJohn Cai
Now that we have helpers for modifying tree entries, replace our existing git plumbing implementation with the TreeEntry Modify() helper behind a feature flag.
2023-05-22Merge branch 'jc/tree-entry-as-tree' into 'master'Patrick Steinhardt
localrepo: Add ability to read and write trees in memory See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5807 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Approved-by: Patrick Steinhardt <psteinhardt@gitlab.com> Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com> Reviewed-by: karthik nayak <knayak@gitlab.com> Co-authored-by: John Cai <jcai@gitlab.com>
2023-05-19localrepo: Turn TreeEntry into a tree data structureJohn Cai
Currently, a TreeEntry is a flat data structure in the sense that it represents a single entry but does not have any children. A git tree object has children though. Change this by adding an Entries member to the TreeEntry struct. This way, we can represent a real tree data structure. Also, add a GetTree() function that can get an entire tree. We can consolidate ListEntries() into GetTree().
2023-05-18Decouple production code from test protoMikhail Mazurskiy
WithInterceptedMetadata() uses testproto.ErrorMetadata, which is in a test-only package. This function is only used in tests so move it to testhelper and interceptors into testserver
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-03-27featureflag: Remove SubmoduleInGit feature flagJohn Cai
Remove the SubmoduleInGit feature flag, and associated call sites.
2023-03-21lstree: Move package to localrepoJohn Cai
The lstree package contains a helper for reading a tree. There is no reason why this code needs to be in its own package. In fact, this makes it harder when for instance, we might want to add code in the `localrepo` package that calls `ListEntries()` since it would result in a dependency cycle because `lstree` depends on `localrepo`. Move the code under `lstree` under `localrepo`, since that is the one stop shop for operations on local repositories.
2023-03-16lint: Fix manual quote interpolation offensesQuang-Minh Nguyen
This commit fixes manually quoted string interpolation with '%s' and "%s". Quoting this way doesn't escape special characters such as endline and makes debugging harder later. We encourage to use %q verb instead.
2023-03-07operations: Reimplement UserUpdateSubmodule using git plumbing commandsJohn Cai
Updating a submodule is simply updating the oid of the commit at the path. We can do this by manually rewriting trees and writing a new commit. If we impelement it this way, we don't need to rely on Git2Go.
2023-03-06Revert "Merge branch 'jc-submodule-in-git-fix' into 'master'"John Cai
This reverts merge request !5448
2023-03-04operations: Reimplement UserUpdateSubmodule using git plumbing commandsJohn Cai
Updating a submodule is simply updating the oid of the commit at the path. We can do this by manually rewriting trees and writing a new commit. If we impelement it this way, we don't need to rely on Git2Go.
2023-03-02lstree: Use localrepo.TreeEntry instead of lstree.EntryJohn Cai
There is no reason to keep two structs around that both represent a tree entry object. Now that we have `localrepo.TreeEntry`, added by 9fac9132, let's unify `lstree` to use `localrepo.TreeEntry` everywhere. To do so, we need to add a `Type` field to `localrepo.TreeEntry`.
2023-03-01Revert "Merge branch 'jc-submodule-in-git' into 'master'"Patrick Steinhardt
This reverts merge request !5046
2023-02-24operations: Reimplement UserUpdateSubmodule using git plumbing commandsJohn Cai
Updating a submodule is simply updating the oid of the commit at the path. We can do this by manually rewriting trees and writing a new commit. If we impelement it this way, we don't need to rely on Git2Go.
2023-02-02git: Include reason oid is invalid in errorWill Chandler
Previously `ValidateHex` returned a generic error message when an invalid string representation of a SHA1 or SHA256 oid was found. This gave no indication as to why the oid was rejected. Now that we are iterating over characters manually rather than using a regexp, we are in a position to provide users with more detail on what is invalid about the object ID. Introduce new error types to bubble this information up to users.
2023-01-10operations: Use `ExpectedOldOid` in `UserUpdateSubmodule`Karthik Nayak
If the clients provide the ExpectedOldOid in the request of UserUpdateSubmodule, we need to use this as the ref's current OID for updating the reference. This is directly fed to git-update-ref(1) where it'll exit with an error code if the current OID of the ref doesn't match the OID provided by us. This allows us to avoid any race conditions wherein the branch was updated concurrently by another process.
2023-01-10operations: Merge some of Test*UserUpdateSubmodule* testsKarthik Nayak
There are a few Test*UserUpdateSubmodule* tests which do similar things, but are outdated and use seeded repos. In preparation of the upcoming additions to UserUpdateSubmodule, let's merge these tests. This makes it easy to add new tests and also no longer uses seeded repos, making it easier to also migrate to SHA256.
2022-12-01testhelper: Convert `GitalyOrPraefectMessage` to use genericsPatrick Steinhardt
The helper function `GitalyOrPraefectMessage()` will return either one of two messages depending on whether we execute with Praefect as proxy or not. It is more generally useful than that though as we may also want to check other object types. And now that we can use generics it is needlessly tied to a specific object type. Convert the function to accept any objects as input by using generics and rename it to `GitalyOrPraefect()`.
2022-11-16operations: Standardize errors creationPavlo Strokov
Replace usage of status.Errorf() with helper.Err<StatusCode>f() to make error creation more standard. Replace fmt.Errorf() with errors.New() if used without a reason. Return Internal code in case of an unexpected operation failure instead of Undefined by using helper.ErrInternal(). Replace old %v with new %w for proper error wrapping. Check error type to convert it to the corresponding error code. Remove redundant prefix from error returned by RPC call.
2022-11-08testhelper: More descriptive name for GitalyOrPraefectPavlo Strokov
GitalyOrPraefect now renamed to GitalyOrPraefectMessage as it is more descriptive.
2022-11-08service/operations: Improve validation of inputPavlo Strokov
Gitaly should return the same error for all RPCs where the Repository input parameter is missing. Input validation code extracted into separate function where it makes sense. The test coverage extended to cover changed code. The error verification is done not only for the code, but for the message as well. It gives us confidence that a proper path is tested.
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-08-05lstree: Inject the object hash used to parse tree entriesPatrick Steinhardt
Inject the object hash used to parse tree entries so that the tree entry parser can easily support parsing both SHA1 and SHA256 tree entries. For the time being all callers just inject SHA1. They will be converted over time to inject the correct value.
2022-07-20git: Move `ZeroOID` into `ObjectHash` structurePatrick Steinhardt
Move the `ZeroOID` variable into the `ObjectHash` structure to make it dependent on the hash function used.
2022-07-20git: Move `NewObjectIDFromHex()` into `ObjectHash` structurePatrick Steinhardt
Move the `NewObjectIDFromHex()` function into the `ObjectHash` structure to make it dependent on the hash function used.
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-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-02-01Amend most operation service tests to create repos through the APISami Hiltunen
This commit amends most of the operations service's test to create the test state through the API. This better matches the production scenario and allows for Praefect to create the metadata it would create in real setups. Most of the replacements are straight forward but some tests rely on working trees. As Gitaly does not support creating worktrees through the API, the worktrees are created after creating the repo through the API. TestUserCommitFiles was simplified a bit and its branch was changed as new repositories nowadays have main as their default branch.
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-20hook: Let custom hook scripts resolve Git via PATHPatrick Steinhardt
Custom hook scripts used in tests which use Git currently have the fully qualified Git path injected into them such that we are sure that the correct Git version is used. This was required until now given that we didn't inject a PATH environment variable which had the correct Git version prepended to it. As a result, we'd have executed the wrong Git executables in these scripts, which would typically be our intercepting Git wrappers in `internal/testhelper/testdata/home/bin`. Now that we do properly set up PATH, this workaround isn't needed anymore. Quite the reverse: the fact that we injected the full Git path into these scripts only obscured the fact that we didn't set up the environment as expected. Adapt tests to always resolve Git via PATH to assert that we pick up the correct executables.
2021-12-06testhelper: Rename `RequireGrpcError()` to `RequireGrpcCode()`Patrick Steinhardt
The `RequireGrpcError()` helper function misleadingly doesn't check the error for equality, but instead only verifies that the error has the expected gRPC code. Rename the function to `RequireGrpcCode()` to clarify this.
2021-11-10lstree: Convert tree entries to have typed object IDsPatrick Steinhardt
Tree entries host the object ID of the entry as a normal string even though we nowadays try to use `git.ObjectID`s instead. Convert the struct to use the latter to improve type safety and make available helper functions to convert these IDs as required.
2021-09-06updateref: Fix quarantine directory being migrated too latePatrick Steinhardt
When we have a quarantine directory in place, then we migrate its objects into the main object database after we have successfully voted on the ref update via the reference-transaction hook. Most notably, we do so _after_ we have executed the update hook. This is different from what Git is doing, which will migrate objects after the pre-receive has successfully executed. The result is that the update hook runs with a wrong environment. This hasn't been much of an issue until now: we don't really use the update hook ourselves, and custom hooks would have envvars set up such that it can find quarantined objects. It will become an issue when we fix our locking: we want to lock the ref update before doing the "prepared" vote, but do not yet have all objects available in the main object database. Fix the issue by aligning our semantics with what Git is doing, which is to migrate objects directly after the pre-receive hook. Changelog: fixed
2021-08-30updateref: Generalize `PreReceiveError` according to its usagePatrick Steinhardt
When any of the hooks fails to execute in our `UpdaterWithHooks`, then we return a `PreReceiveError` to the caller. This is quite misleading though: we not only execute the pre-receive hook, but also others, and they all return the same error. Refactor the error to instead be a `HookError`. While at it, we also embed stdout and stderr in the error such that it can handle generation of the error message itself instead of using `hookErrorMessage()`, and implement `Unwrap()` such that we can use `errors.As()` to retrieve the embedded error. This will be used at a later point to distinguish `HookError`s and `NotAllowedError`s.
2021-08-24quarantine: Always enable use of quarantine directoriesPatrick Steinhardt
Quarantine directories have been introduced for two reasons: first they are a correctness fix, where new objects don't end up in the target repo in case the request fails. And second, they allow us to speed up access checks enumerating new objects direcytl via the quarantine directory. Quarantine directories have been tested since August 9th in production now without any issues and can thus be deemed stable. Remove the feature flags to make them generally available. Changelog: performance
2021-08-06operations: Support object quarantine in UserUpdateSubmodulePatrick Steinhardt
Implement support for object quarantine directories in UserUpdateSubmodule.
2021-08-05gittest: Merge initialization of repos into a single functionPatrick Steinhardt
There's two different functions to initialize empty repositories: `InitBareRepoAt()` and `InitRepoWithWorktreeAtStorage()`. Both do the same, except that they either create a bare repository or not. Merge both into a single function `InitRepo()`. In order to serve both purposes, they take an optional `InitRepoOpts` structure with a single `WithWorktree` parameter.
2021-07-29lint: Fix deprecated import github.com/golang/protobuf/ptypesPavlo Strokov
The dependency github.com/golang/protobuf is deprecated and should be replaced with google.golang.org/protobuf. This change replaces usage of the ptypes package. The replacement packages has a different structure and it requires code changes to be done to migrate. The exclusion rules removed from the golanci-lint tool configuration file to prevent future use of the deprecated package.
2021-07-06Merge branch 'ps-parallel-test-run' into 'master'Sami Hiltunen
Parallel run of the tests See merge request gitlab-org/gitaly!3500
2021-07-01fix: Set operations timezone by UserBaodong
Previously, the time of Web GUI Git operations is set by `time.Now()` or `ptypes.Timestamp`, and the time zone (system local or UTC) is not what we expected. This commit corrects the timezone of the operation according to the User's time zone. Changelog: fixed
2021-06-29Parallel execution of the tests in the operations packagePavlo Strokov
To speed up execution of the tests we mark them allowed to run in parallel by calling t.Parallel(). As a first step we mark for parallel execution only upper-level test and no sub-tests.
2021-05-27Create module v14 gitaly versionPavlo Strokov
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