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
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-06-18 19:05:12 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-06-18 19:05:12 +0300
commit73a98c32524740eb6c9f6289b79170dceb109711 (patch)
tree69dccede6f433d4375f772b63fd5c8416284b3dd
parent73f8a828a72e0e6a3be80820fcde69345d1f2c09 (diff)
Remove dependency on global var to detect repo location
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 used in the services to get location of the repository. Implementation of the interface needs to be injected into each service that requires it. In order to break cyclic dependencies some of other funcs was also moved. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r--NOTICE214
-rw-r--r--go.mod2
-rw-r--r--go.sum14
-rw-r--r--internal/git/objectpool/clone_test.go5
-rw-r--r--internal/git/objectpool/fetch.go3
-rw-r--r--internal/git/objectpool/fetch_test.go16
-rw-r--r--internal/git/objectpool/pool.go26
-rw-r--r--internal/git/objectpool/pool_test.go29
-rw-r--r--internal/git/objectpool/proto.go9
-rw-r--r--internal/git/objectpool/testhelper_test.go3
-rw-r--r--internal/middleware/locator/locator.go77
-rw-r--r--internal/praefect/helper_test.go4
-rw-r--r--internal/praefect/replicator_test.go11
-rw-r--r--internal/server/server.go5
-rw-r--r--internal/service/commit/testhelper_test.go3
-rw-r--r--internal/service/diff/testhelper_test.go3
-rw-r--r--internal/service/internalgitaly/testhelper_test.go3
-rw-r--r--internal/service/namespace/testhelper_test.go3
-rw-r--r--internal/service/objectpool/alternates_test.go3
-rw-r--r--internal/service/objectpool/create.go8
-rw-r--r--internal/service/objectpool/create_test.go7
-rw-r--r--internal/service/objectpool/fetch_into_object_pool.go2
-rw-r--r--internal/service/objectpool/fetch_into_object_pool_test.go10
-rw-r--r--internal/service/objectpool/get.go2
-rw-r--r--internal/service/objectpool/get_test.go3
-rw-r--r--internal/service/objectpool/link.go4
-rw-r--r--internal/service/objectpool/link_test.go17
-rw-r--r--internal/service/objectpool/reduplicate_test.go3
-rw-r--r--internal/service/objectpool/server.go6
-rw-r--r--internal/service/objectpool/testhelper_test.go4
-rw-r--r--internal/service/operations/testhelper_test.go2
-rw-r--r--internal/service/register.go7
-rw-r--r--internal/service/repository/clone_from_pool.go8
-rw-r--r--internal/service/repository/clone_from_pool_internal.go8
-rw-r--r--internal/service/repository/clone_from_pool_internal_test.go3
-rw-r--r--internal/service/repository/fetch_remote_test.go2
-rw-r--r--internal/service/repository/replicate_test.go4
-rw-r--r--internal/service/repository/search_files_test.go4
-rw-r--r--internal/service/repository/server.go6
-rw-r--r--internal/service/repository/testhelper_test.go2
-rw-r--r--internal/service/server/info_test.go2
-rw-r--r--internal/service/smarthttp/inforefs_test.go2
-rw-r--r--internal/service/smarthttp/receive_pack_test.go2
-rw-r--r--internal/service/ssh/receive_pack_test.go2
-rw-r--r--internal/testhelper/testhelper.go31
-rw-r--r--internal/testhelper/testserver.go2
46 files changed, 148 insertions, 438 deletions
diff --git a/NOTICE b/NOTICE
index 307e15516..e1f52bd1d 100644
--- a/NOTICE
+++ b/NOTICE
@@ -926,207 +926,27 @@ THE SOFTWARE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LICENSE - github.com/opentracing/opentracing-go
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- &#34;License&#34; shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- &#34;Licensor&#34; shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- &#34;Legal Entity&#34; shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- &#34;control&#34; means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- &#34;You&#34; (or &#34;Your&#34;) shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- &#34;Source&#34; form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- &#34;Object&#34; form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- &#34;Work&#34; shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- &#34;Derivative Works&#34; shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- &#34;Contribution&#34; shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, &#34;submitted&#34;
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as &#34;Not a Contribution.&#34;
-
- &#34;Contributor&#34; shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a &#34;NOTICE&#34; text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an &#34;AS IS&#34; BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets &#34;{}&#34;
- replaced with your own identifying information. (Don&#39;t include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same &#34;printed page&#34; as the copyright notice for easier
- identification within third-party archives.
+The MIT License (MIT)
- Copyright 2016 The OpenTracing Authors
+Copyright (c) 2016 The OpenTracing Authors
- Licensed under the Apache License, Version 2.0 (the &#34;License&#34;);
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the &#34;Software&#34;), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
- http://www.apache.org/licenses/LICENSE-2.0
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an &#34;AS IS&#34; BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+THE SOFTWARE IS PROVIDED &#34;AS IS&#34;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LICENSE - github.com/pmezard/go-difflib/difflib
diff --git a/go.mod b/go.mod
index 70a1ee642..c9581053b 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
github.com/getsentry/sentry-go v0.5.1
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
- github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
+ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/kelseyhightower/envconfig v1.3.0
github.com/lib/pq v1.2.0
diff --git a/go.sum b/go.sum
index 1dfd76d7b..c91a01b46 100644
--- a/go.sum
+++ b/go.sum
@@ -87,9 +87,7 @@ github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
-github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
-github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
@@ -108,8 +106,6 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
-github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
-github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -150,8 +146,6 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
-github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 h1:0IKlLyQ3Hs9nDaiK5cSHAGmcQEIC8l2Ts1u6x5Dfrqg=
-github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -187,7 +181,6 @@ github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6i
github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0=
github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM=
github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
-github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
@@ -249,8 +242,6 @@ github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
-github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
-github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/otiai10/copy v1.0.1 h1:gtBjD8aq4nychvRZ2CyJvFWAw0aja+VHazDdruZKGZA=
github.com/otiai10/copy v1.0.1/go.mod h1:8bMCJrAqOtN/d9oyh5HR7HhLQMvcGMpGdwRDYsfOCHc=
github.com/otiai10/copy v1.0.1/go.mod h1:8bMCJrAqOtN/d9oyh5HR7HhLQMvcGMpGdwRDYsfOCHc=
@@ -373,10 +364,6 @@ go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
-go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
-go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
-go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
-go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
@@ -474,7 +461,6 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/internal/git/objectpool/clone_test.go b/internal/git/objectpool/clone_test.go
index e18940aba..89cd72143 100644
--- a/internal/git/objectpool/clone_test.go
+++ b/internal/git/objectpool/clone_test.go
@@ -5,6 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)
@@ -15,7 +16,7 @@ func TestClone(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
err = pool.clone(ctx, testRepo)
@@ -33,7 +34,7 @@ func TestCloneExistingPool(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
err = pool.clone(ctx, testRepo)
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index 44c278762..9ebc8c231 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -17,7 +17,6 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/internal/git/updateref"
- "gitlab.com/gitlab-org/gitaly/internal/middleware/locator"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
@@ -32,7 +31,7 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *gitalypb.Repos
return err
}
- originPath, err := locator.GetFromCtx(ctx).GetPath(origin)
+ originPath, err := o.locator.GetPath(origin)
if err != nil {
return err
diff --git a/internal/git/objectpool/fetch_test.go b/internal/git/objectpool/fetch_test.go
index 811a51b9c..3b473c6e2 100644
--- a/internal/git/objectpool/fetch_test.go
+++ b/internal/git/objectpool/fetch_test.go
@@ -18,14 +18,12 @@ func TestFetchFromOriginDangling(t *testing.T) {
source, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- pool, err := NewObjectPool(source.StorageName, testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), source.StorageName, testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
ctx, cancel := testhelper.Context()
defer cancel()
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
require.NoError(t, pool.FetchFromOrigin(ctx, source), "seed pool")
const (
@@ -92,14 +90,12 @@ func TestFetchFromOriginDeltaIslands(t *testing.T) {
source, sourcePath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- pool, err := NewObjectPool(source.StorageName, testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), source.StorageName, testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
ctx, cancel := testhelper.Context()
defer cancel()
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
require.NoError(t, pool.FetchFromOrigin(ctx, source), "seed pool")
require.NoError(t, pool.Link(ctx, source))
@@ -120,14 +116,12 @@ func TestFetchFromOriginBitmapHashCache(t *testing.T) {
source, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- pool, err := NewObjectPool(source.StorageName, testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), source.StorageName, testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
ctx, cancel := testhelper.Context()
defer cancel()
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
require.NoError(t, pool.FetchFromOrigin(ctx, source), "seed pool")
packDir := filepath.Join(pool.FullPath(), "objects/pack")
@@ -151,15 +145,13 @@ func TestFetchFromOriginRefUpdates(t *testing.T) {
source, sourcePath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- pool, err := NewObjectPool(source.StorageName, testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), source.StorageName, testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
poolPath := pool.FullPath()
ctx, cancel := testhelper.Context()
defer cancel()
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
require.NoError(t, pool.FetchFromOrigin(ctx, source), "seed pool")
oldRefs := map[string]string{
diff --git a/internal/git/objectpool/pool.go b/internal/git/objectpool/pool.go
index 30cfa4eea..96ead6987 100644
--- a/internal/git/objectpool/pool.go
+++ b/internal/git/objectpool/pool.go
@@ -14,7 +14,6 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/helper"
- "gitlab.com/gitlab-org/gitaly/internal/middleware/locator"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
@@ -33,6 +32,7 @@ const ErrInvalidPoolDir errString = "invalid object pool directory"
// live in a pool in a distinct repository which is used as an alternate object
// store for other repositories.
type ObjectPool struct {
+ locator storage.Locator
storageName string
storagePath string
@@ -42,7 +42,7 @@ type ObjectPool struct {
// NewObjectPool will initialize the object with the required data on the storage
// shard. Relative path is validated to match the expected naming and directory
// structure. If the shard cannot be found, this function returns an error.
-func NewObjectPool(storageName, relativePath string) (pool *ObjectPool, err error) {
+func NewObjectPool(locator storage.Locator, storageName, relativePath string) (pool *ObjectPool, err error) {
storagePath, err := helper.GetStorageByName(storageName)
if err != nil {
return nil, err
@@ -53,7 +53,7 @@ func NewObjectPool(storageName, relativePath string) (pool *ObjectPool, err erro
return nil, ErrInvalidPoolDir
}
- return &ObjectPool{storageName, storagePath, relativePath}, nil
+ return &ObjectPool{locator: locator, storageName: storageName, storagePath: storagePath, relativePath: relativePath}, nil
}
// GetGitAlternateObjectDirectories for object pools are empty, given pools are
@@ -140,7 +140,7 @@ func (o *ObjectPool) Init(ctx context.Context) (err error) {
}
// FromRepo returns an instance of ObjectPool that the repository points to
-func FromRepo(ctx context.Context, repo *gitalypb.Repository) (*ObjectPool, error) {
+func FromRepo(locator storage.Locator, repo *gitalypb.Repository) (*ObjectPool, error) {
dir, err := getAlternateObjectDir(repo)
if err != nil {
return nil, err
@@ -150,12 +150,17 @@ func FromRepo(ctx context.Context, repo *gitalypb.Repository) (*ObjectPool, erro
return nil, nil
}
- altPathRelativeToStorage, err := objectPathRelativeToStorage(ctx, repo, dir)
+ repoPath, err := locator.GetPath(repo)
if err != nil {
return nil, err
}
- return NewObjectPool(repo.GetStorageName(), filepath.Dir(altPathRelativeToStorage))
+ altPathRelativeToStorage, err := objectPathRelativeToStorage(repo.GetStorageName(), dir, repoPath)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewObjectPool(locator, repo.GetStorageName(), filepath.Dir(altPathRelativeToStorage))
}
var (
@@ -206,13 +211,8 @@ func getAlternateObjectDir(repo *gitalypb.Repository) (string, error) {
// objectPathRelativeToStorage takes an object path that's relative to a repository's object directory
// and returns the path relative to the storage path of the repository.
-func objectPathRelativeToStorage(ctx context.Context, repo *gitalypb.Repository, path string) (string, error) {
- repoPath, err := locator.GetFromCtx(ctx).GetPath(repo)
- if err != nil {
- return "", err
- }
-
- storagePath, err := helper.GetStorageByName(repo.GetStorageName())
+func objectPathRelativeToStorage(storageName, path, repoPath string) (string, error) {
+ storagePath, err := helper.GetStorageByName(storageName)
if err != nil {
return "", err
}
diff --git a/internal/git/objectpool/pool_test.go b/internal/git/objectpool/pool_test.go
index 9fc619cc4..23166a6f9 100644
--- a/internal/git/objectpool/pool_test.go
+++ b/internal/git/objectpool/pool_test.go
@@ -15,24 +15,22 @@ import (
)
func TestNewObjectPool(t *testing.T) {
- _, err := NewObjectPool("default", testhelper.NewTestObjectPoolName(t))
+ _, err := NewObjectPool(nil, "default", testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
- _, err = NewObjectPool("mepmep", testhelper.NewTestObjectPoolName(t))
+ _, err = NewObjectPool(nil, "mepmep", testhelper.NewTestObjectPoolName(t))
require.Error(t, err, "creating pool in storage that does not exist should fail")
}
func TestNewFromRepoSuccess(t *testing.T) {
ctx, cancel := testhelper.Context()
-
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
relativePoolPath := testhelper.NewTestObjectPoolName(t)
+ locator := config.NewLocator(config.Config)
- pool, err := NewObjectPool(testRepo.GetStorageName(), relativePoolPath)
+ pool, err := NewObjectPool(locator, testRepo.GetStorageName(), relativePoolPath)
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -40,23 +38,20 @@ func TestNewFromRepoSuccess(t *testing.T) {
require.NoError(t, pool.Create(ctx, testRepo))
require.NoError(t, pool.Link(ctx, testRepo))
- poolFromRepo, err := FromRepo(ctx, testRepo)
+ poolFromRepo, err := FromRepo(locator, testRepo)
require.NoError(t, err)
require.Equal(t, relativePoolPath, poolFromRepo.relativePath)
require.Equal(t, pool.storageName, poolFromRepo.storageName)
}
func TestNewFromRepoNoObjectPool(t *testing.T) {
- ctx, cancel := testhelper.Context()
- defer cancel()
-
- ctx = testhelper.CtxWithLocator(ctx, config.NewLocator(config.Config))
-
testRepo, testRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
+ locator := config.NewLocator(config.Config)
+
// no alternates file
- poolFromRepo, err := FromRepo(ctx, testRepo)
+ poolFromRepo, err := FromRepo(locator, testRepo)
require.Equal(t, ErrAlternateObjectDirNotExist, err)
require.Nil(t, poolFromRepo)
@@ -89,7 +84,7 @@ func TestNewFromRepoNoObjectPool(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
alternateFilePath := filepath.Join(testRepoPath, "objects", "info", "alternates")
require.NoError(t, ioutil.WriteFile(alternateFilePath, tc.fileContent, 0644))
- poolFromRepo, err := FromRepo(ctx, testRepo)
+ poolFromRepo, err := FromRepo(locator, testRepo)
require.Equal(t, tc.expectedErr, err)
require.Nil(t, poolFromRepo)
@@ -107,7 +102,7 @@ func TestCreate(t *testing.T) {
masterSha := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "show-ref", "master")
- pool, err := NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
err = pool.Create(ctx, testRepo)
@@ -140,7 +135,7 @@ func TestCreateSubDirsExist(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
defer pool.Remove(ctx)
require.NoError(t, err)
@@ -161,7 +156,7 @@ func TestRemove(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
err = pool.Create(ctx, testRepo)
diff --git a/internal/git/objectpool/proto.go b/internal/git/objectpool/proto.go
index 19417485e..1e69f5a50 100644
--- a/internal/git/objectpool/proto.go
+++ b/internal/git/objectpool/proto.go
@@ -1,10 +1,13 @@
package objectpool
-import "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
+import (
+ "gitlab.com/gitlab-org/gitaly/internal/storage"
+ "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
+)
// FromProto returns an object pool object from a git repository object
-func FromProto(o *gitalypb.ObjectPool) (*ObjectPool, error) {
- return NewObjectPool(o.GetRepository().GetStorageName(), o.GetRepository().GetRelativePath())
+func FromProto(locator storage.Locator, o *gitalypb.ObjectPool) (*ObjectPool, error) {
+ return NewObjectPool(locator, o.GetRepository().GetStorageName(), o.GetRepository().GetRelativePath())
}
// ToProto returns a new struct that is the protobuf definition of the ObjectPool
diff --git a/internal/git/objectpool/testhelper_test.go b/internal/git/objectpool/testhelper_test.go
index e60ca14f8..e5dde7cf5 100644
--- a/internal/git/objectpool/testhelper_test.go
+++ b/internal/git/objectpool/testhelper_test.go
@@ -6,6 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)
@@ -15,7 +16,7 @@ func TestMain(m *testing.M) {
}
func NewTestObjectPool(ctx context.Context, t *testing.T, storageName string) (*ObjectPool, func()) {
- pool, err := NewObjectPool(storageName, testhelper.NewTestObjectPoolName(t))
+ pool, err := NewObjectPool(config.NewLocator(config.Config), storageName, testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
return pool, func() {
require.NoError(t, pool.Remove(ctx))
diff --git a/internal/middleware/locator/locator.go b/internal/middleware/locator/locator.go
deleted file mode 100644
index 36785eaa1..000000000
--- a/internal/middleware/locator/locator.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package locator
-
-import (
- "context"
-
- grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
- "gitlab.com/gitlab-org/gitaly/internal/storage"
- "google.golang.org/grpc"
-)
-
-const (
- instanceKey = "locator.instance.key"
-)
-
-// UnaryInterceptor returns a Unary Interceptor with provided locator.
-// It will be set into context with context tags.
-// GetFromCtx should be used to extract it from the context.
-func UnaryInterceptor(locator storage.Locator) func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
- return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
- SetAtCtx(ctx, locator)
- return handler(ctx, req)
- }
-}
-
-// StreamInterceptor returns a Stream Interceptor
-// It will be set into context with context tags.
-// GetFromCtx should be used to extract it from the context.
-func StreamInterceptor(locator storage.Locator) func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
- return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
- SetAtCtx(stream.Context(), locator)
- return handler(srv, stream)
- }
-}
-
-// SetAtCtx sets provided locator to the context using context tags.
-func SetAtCtx(ctx context.Context, locator storage.Locator) {
- tags := grpc_ctxtags.Extract(ctx)
- if tags.Has(instanceKey) {
- panic("locator is already set for this context")
- }
-
- if tags == grpc_ctxtags.NoopTags {
- panic("locator can be set without context tags support")
- }
-
- tags.Set(instanceKey, locator)
-}
-
-// IsAtCtx checks if locator is set at the context and it is not a nil.
-func IsAtCtx(ctx context.Context) bool {
- tags := grpc_ctxtags.Extract(ctx)
- if !tags.Has(instanceKey) {
- return false
- }
-
- _, ok := tags.Values()[instanceKey].(storage.Locator)
- return ok
-}
-
-// GetFromCtx returns locator from the passed in context.
-// If locator is not set this method will panic.
-// Please ensure you have added github.com/grpc-ecosystem/go-grpc-middleware/tags middleware
-// to support gRPC context based tags and a proper UnaryInterceptor | StreamInterceptor middleware
-// defined in this package.
-// If this error occurs in the test, you can use helper.CtxWithLocator function to inject
-// locator into the context.
-func GetFromCtx(ctx context.Context) storage.Locator {
- tags := grpc_ctxtags.Extract(ctx)
- if tags.Has(instanceKey) {
- locator, ok := tags.Values()[instanceKey].(storage.Locator)
- if locator != nil && ok {
- return locator
- }
- }
-
- panic("locator is not defined")
-}
diff --git a/internal/praefect/helper_test.go b/internal/praefect/helper_test.go
index b46feaff5..917c32de4 100644
--- a/internal/praefect/helper_test.go
+++ b/internal/praefect/helper_test.go
@@ -305,7 +305,7 @@ func realGitaly(storages []gconfig.Storage, authToken, internalSocketPath string
healthpb.HealthServer
}{
gitalyserver.NewServer(storages),
- repository.NewServer(RubyServer, internalSocketPath),
+ repository.NewServer(RubyServer, gconfig.NewLocator(gconfig.Config), internalSocketPath),
internalgitaly.NewServer(gconfig.Config.Storages),
health.NewServer(),
}
@@ -315,7 +315,7 @@ func runInternalGitalyServer(t testing.TB, storages []gconfig.Storage, token str
streamInt := []grpc.StreamServerInterceptor{auth.StreamServerInterceptor(internalauth.Config{Token: token})}
unaryInt := []grpc.UnaryServerInterceptor{auth.UnaryServerInterceptor(internalauth.Config{Token: token})}
- server := testhelper.NewTestGrpcServer(t, gconfig.Config, streamInt, unaryInt)
+ server := testhelper.NewTestGrpcServer(t, streamInt, unaryInt)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index 2c80cd293..b61c4d3a6 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -92,7 +92,7 @@ func TestProcessReplicationJob(t *testing.T) {
// create object pool on the source
objectPoolPath := testhelper.NewTestObjectPoolName(t)
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), objectPoolPath)
+ pool, err := objectpool.NewObjectPool(gitaly_config.NewLocator(gitaly_config.Config), testRepo.GetStorageName(), objectPoolPath)
require.NoError(t, err)
poolCtx, cancel := testhelper.Context()
@@ -335,7 +335,7 @@ func (m *mockRepositoryServer) RepackIncremental(ctx context.Context, in *gitaly
}
func runMockRepositoryServer(t *testing.T) (*mockRepositoryServer, string, func()) {
- server := testhelper.NewTestGrpcServer(t, gitaly_config.Cfg{}, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
@@ -787,10 +787,11 @@ func newReplicationService(tb testing.TB) (*grpc.Server, string) {
internalSocketName := gitaly_config.GitalyInternalSocketPath()
require.NoError(tb, os.RemoveAll(internalSocketName))
- svr := testhelper.NewTestGrpcServer(tb, gitaly_config.Config, nil, nil)
+ svr := testhelper.NewTestGrpcServer(tb, nil, nil)
- gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(RubyServer, internalSocketName))
- gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer())
+ locator := gitaly_config.NewLocator(gitaly_config.Config)
+ gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(RubyServer, locator, internalSocketName))
+ gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer(locator))
gitalypb.RegisterRemoteServiceServer(svr, remote.NewServer(RubyServer))
gitalypb.RegisterSSHServiceServer(svr, ssh.NewServer())
reflection.Register(svr)
diff --git a/internal/server/server.go b/internal/server/server.go
index 2be9d4ebf..243b387c6 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -19,7 +19,6 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/middleware/cache"
"gitlab.com/gitlab-org/gitaly/internal/middleware/cancelhandler"
"gitlab.com/gitlab-org/gitaly/internal/middleware/limithandler"
- "gitlab.com/gitlab-org/gitaly/internal/middleware/locator"
"gitlab.com/gitlab-org/gitaly/internal/middleware/metadatahandler"
"gitlab.com/gitlab-org/gitaly/internal/middleware/panichandler"
"gitlab.com/gitlab-org/gitaly/internal/middleware/sentryhandler"
@@ -85,7 +84,6 @@ func createNewServer(rubyServer *rubyserver.Server, gitlabAPI hook.GitlabAPI, cf
opts := []grpc.ServerOption{
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpc_ctxtags.StreamServerInterceptor(ctxTagOpts...),
- locator.StreamInterceptor(storageLocator),
grpccorrelation.StreamServerCorrelationInterceptor(), // Must be above the metadata handler
metadatahandler.StreamInterceptor,
grpc_prometheus.StreamServerInterceptor,
@@ -102,7 +100,6 @@ func createNewServer(rubyServer *rubyserver.Server, gitlabAPI hook.GitlabAPI, cf
)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpc_ctxtags.UnaryServerInterceptor(ctxTagOpts...),
- locator.UnaryInterceptor(storageLocator),
grpccorrelation.UnaryServerCorrelationInterceptor(), // Must be above the metadata handler
metadatahandler.UnaryInterceptor,
grpc_prometheus.UnaryServerInterceptor,
@@ -135,7 +132,7 @@ func createNewServer(rubyServer *rubyserver.Server, gitlabAPI hook.GitlabAPI, cf
server := grpc.NewServer(opts...)
- service.RegisterAll(server, cfg, rubyServer, gitlabAPI)
+ service.RegisterAll(server, cfg, rubyServer, gitlabAPI, storageLocator)
reflection.Register(server)
grpc_prometheus.Register(server)
diff --git a/internal/service/commit/testhelper_test.go b/internal/service/commit/testhelper_test.go
index c56931b42..16d3f1297 100644
--- a/internal/service/commit/testhelper_test.go
+++ b/internal/service/commit/testhelper_test.go
@@ -6,7 +6,6 @@ import (
"testing"
"github.com/golang/protobuf/ptypes/timestamp"
- "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -25,7 +24,7 @@ func testMain(m *testing.M) int {
}
func startTestServices(t testing.TB) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/service/diff/testhelper_test.go b/internal/service/diff/testhelper_test.go
index a7fc2451a..d3d32efd2 100644
--- a/internal/service/diff/testhelper_test.go
+++ b/internal/service/diff/testhelper_test.go
@@ -5,7 +5,6 @@ import (
"os"
"testing"
- "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -24,7 +23,7 @@ func testMain(m *testing.M) int {
}
func runDiffServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/service/internalgitaly/testhelper_test.go b/internal/service/internalgitaly/testhelper_test.go
index 9a1438834..bccec58af 100644
--- a/internal/service/internalgitaly/testhelper_test.go
+++ b/internal/service/internalgitaly/testhelper_test.go
@@ -4,7 +4,6 @@ import (
"net"
"testing"
- "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -13,7 +12,7 @@ import (
func runInternalGitalyServer(t *testing.T, srv gitalypb.InternalGitalyServer) (*grpc.Server, string) {
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- grpcServer := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
listener, err := net.Listen("unix", serverSocketPath)
if err != nil {
diff --git a/internal/service/namespace/testhelper_test.go b/internal/service/namespace/testhelper_test.go
index 11b31d327..31a6cd00a 100644
--- a/internal/service/namespace/testhelper_test.go
+++ b/internal/service/namespace/testhelper_test.go
@@ -4,7 +4,6 @@ import (
"net"
"testing"
- "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -12,7 +11,7 @@ import (
)
func runNamespaceServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/service/objectpool/alternates_test.go b/internal/service/objectpool/alternates_test.go
index cba9ea7d5..b613a4a24 100644
--- a/internal/service/objectpool/alternates_test.go
+++ b/internal/service/objectpool/alternates_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ gconfig "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -26,7 +27,7 @@ func TestDisconnectGitAlternates(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
diff --git a/internal/service/objectpool/create.go b/internal/service/objectpool/create.go
index 39c8ddd65..407e56287 100644
--- a/internal/service/objectpool/create.go
+++ b/internal/service/objectpool/create.go
@@ -26,7 +26,7 @@ func (s *server) CreateObjectPool(ctx context.Context, in *gitalypb.CreateObject
return nil, errMissingOriginRepository
}
- pool, err := poolForRequest(in)
+ pool, err := s.poolForRequest(in)
if err != nil {
return nil, err
}
@@ -43,7 +43,7 @@ func (s *server) CreateObjectPool(ctx context.Context, in *gitalypb.CreateObject
}
func (s *server) DeleteObjectPool(ctx context.Context, in *gitalypb.DeleteObjectPoolRequest) (*gitalypb.DeleteObjectPoolResponse, error) {
- pool, err := poolForRequest(in)
+ pool, err := s.poolForRequest(in)
if err != nil {
return nil, err
}
@@ -59,7 +59,7 @@ type poolRequest interface {
GetObjectPool() *gitalypb.ObjectPool
}
-func poolForRequest(req poolRequest) (*objectpool.ObjectPool, error) {
+func (s *server) poolForRequest(req poolRequest) (*objectpool.ObjectPool, error) {
reqPool := req.GetObjectPool()
poolRepo := reqPool.GetRepository()
@@ -67,7 +67,7 @@ func poolForRequest(req poolRequest) (*objectpool.ObjectPool, error) {
return nil, errMissingPool
}
- pool, err := objectpool.NewObjectPool(poolRepo.GetStorageName(), poolRepo.GetRelativePath())
+ pool, err := objectpool.NewObjectPool(s.locator, poolRepo.GetStorageName(), poolRepo.GetRelativePath())
if err != nil {
if err == objectpool.ErrInvalidPoolDir {
return nil, errInvalidPoolDir
diff --git a/internal/service/objectpool/create_test.go b/internal/service/objectpool/create_test.go
index a70df5781..9d1fc788b 100644
--- a/internal/service/objectpool/create_test.go
+++ b/internal/service/objectpool/create_test.go
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -28,7 +29,7 @@ func TestCreate(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool("default", testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), "default", testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
poolReq := &gitalypb.CreateObjectPoolRequest{
@@ -75,7 +76,7 @@ func TestUnsuccessfulCreate(t *testing.T) {
defer cleanupFn()
validPoolPath := testhelper.NewTestObjectPoolName(t)
- pool, err := objectpool.NewObjectPool("default", validPoolPath)
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), "default", validPoolPath)
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -174,7 +175,7 @@ func TestDelete(t *testing.T) {
defer cleanupFn()
validPoolPath := testhelper.NewTestObjectPoolName(t)
- pool, err := objectpool.NewObjectPool("default", validPoolPath)
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), "default", validPoolPath)
require.NoError(t, err)
require.NoError(t, pool.Create(ctx, testRepo))
diff --git a/internal/service/objectpool/fetch_into_object_pool.go b/internal/service/objectpool/fetch_into_object_pool.go
index ad8d80854..e289dccd8 100644
--- a/internal/service/objectpool/fetch_into_object_pool.go
+++ b/internal/service/objectpool/fetch_into_object_pool.go
@@ -16,7 +16,7 @@ func (s *server) FetchIntoObjectPool(ctx context.Context, req *gitalypb.FetchInt
return nil, helper.ErrInvalidArgument(err)
}
- objectPool, err := objectpool.FromProto(req.GetObjectPool())
+ objectPool, err := objectpool.FromProto(s.locator, req.GetObjectPool())
if err != nil {
return nil, helper.ErrInvalidArgument(fmt.Errorf("object pool invalid: %v", err))
}
diff --git a/internal/service/objectpool/fetch_into_object_pool_test.go b/internal/service/objectpool/fetch_into_object_pool_test.go
index 425ea621f..a3bed54db 100644
--- a/internal/service/objectpool/fetch_into_object_pool_test.go
+++ b/internal/service/objectpool/fetch_into_object_pool_test.go
@@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ gconfig "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -34,7 +35,7 @@ func TestFetchIntoObjectPool_Success(t *testing.T) {
repoCommit := testhelper.CreateCommit(t, testRepoPath, t.Name(), &testhelper.CreateCommitOpts{Message: t.Name()})
- pool, err := objectpool.NewObjectPool("default", testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), "default", testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -87,7 +88,7 @@ func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool("default", testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), "default", testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -116,7 +117,8 @@ func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) {
}
func TestFetchIntoObjectPool_Failure(t *testing.T) {
- server := NewServer()
+ locator := gconfig.NewLocator(gconfig.Config)
+ server := NewServer(locator)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -124,7 +126,7 @@ func TestFetchIntoObjectPool_Failure(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool("default", testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(locator, "default", testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
diff --git a/internal/service/objectpool/get.go b/internal/service/objectpool/get.go
index 6a076f98b..c409ee869 100644
--- a/internal/service/objectpool/get.go
+++ b/internal/service/objectpool/get.go
@@ -15,7 +15,7 @@ func (s *server) GetObjectPool(ctx context.Context, in *gitalypb.GetObjectPoolRe
return nil, helper.ErrInternal(errors.New("repository is empty"))
}
- objectPool, err := objectpool.FromRepo(ctx, in.GetRepository())
+ objectPool, err := objectpool.FromRepo(s.locator, in.GetRepository())
if err != nil {
ctxlogrus.Extract(ctx).
diff --git a/internal/service/objectpool/get_test.go b/internal/service/objectpool/get_test.go
index 392758fd3..72eac88a5 100644
--- a/internal/service/objectpool/get_test.go
+++ b/internal/service/objectpool/get_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ gconfig "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -24,7 +25,7 @@ func TestGetObjectPoolSuccess(t *testing.T) {
relativePoolPath := testhelper.NewTestObjectPoolName(t)
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), relativePoolPath)
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), relativePoolPath)
require.NoError(t, err)
poolCtx, cancel := testhelper.Context()
diff --git a/internal/service/objectpool/link.go b/internal/service/objectpool/link.go
index 404691ebd..a62b7ec97 100644
--- a/internal/service/objectpool/link.go
+++ b/internal/service/objectpool/link.go
@@ -16,7 +16,7 @@ func (s *server) LinkRepositoryToObjectPool(ctx context.Context, req *gitalypb.L
return nil, status.Error(codes.InvalidArgument, "no repository")
}
- pool, err := poolForRequest(req)
+ pool, err := s.poolForRequest(req)
if err != nil {
return nil, err
}
@@ -37,7 +37,7 @@ func (s *server) UnlinkRepositoryFromObjectPool(ctx context.Context, req *gitaly
return nil, helper.ErrInvalidArgument(errors.New("no repository"))
}
- pool, err := poolForRequest(req)
+ pool, err := s.poolForRequest(req)
if err != nil {
return nil, helper.ErrInternal(err)
}
diff --git a/internal/service/objectpool/link_test.go b/internal/service/objectpool/link_test.go
index 99db8441c..122f02f6a 100644
--- a/internal/service/objectpool/link_test.go
+++ b/internal/service/objectpool/link_test.go
@@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ gconfig "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/helper"
@@ -29,7 +30,7 @@ func TestLink(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
require.NoError(t, pool.Remove(ctx), "make sure pool does not exist at start of test")
@@ -102,7 +103,7 @@ func TestLinkIdempotent(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
require.NoError(t, pool.Create(ctx, testRepo))
@@ -132,7 +133,7 @@ func TestLinkNoClobber(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -171,7 +172,7 @@ func TestLinkNoPool(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
// intentionally do not call pool.Create
defer pool.Remove(ctx)
@@ -206,7 +207,9 @@ func TestUnlink(t *testing.T) {
deletedRepo, deletedRepoPath, removeDeletedRepo := testhelper.NewTestRepo(t)
defer removeDeletedRepo()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ locator := gconfig.NewLocator(gconfig.Config)
+
+ pool, err := objectpool.NewObjectPool(locator, testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
@@ -217,7 +220,7 @@ func TestUnlink(t *testing.T) {
removeDeletedRepo()
testhelper.AssertPathNotExists(t, deletedRepoPath)
- pool2, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool2, err := objectpool.NewObjectPool(locator, testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
require.NoError(t, pool2.Create(ctx, testRepo), "create pool 2")
defer pool2.Remove(ctx)
@@ -315,7 +318,7 @@ func TestUnlinkIdempotent(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
require.NoError(t, pool.Create(ctx, testRepo))
diff --git a/internal/service/objectpool/reduplicate_test.go b/internal/service/objectpool/reduplicate_test.go
index d1d9f560c..2028971b1 100644
--- a/internal/service/objectpool/reduplicate_test.go
+++ b/internal/service/objectpool/reduplicate_test.go
@@ -5,6 +5,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ gconfig "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -24,7 +25,7 @@ func TestReduplicate(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(gconfig.NewLocator(gconfig.Config), testRepo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
defer pool.Remove(ctx)
require.NoError(t, pool.Create(ctx, testRepo))
diff --git a/internal/service/objectpool/server.go b/internal/service/objectpool/server.go
index b9456a0e5..022376bd3 100644
--- a/internal/service/objectpool/server.go
+++ b/internal/service/objectpool/server.go
@@ -1,14 +1,16 @@
package objectpool
import (
+ "gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
type server struct {
gitalypb.UnimplementedObjectPoolServiceServer
+ locator storage.Locator
}
// NewServer creates a new instance of a gRPC repo server
-func NewServer() gitalypb.ObjectPoolServiceServer {
- return &server{}
+func NewServer(locator storage.Locator) gitalypb.ObjectPoolServiceServer {
+ return &server{locator: locator}
}
diff --git a/internal/service/objectpool/testhelper_test.go b/internal/service/objectpool/testhelper_test.go
index 63a1dca1b..177ac055f 100644
--- a/internal/service/objectpool/testhelper_test.go
+++ b/internal/service/objectpool/testhelper_test.go
@@ -25,7 +25,7 @@ func testMain(m *testing.M) int {
}
func runObjectPoolServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
@@ -33,7 +33,7 @@ func runObjectPoolServer(t *testing.T) (*grpc.Server, string) {
t.Fatal(err)
}
- gitalypb.RegisterObjectPoolServiceServer(server, NewServer())
+ gitalypb.RegisterObjectPoolServiceServer(server, NewServer(config.NewLocator(config.Config)))
reflection.Register(server)
go server.Serve(listener)
diff --git a/internal/service/operations/testhelper_test.go b/internal/service/operations/testhelper_test.go
index b7f86f1e4..028cdd327 100644
--- a/internal/service/operations/testhelper_test.go
+++ b/internal/service/operations/testhelper_test.go
@@ -88,7 +88,7 @@ func runOperationServiceServerWithRubyServer(t *testing.T, ruby *rubyserver.Serv
gitalypb.RegisterOperationServiceServer(srv.GrpcServer(), &server{ruby: ruby})
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hook.NewServer(testhelper.GitlabAPIStub, config.Config.Hooks))
- gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(ruby, internalSocket))
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(ruby, config.NewLocator(config.Config), internalSocket))
gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer())
gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), commit.NewServer())
gitalypb.RegisterSSHServiceServer(srv.GrpcServer(), ssh.NewServer())
diff --git a/internal/service/register.go b/internal/service/register.go
index 81f73ed88..aef803736 100644
--- a/internal/service/register.go
+++ b/internal/service/register.go
@@ -22,6 +22,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/service/smarthttp"
"gitlab.com/gitlab-org/gitaly/internal/service/ssh"
"gitlab.com/gitlab-org/gitaly/internal/service/wiki"
+ "gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
@@ -52,7 +53,7 @@ var (
// RegisterAll will register all the known grpc services with
// the specified grpc service instance
-func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver.Server, gitlabAPI hook.GitlabAPI) {
+func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver.Server, gitlabAPI hook.GitlabAPI, locator storage.Locator) {
gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer))
gitalypb.RegisterCleanupServiceServer(grpcServer, cleanup.NewServer())
gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer())
@@ -60,7 +61,7 @@ func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer())
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(rubyServer))
gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer())
- gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer, config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer, locator, config.GitalyInternalSocketPath()))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer(
ssh.WithPackfileNegotiationMetrics(sshPackfileNegotiationMetrics),
))
@@ -71,7 +72,7 @@ func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver
gitalypb.RegisterConflictsServiceServer(grpcServer, conflicts.NewServer(rubyServer))
gitalypb.RegisterRemoteServiceServer(grpcServer, remote.NewServer(rubyServer))
gitalypb.RegisterServerServiceServer(grpcServer, server.NewServer(cfg.Storages))
- gitalypb.RegisterObjectPoolServiceServer(grpcServer, objectpool.NewServer())
+ gitalypb.RegisterObjectPoolServiceServer(grpcServer, objectpool.NewServer(locator))
gitalypb.RegisterHookServiceServer(grpcServer, hook.NewServer(gitlabAPI, cfg.Hooks))
gitalypb.RegisterInternalGitalyServer(grpcServer, internalgitaly.NewServer(cfg.Storages))
diff --git a/internal/service/repository/clone_from_pool.go b/internal/service/repository/clone_from_pool.go
index 3f0716239..29ff78f8f 100644
--- a/internal/service/repository/clone_from_pool.go
+++ b/internal/service/repository/clone_from_pool.go
@@ -16,7 +16,7 @@ func (s *server) CloneFromPool(ctx context.Context, req *gitalypb.CloneFromPoolR
return nil, helper.ErrInvalidArgument(err)
}
- if err := validateCloneFromPoolRequestRepositoryState(req); err != nil {
+ if err := s.validateCloneFromPoolRequestRepositoryState(req); err != nil {
return nil, helper.ErrInternal(err)
}
@@ -32,7 +32,7 @@ func (s *server) CloneFromPool(ctx context.Context, req *gitalypb.CloneFromPoolR
return nil, helper.ErrInternalf("fetch http remote: %v", err)
}
- objectPool, err := objectpool.FromProto(req.GetPool())
+ objectPool, err := objectpool.FromProto(s.locator, req.GetPool())
if err != nil {
return nil, helper.ErrInternalf("get object pool from request: %v", err)
}
@@ -44,7 +44,7 @@ func (s *server) CloneFromPool(ctx context.Context, req *gitalypb.CloneFromPoolR
return &gitalypb.CloneFromPoolResponse{}, nil
}
-func validateCloneFromPoolRequestRepositoryState(req *gitalypb.CloneFromPoolRequest) error {
+func (s *server) validateCloneFromPoolRequestRepositoryState(req *gitalypb.CloneFromPoolRequest) error {
targetRepositoryFullPath, err := helper.GetPath(req.GetRepository())
if err != nil {
return fmt.Errorf("getting target repository path: %v", err)
@@ -54,7 +54,7 @@ func validateCloneFromPoolRequestRepositoryState(req *gitalypb.CloneFromPoolRequ
return errors.New("target reopsitory already exists")
}
- objectPool, err := objectpool.FromProto(req.GetPool())
+ objectPool, err := objectpool.FromProto(s.locator, req.GetPool())
if err != nil {
return fmt.Errorf("getting object pool from repository: %v", err)
}
diff --git a/internal/service/repository/clone_from_pool_internal.go b/internal/service/repository/clone_from_pool_internal.go
index af037b028..52d94cda4 100644
--- a/internal/service/repository/clone_from_pool_internal.go
+++ b/internal/service/repository/clone_from_pool_internal.go
@@ -19,7 +19,7 @@ func (s *server) CloneFromPoolInternal(ctx context.Context, req *gitalypb.CloneF
return nil, helper.ErrInvalidArgument(err)
}
- if err := validateCloneFromPoolInternalRequestRepositoryState(req); err != nil {
+ if err := s.validateCloneFromPoolInternalRequestRepositoryState(req); err != nil {
return nil, helper.ErrInternal(err)
}
@@ -46,7 +46,7 @@ func (s *server) CloneFromPoolInternal(ctx context.Context, req *gitalypb.CloneF
return nil, helper.ErrInternalf("fetch internal remote: %v", err)
}
- objectPool, err := objectpool.FromProto(req.GetPool())
+ objectPool, err := objectpool.FromProto(s.locator, req.GetPool())
if err != nil {
return nil, helper.ErrInternalf("get object pool from request: %v", err)
}
@@ -58,7 +58,7 @@ func (s *server) CloneFromPoolInternal(ctx context.Context, req *gitalypb.CloneF
return &gitalypb.CloneFromPoolInternalResponse{}, nil
}
-func validateCloneFromPoolInternalRequestRepositoryState(req *gitalypb.CloneFromPoolInternalRequest) error {
+func (s *server) validateCloneFromPoolInternalRequestRepositoryState(req *gitalypb.CloneFromPoolInternalRequest) error {
targetRepositoryFullPath, err := helper.GetPath(req.GetRepository())
if err != nil {
return fmt.Errorf("getting target repository path: %v", err)
@@ -68,7 +68,7 @@ func validateCloneFromPoolInternalRequestRepositoryState(req *gitalypb.CloneFrom
return errors.New("target reopsitory already exists")
}
- objectPool, err := objectpool.FromProto(req.GetPool())
+ objectPool, err := objectpool.FromProto(s.locator, req.GetPool())
if err != nil {
return fmt.Errorf("getting object pool from repository: %v", err)
}
diff --git a/internal/service/repository/clone_from_pool_internal_test.go b/internal/service/repository/clone_from_pool_internal_test.go
index c32453ee9..1059abc9f 100644
--- a/internal/service/repository/clone_from_pool_internal_test.go
+++ b/internal/service/repository/clone_from_pool_internal_test.go
@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/objectpool"
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/internal/service/repository"
@@ -21,7 +22,7 @@ func NewTestObjectPool(t *testing.T) (*objectpool.ObjectPool, *gitalypb.Reposito
relativePath := testhelper.NewTestObjectPoolName(t)
repo := testhelper.CreateRepo(t, storagePath, relativePath)
- pool, err := objectpool.NewObjectPool(repo.GetStorageName(), relativePath)
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), repo.GetStorageName(), relativePath)
require.NoError(t, err)
return pool, repo
diff --git a/internal/service/repository/fetch_remote_test.go b/internal/service/repository/fetch_remote_test.go
index 943fc5816..f00bc508b 100644
--- a/internal/service/repository/fetch_remote_test.go
+++ b/internal/service/repository/fetch_remote_test.go
@@ -68,7 +68,7 @@ func TestFetchRemoteSuccess(t *testing.T) {
}
func TestFetchRemoteFailure(t *testing.T) {
- server := NewServer(RubyServer, config.GitalyInternalSocketPath())
+ server := NewServer(RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath())
tests := []struct {
desc string
diff --git a/internal/service/repository/replicate_test.go b/internal/service/repository/replicate_test.go
index c079fdf8f..8933fbe9b 100644
--- a/internal/service/repository/replicate_test.go
+++ b/internal/service/repository/replicate_test.go
@@ -316,7 +316,7 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) {
}
func runServerWithBadFetchInternalRemote(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
@@ -325,7 +325,7 @@ func runServerWithBadFetchInternalRemote(t *testing.T) (*grpc.Server, string) {
internalListener, err := net.Listen("unix", config.GitalyInternalSocketPath())
require.NoError(t, err)
- gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(repository.RubyServer, config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(repository.RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath()))
gitalypb.RegisterRemoteServiceServer(server, &mockRemoteServer{})
reflection.Register(server)
diff --git a/internal/service/repository/search_files_test.go b/internal/service/repository/search_files_test.go
index 26504fb20..57aa56e39 100644
--- a/internal/service/repository/search_files_test.go
+++ b/internal/service/repository/search_files_test.go
@@ -209,7 +209,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
}
func TestSearchFilesByContentFailure(t *testing.T) {
- server := NewServer(RubyServer, config.GitalyInternalSocketPath())
+ server := NewServer(RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath())
testRepo, _, cleanupRepo := testhelper.NewTestRepo(t)
defer cleanupRepo()
@@ -315,7 +315,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
}
func TestSearchFilesByNameFailure(t *testing.T) {
- server := NewServer(RubyServer, config.GitalyInternalSocketPath())
+ server := NewServer(RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath())
testCases := []struct {
desc string
diff --git a/internal/service/repository/server.go b/internal/service/repository/server.go
index 563b9c2a1..4a40cc28f 100644
--- a/internal/service/repository/server.go
+++ b/internal/service/repository/server.go
@@ -6,6 +6,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
+ "gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
)
@@ -16,11 +17,12 @@ type server struct {
connsByAddress map[string]*grpc.ClientConn
connsMtx sync.RWMutex
internalGitalySocket string
+ locator storage.Locator
}
// NewServer creates a new instance of a gRPC repo server
-func NewServer(rs *rubyserver.Server, internalGitalySocket string) gitalypb.RepositoryServiceServer {
- return &server{ruby: rs, connsByAddress: make(map[string]*grpc.ClientConn), internalGitalySocket: internalGitalySocket}
+func NewServer(rs *rubyserver.Server, locator storage.Locator, internalGitalySocket string) gitalypb.RepositoryServiceServer {
+ return &server{ruby: rs, locator: locator, connsByAddress: make(map[string]*grpc.ClientConn), internalGitalySocket: internalGitalySocket}
}
func (*server) FetchHTTPRemote(context.Context, *gitalypb.FetchHTTPRemoteRequest) (*gitalypb.FetchHTTPRemoteResponse, error) {
diff --git a/internal/service/repository/testhelper_test.go b/internal/service/repository/testhelper_test.go
index ae61359dc..96829400e 100644
--- a/internal/service/repository/testhelper_test.go
+++ b/internal/service/repository/testhelper_test.go
@@ -75,7 +75,7 @@ func runRepoServer(t *testing.T, opts ...testhelper.TestServerOpt) (string, func
srv := testhelper.NewServerWithAuth(t, streamInt, unaryInt, config.Config.Auth.Token, opts...)
- gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(RubyServer, config.GitalyInternalSocketPath()))
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(RubyServer, config.NewLocator(config.Config), config.GitalyInternalSocketPath()))
reflection.Register(srv.GrpcServer())
require.NoError(t, srv.Start())
diff --git a/internal/service/server/info_test.go b/internal/service/server/info_test.go
index 0a540bfba..3aef80af4 100644
--- a/internal/service/server/info_test.go
+++ b/internal/service/server/info_test.go
@@ -76,7 +76,7 @@ func runServer(t *testing.T, storages []config.Storage) (*grpc.Server, string) {
streamInt := []grpc.StreamServerInterceptor{auth.StreamServerInterceptor(authConfig)}
unaryInt := []grpc.UnaryServerInterceptor{auth.UnaryServerInterceptor(authConfig)}
- server := testhelper.NewTestGrpcServer(t, config.Config, streamInt, unaryInt)
+ server := testhelper.NewTestGrpcServer(t, streamInt, unaryInt)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go
index 05bbc8649..6a34b92ea 100644
--- a/internal/service/smarthttp/inforefs_test.go
+++ b/internal/service/smarthttp/inforefs_test.go
@@ -197,7 +197,7 @@ func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- pool, err := objectpool.NewObjectPool(repo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), repo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
require.NoError(t, pool.Create(ctx, repo))
diff --git a/internal/service/smarthttp/receive_pack_test.go b/internal/service/smarthttp/receive_pack_test.go
index 8474f3ea0..463460060 100644
--- a/internal/service/smarthttp/receive_pack_test.go
+++ b/internal/service/smarthttp/receive_pack_test.go
@@ -424,7 +424,7 @@ func TestPostReceivePackToHooks(t *testing.T) {
}
func runSmartHTTPHookServiceServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, config.Config, nil, nil)
+ server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/service/ssh/receive_pack_test.go b/internal/service/ssh/receive_pack_test.go
index a72cdbd5e..efc983776 100644
--- a/internal/service/ssh/receive_pack_test.go
+++ b/internal/service/ssh/receive_pack_test.go
@@ -176,7 +176,7 @@ func TestObjectPoolRefAdvertisementHidingSSH(t *testing.T) {
repo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- pool, err := objectpool.NewObjectPool(repo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
+ pool, err := objectpool.NewObjectPool(config.NewLocator(config.Config), repo.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
require.NoError(t, pool.Create(ctx, repo))
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index c8975f777..5cfe083f0 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -40,7 +40,6 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
gitalylog "gitlab.com/gitlab-org/gitaly/internal/log"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
- "gitlab.com/gitlab-org/gitaly/internal/middleware/locator"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -370,23 +369,16 @@ func GetGitEnvData() (string, error) {
}
// NewTestGrpcServer creates a GRPC Server for testing purposes
-func NewTestGrpcServer(tb testing.TB, conf config.Cfg, streamInterceptors []grpc.StreamServerInterceptor, unaryInterceptors []grpc.UnaryServerInterceptor) *grpc.Server {
- ctxTagger := grpc_ctxtags.WithFieldExtractorForInitialReq(fieldextractors.FieldExtractor)
- cfgLocator := config.NewLocator(conf)
+func NewTestGrpcServer(tb testing.TB, streamInterceptors []grpc.StreamServerInterceptor, unaryInterceptors []grpc.UnaryServerInterceptor) *grpc.Server {
logger := NewTestLogger(tb)
logrusEntry := log.NewEntry(logger).WithField("test", tb.Name())
- streamInterceptors = append([]grpc.StreamServerInterceptor{
- grpc_ctxtags.StreamServerInterceptor(ctxTagger),
- locator.StreamInterceptor(cfgLocator),
- grpc_logrus.StreamServerInterceptor(logrusEntry),
- }, streamInterceptors...)
+ ctxTagger := grpc_ctxtags.WithFieldExtractorForInitialReq(fieldextractors.FieldExtractor)
+ ctxStreamTagger := grpc_ctxtags.StreamServerInterceptor(ctxTagger)
+ ctxUnaryTagger := grpc_ctxtags.UnaryServerInterceptor(ctxTagger)
- unaryInterceptors = append([]grpc.UnaryServerInterceptor{
- grpc_ctxtags.UnaryServerInterceptor(ctxTagger),
- locator.UnaryInterceptor(cfgLocator),
- grpc_logrus.UnaryServerInterceptor(logrusEntry),
- }, unaryInterceptors...)
+ streamInterceptors = append([]grpc.StreamServerInterceptor{ctxStreamTagger, grpc_logrus.StreamServerInterceptor(logrusEntry)}, streamInterceptors...)
+ unaryInterceptors = append([]grpc.UnaryServerInterceptor{ctxUnaryTagger, grpc_logrus.UnaryServerInterceptor(logrusEntry)}, unaryInterceptors...)
return grpc.NewServer(
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamInterceptors...)),
@@ -902,14 +894,3 @@ func GenerateTestCerts(t *testing.T) (string, string, Cleanup) {
return certFile.Name(), keyFile.Name(), cleanup
}
-
-// CtxWithLocator returns a new context with injected locator.
-func CtxWithLocator(ctx context.Context, l storage.Locator) context.Context {
- if locator.IsAtCtx(ctx) {
- panic("locator already injected")
- }
-
- ctx = grpc_ctxtags.SetInContext(ctx, grpc_ctxtags.NewTags())
- locator.SetAtCtx(ctx, l)
- return ctx
-}
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go
index 466dde39a..26f990aa7 100644
--- a/internal/testhelper/testserver.go
+++ b/internal/testhelper/testserver.go
@@ -796,7 +796,7 @@ func NewServerWithHealth(t testing.TB, socketName string) (*grpc.Server, *health
}
func NewHealthServerWithListener(t testing.TB, listener net.Listener) (*grpc.Server, *health.Server) {
- srv := NewTestGrpcServer(t, config.Cfg{}, nil, nil)
+ srv := NewTestGrpcServer(t, nil, nil)
healthSrvr := health.NewServer()
healthpb.RegisterHealthServer(srv, healthSrvr)
healthSrvr.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)