Skip to content

Commit b3282a5

Browse files
authored
Merge pull request #100 from github/forty
Adjust importer's push limits
2 parents c643133 + 396aa5b commit b3282a5

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

internal/integration/integration_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ func (suite *SpokesReceivePackTestSuite) TestSpokesReceivePackAllowedWhenWithImp
236236
assert.NoError(suite.T(), chdir(suite.T(), suite.localRepo), "unable to chdir into our local Git repo")
237237
cmd := exec.Command("git", "push", "--all", "--receive-pack=spokes-receive-pack-wrapper", "r")
238238
cmd.Env = append(os.Environ(),
239+
"GIT_SOCKSTAT_VAR_is_importing=bool:true",
239240
"GIT_SOCKSTAT_VAR_import_skip_push_limit=bool:true",
240241
)
241242
err := cmd.Run()
@@ -245,6 +246,23 @@ func (suite *SpokesReceivePackTestSuite) TestSpokesReceivePackAllowedWhenWithImp
245246
"unexpected failure with the custom spokes-receive-pack program; it should have succeeded")
246247
}
247248

249+
func (suite *SpokesReceivePackTestSuite) TestSpokesReceivePackAllowedWhenImporting() {
250+
assert.NoError(suite.T(), chdir(suite.T(), suite.remoteRepo), "unable to chdir into our remote Git repo")
251+
// Set a really low value to receive.maxsize in order to make it fail
252+
require.NoError(suite.T(), exec.Command("git", "config", "receive.maxsize", "1").Run())
253+
254+
assert.NoError(suite.T(), chdir(suite.T(), suite.localRepo), "unable to chdir into our local Git repo")
255+
cmd := exec.Command("git", "push", "--all", "--receive-pack=spokes-receive-pack-wrapper", "r")
256+
cmd.Env = append(os.Environ(),
257+
"GIT_SOCKSTAT_VAR_is_importing=bool:true",
258+
)
259+
err := cmd.Run()
260+
assert.NoError(
261+
suite.T(),
262+
err,
263+
"unexpected failure with the custom spokes-receive-pack program; it should have succeeded")
264+
}
265+
248266
func (suite *SpokesReceivePackTestSuite) TestWithGovernor() {
249267
started := make(chan any)
250268
govSock, msgs, cleanup := startFakeGovernor(suite.T(), started, nil)

internal/spokes/spokes.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -955,12 +955,14 @@ func (r *spokesReceivePack) isFsckConfigEnabled() bool {
955955
}
956956

957957
func (r *spokesReceivePack) getMaxInputSize() (int, error) {
958-
// We want to skip the default push limit when the `import_skip_push_limit`
959-
// stat is set only.
960-
// We keep using the `is_import` here for backward compatibility only,
961-
// which should be removed on a subsequent PR.
962-
if isImporting() || skipPushLimit() {
963-
return 80 * 1024 * 1024 * 1024, nil /* 80 GB */
958+
switch {
959+
case isImporting() && skipPushLimit():
960+
// If the import has been allow-listed, use a higher limit.
961+
return 80 * 1024 * 1024 * 1024, nil
962+
case isImporting():
963+
// Imports are allowed to push in 40 GiB by default. This
964+
// setting makes it so that GEI has parity with ECI.
965+
return 40 * 1024 * 1024 * 1024, nil
964966
}
965967

966968
maxSize := r.config.Get("receive.maxsize")

0 commit comments

Comments
 (0)