From afd5911557051c4dae652b386c7a91f746ff18a5 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 21 Nov 2017 17:13:21 +0000 Subject: [PATCH] Set the default gitlab-shell timeout to 3 hours --- app/views/shared/_import_form.html.haml | 3 ++- changelogs/unreleased/39977-gitlab-shell-default-timeout.yml | 5 +++++ config/gitlab.yml.example | 4 ++-- config/initializers/1_settings.rb | 2 +- lib/gitlab/shell.rb | 3 +-- 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/39977-gitlab-shell-default-timeout.yml diff --git a/app/views/shared/_import_form.html.haml b/app/views/shared/_import_form.html.haml index 233d8c95eda..736afa085e8 100644 --- a/app/views/shared/_import_form.html.haml +++ b/app/views/shared/_import_form.html.haml @@ -11,6 +11,7 @@ %li If your HTTP repository is not publicly accessible, add authentication information to the URL: https://username:password@gitlab.company.com/group/project.git. %li - The import will time out after 15 minutes. For repositories that take longer, use a clone/push combination. + The import will time out after #{time_interval_in_words(Gitlab.config.gitlab_shell.git_timeout)}. + For repositories that take longer, use a clone/push combination. %li To migrate an SVN repository, check out #{link_to "this document", help_page_path('user/project/import/svn')}. diff --git a/changelogs/unreleased/39977-gitlab-shell-default-timeout.yml b/changelogs/unreleased/39977-gitlab-shell-default-timeout.yml new file mode 100644 index 00000000000..b7a974fd8d9 --- /dev/null +++ b/changelogs/unreleased/39977-gitlab-shell-default-timeout.yml @@ -0,0 +1,5 @@ +--- +title: Set the default gitlab-shell timeout to 3 hours +merge_request: 15292 +author: +type: fixed diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 7547ba4a8fa..7f6e68ceed6 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -559,8 +559,8 @@ production: &base upload_pack: true receive_pack: true - # Git import/fetch timeout - # git_timeout: 800 + # Git import/fetch timeout, in seconds. Defaults to 3 hours. + # git_timeout: 10800 # If you use non-standard ssh port you need to specify it # ssh_port: 22 diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index d1156b0c8a8..f7c83f7b0f7 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -429,7 +429,7 @@ Settings.gitlab_shell['ssh_port'] ||= 22 Settings.gitlab_shell['ssh_user'] ||= 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['git_timeout'] ||= 800 +Settings.gitlab_shell['git_timeout'] ||= 10800 # # Workhorse diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index dc0184e4ad9..996d213fdb4 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -101,8 +101,7 @@ module Gitlab # # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387 def import_repository(storage, name, url) - # Timeout should be less than 900 ideally, to prevent the memory killer - # to silently kill the process without knowing we are timing out here. + # The timeout ensures the subprocess won't hang forever cmd = [gitlab_shell_projects_path, 'import-project', storage, "#{name}.git", url, "#{Gitlab.config.gitlab_shell.git_timeout}"] gitlab_shell_fast_execute_raise_error(cmd)