Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
faf2ce89
Commit
faf2ce89
authored
May 05, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mrchrisw-import-shell-timeout'
parents
7e0e45db
0f1273fa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
2 deletions
+51
-2
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
+4
-0
config/gitlab.yml.example
config/gitlab.yml.example
+3
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+2
-2
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+41
-0
No files found.
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
0 → 100644
View file @
faf2ce89
---
title
:
Add configurable timeout for git fetch and clone operations
merge_request
:
10697
author
:
config/gitlab.yml.example
View file @
faf2ce89
...
@@ -502,6 +502,9 @@ production: &base
...
@@ -502,6 +502,9 @@ production: &base
upload_pack: true
upload_pack: true
receive_pack: true
receive_pack: true
# Git import/fetch timeout
# git_timeout: 800
# If you use non-standard ssh port you need to specify it
# If you use non-standard ssh port you need to specify it
# ssh_port: 22
# ssh_port: 22
...
...
config/initializers/1_settings.rb
View file @
faf2ce89
...
@@ -386,6 +386,7 @@ Settings.gitlab_shell['ssh_port'] ||= 22
...
@@ -386,6 +386,7 @@ Settings.gitlab_shell['ssh_port'] ||= 22
Settings
.
gitlab_shell
[
'ssh_user'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'ssh_user'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'owner_group'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'owner_group'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'ssh_path_prefix'
]
||=
Settings
.
__send__
(
:build_gitlab_shell_ssh_path_prefix
)
Settings
.
gitlab_shell
[
'ssh_path_prefix'
]
||=
Settings
.
__send__
(
:build_gitlab_shell_ssh_path_prefix
)
Settings
.
gitlab_shell
[
'git_timeout'
]
||=
800
#
#
# Workhorse
# Workhorse
...
...
lib/gitlab/shell.rb
View file @
faf2ce89
...
@@ -83,7 +83,7 @@ module Gitlab
...
@@ -83,7 +83,7 @@ module Gitlab
# Timeout should be less than 900 ideally, to prevent the memory killer
# Timeout should be less than 900 ideally, to prevent the memory killer
# to silently kill the process without knowing we are timing out here.
# to silently kill the process without knowing we are timing out here.
output
,
status
=
Popen
.
popen
([
gitlab_shell_projects_path
,
'import-project'
,
output
,
status
=
Popen
.
popen
([
gitlab_shell_projects_path
,
'import-project'
,
storage
,
"
#{
name
}
.git"
,
url
,
'800'
])
storage
,
"
#{
name
}
.git"
,
url
,
"
#{
Gitlab
.
config
.
gitlab_shell
.
git_timeout
}
"
])
raise
Error
,
output
unless
status
.
zero?
raise
Error
,
output
unless
status
.
zero?
true
true
end
end
...
@@ -99,7 +99,7 @@ module Gitlab
...
@@ -99,7 +99,7 @@ module Gitlab
# fetch_remote("gitlab/gitlab-ci", "upstream")
# fetch_remote("gitlab/gitlab-ci", "upstream")
#
#
def
fetch_remote
(
storage
,
name
,
remote
,
forced:
false
,
no_tags:
false
)
def
fetch_remote
(
storage
,
name
,
remote
,
forced:
false
,
no_tags:
false
)
args
=
[
gitlab_shell_projects_path
,
'fetch-remote'
,
storage
,
"
#{
name
}
.git"
,
remote
,
'800'
]
args
=
[
gitlab_shell_projects_path
,
'fetch-remote'
,
storage
,
"
#{
name
}
.git"
,
remote
,
"
#{
Gitlab
.
config
.
gitlab_shell
.
git_timeout
}
"
]
args
<<
'--force'
if
forced
args
<<
'--force'
if
forced
args
<<
'--no-tags'
if
no_tags
args
<<
'--no-tags'
if
no_tags
...
...
spec/lib/gitlab/shell_spec.rb
View file @
faf2ce89
...
@@ -91,4 +91,45 @@ describe Gitlab::Shell, lib: true do
...
@@ -91,4 +91,45 @@ describe Gitlab::Shell, lib: true do
end
end
end
end
end
end
describe
'projects commands'
do
let
(
:projects_path
)
{
'tmp/tests/shell-projects-test/bin/gitlab-projects'
}
before
do
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:path
).
and_return
(
'tmp/tests/shell-projects-test'
)
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:git_timeout
).
and_return
(
800
)
end
describe
'#fetch_remote'
do
it
'returns true when the command succeeds'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'fetch-remote'
,
'current/storage'
,
'project/path.git'
,
'new/storage'
,
'800'
]).
and_return
([
nil
,
0
])
expect
(
gitlab_shell
.
fetch_remote
(
'current/storage'
,
'project/path'
,
'new/storage'
)).
to
be
true
end
it
'raises an exception when the command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'fetch-remote'
,
'current/storage'
,
'project/path.git'
,
'new/storage'
,
'800'
]).
and_return
([
"error"
,
1
])
expect
{
gitlab_shell
.
fetch_remote
(
'current/storage'
,
'project/path'
,
'new/storage'
)
}.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
"error"
)
end
end
describe
'#import_repository'
do
it
'returns true when the command succeeds'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'import-project'
,
'current/storage'
,
'project/path.git'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
"800"
]).
and_return
([
nil
,
0
])
expect
(
gitlab_shell
.
import_repository
(
'current/storage'
,
'project/path'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
)).
to
be
true
end
it
'raises an exception when the command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'import-project'
,
'current/storage'
,
'project/path.git'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
"800"
]).
and_return
([
"error"
,
1
])
expect
{
gitlab_shell
.
import_repository
(
'current/storage'
,
'project/path'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
)
}.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
"error"
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment