Skip to content
Snippets Groups Projects
Unverified Commit 77d8eb0b authored by Stan Hu's avatar Stan Hu
Browse files

Add SMTP timeout configuration options

In https://github.com/mikel/mail/pull/1427/files, mail v2.8.1 gem
modified the default open and read timeout values to 5 seconds instead
of the default `Net::SMTP` 30 and 60 seconds, respectively.

Since upgrading to GitLab 15.10.3, some users have observed receiving
`Net::ReadTimeout` errors. This commit restores the original defaults
and allows users to configure the timeouts.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/410336

Changelog: added
parent ec612b7c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -506,6 +506,8 @@ default['gitlab']['gitlab-rails']['smtp_pool'] = false
# Path to the public Certificate Authority file
# defaults to /opt/gitlab/embedded/ssl/certs/cacert.pem. The install-dir path is set at build time
default['gitlab']['gitlab-rails']['smtp_ca_file'] = "#{node['package']['install-dir']}/embedded/ssl/certs/cacert.pem"
default['gitlab']['gitlab-rails']['smtp_open_timeout'] = 30
default['gitlab']['gitlab-rails']['smtp_read_timeout'] = 60
 
# Path to directory that contains (ca) certificates that should also be trusted (e.g. on
# outgoing Webhooks connections). For these certificates symlinks will be created in
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ if Rails.env.production?
<% end %>
user_name: <%= node['gitlab']['gitlab-rails']["smtp_user_name"]&.inspect || "secrets.username" %>,
password: <%= node['gitlab']['gitlab-rails']["smtp_password"]&.inspect || "secrets.password" %>,
<% %w{ address port domain enable_starttls_auto tls ssl openssl_verify_mode ca_path ca_file }.each do |key| %>
<% %w{ address port domain enable_starttls_auto tls ssl openssl_verify_mode ca_path ca_file open_timeout read_timeout }.each do |key| %>
<% value = node['gitlab']['gitlab-rails']["smtp_#{key}"] %>
<%= "#{key}: #{value.inspect}," unless value.nil? %>
<% end %>
Loading
Loading
Loading
Loading
@@ -1196,6 +1196,56 @@ RSpec.describe 'gitlab::gitlab-rails' do
end
 
context 'SMTP settings' do
context 'defaults' do
before do
stub_gitlab_rb(
gitlab_rails: {
smtp_enable: true
}
)
end
it 'renders the default timeout values' do
expect(chef_run).to create_templatesymlink('Create a smtp_settings.rb and create a symlink to Rails root').with_variables(
hash_including(
'smtp_open_timeout' => 30,
'smtp_read_timeout' => 60
)
)
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/smtp_settings.rb').with_content { |content|
expect(content).to include('open_timeout: 30')
expect(content).to include('read_timeout: 60')
}
end
end
context 'when timeouts are set' do
before do
stub_gitlab_rb(
gitlab_rails: {
smtp_enable: true,
smtp_open_timeout: 10,
smtp_read_timeout: 20
}
)
end
it 'renders the timeout values' do
expect(chef_run).to create_templatesymlink('Create a smtp_settings.rb and create a symlink to Rails root').with_variables(
hash_including(
'smtp_open_timeout' => 10,
'smtp_read_timeout' => 20
)
)
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/smtp_settings.rb').with_content { |content|
expect(content).to include('open_timeout: 10')
expect(content).to include('read_timeout: 20')
}
end
end
context 'when connection pooling is not configured' do
it 'creates smtp_settings.rb with pooling disabled' do
stub_gitlab_rb(
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment