Add SMTP timeout configuration options
What does this MR do?
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.
Discourse came across a similar problem with the same solution. Some SMTP servers are slow to respond: https://meta.discourse.org/t/smtp-net-readtimeout-without-relation-to-net-or-login-problems-smtp-host-is-just-slow/235727
Related issues
Relates to gitlab#410336 (closed)
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
MR title and description are up to date, accurate, and descriptive. -
MR targeting the appropriate branch. -
Latest Merge Result pipeline is green. -
When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
-
The manual Trigger:ee-package
jobs have a green pipeline running against latest commit. -
If config/software
orconfig/patches
directories are changed, make sure thebuild-package-on-all-os
job within theTrigger:ee-package
downstream pipeline succeeded. -
If you are changing anything SSL related, then the Trigger:package:fips
manual job within theTrigger:ee-package
downstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed to dev.gitlab.org
to confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes. -
Documentation created/updated. -
Tests added. -
Integration tests added to GitLab QA. -
Equivalent MR/issue for the GitLab Chart opened: gitlab-org/charts/gitlab!3156 (merged) -
Validate potential values for new configuration settings. Formats such as integer 10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.
Merge request reports
Activity
added devopssystems groupdistribution sectioncore platform labels
assigned to @stanhu
changed milestone to %16.0
- A deleted user
added featureaddition typefeature labels
1 Warning You've made some changes at the locations which contain user facing configuration.
That's OK as long as you're refactoring existing code and not adding any new
configuration. If you are adding new user facing configuration, consider adding
to gitlab.rb.template located in files/gitlab-config-template/gitlab.rb.template .
Otherwise, please consider adding the typemaintenance label in that case.1 Message Please add the workflowready for review label once you think the MR is ready to for an initial review. Merge requests are handled according to the workflow documented in our handbook and should receive a response within the limit documented in our First-response SLO.
If you don't receive a response, please mention
@gitlab-org/distribution
, or one of our Project MaintainersIf needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerI have Postfix installed without TLS, but the timeouts should still apply. This email works:
Notify.test_email('email@example.com', 'Message Subject', 'Message Body').deliver_now
Testing, without settings:
$ sudo cat /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb # This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. if Rails.env.production? secrets = Gitlab::Email::SmtpConfig.secrets smtp_settings = { user_name: secrets.username, password: secrets.password, address: "localhost", port: 25, domain: "localhost", enable_starttls_auto: false, tls: false, ssl: false, openssl_verify_mode: "none", ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem", } Gitlab::Application.config.action_mailer.delivery_method = :smtp ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = smtp_settings end
Via
sudo gitlab-rails console
:irb(main):001:0> ActionMailer::Base.smtp_settings => {:user_name=>nil, :password=>nil, :address=>"localhost", :port=>25, :domain=>"localhost", :enable_starttls_auto=>false, :tls=>false, :ssl=>false, :openssl_verify_mode=>"none", :ca_file=>"/opt/gitlab/embedded/ssl/certs/cacert.pem"}
Testing, with new settings:
gitlab_rails['smtp_read_timeout'] = 10 gitlab_rails['smtp_open_timeout'] = 10
$ sudo cat /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb # This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. if Rails.env.production? secrets = Gitlab::Email::SmtpConfig.secrets smtp_settings = { user_name: secrets.username, password: secrets.password, address: "localhost", port: 25, domain: "localhost", enable_starttls_auto: false, tls: false, ssl: false, openssl_verify_mode: "none", ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem", open_timeout: 10, read_timeout: 10, } Gitlab::Application.config.action_mailer.delivery_method = :smtp ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = smtp_settings end
In
gitlab-rails console
:irb(main):001:0> ActionMailer::Base.smtp_settings => {:user_name=>nil, :password=>nil, :address=>"localhost", :port=>25, :domain=>"localhost", :enable_starttls_auto=>false, :tls=>false, :ssl=>false, :openssl_verify_mode=>"none", :ca_file=>"/opt/gitlab/embedded/ssl/certs/cacert.pem", :open_timeout=>10, :read_timeout=>10}
marked the checklist item When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow. as completed
mentioned in issue gitlab#410336 (closed)
- Resolved by Stan Hu
marked the checklist item Integration tests added to GitLab QA. as completed
mentioned in merge request gitlab-org/charts/gitlab!3156 (merged)
added Pick into 15.10 Pick into 15.11 labels
added workflowready for review label
requested review from @Alexand
added workflowin review label and removed workflowready for review label
I was able to reproduce the same and I was also able to confirm the new default
[30, 60]
is being applied:# my gitlab.rb gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = 'localhost' gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_domain'] = 'localhost' gitlab_rails['smtp_tls'] = false gitlab_rails['smtp_openssl_verify_mode'] = 'none' gitlab_rails['smtp_enable_starttls_auto'] = false gitlab_rails['smtp_ssl'] = false gitlab_rails['smtp_force_ssl'] = false
After
gitlab-ctl reconfigure
:cat /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb # This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`. if Rails.env.production? secrets = Gitlab::Email::SmtpConfig.secrets smtp_settings = { user_name: secrets.username, password: secrets.password, address: "localhost", port: 25, domain: "localhost", enable_starttls_auto: false, tls: false, ssl: false, openssl_verify_mode: "none", ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem", open_timeout: 30, read_timeout: 60, } Gitlab::Application.config.action_mailer.delivery_method = :smtp ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = smtp_settings end
irb(main):006:0> ActionMailer::Base.smtp_settings => {:user_name=>nil, :password=>nil, :address=>"localhost", :port=>25, :domain=>"localhost", :enable_starttls_auto=>false, :tls=>false, :ssl=>false, :openssl_verify_mode=>"none", :ca_file=>"/opt/gitlab/embedded/ssl/certs/cacert.pem", :open_timeout=>30, :read_timeout=>60}
marked the checklist item If CI configuration is changed, the branch must be pushed to
dev.gitlab.org
to confirm regular branch builds aren't broken. as completedThanks, Stan. It all LGTM.
@balasankarc, could you please take the maintainer review?
requested review from @balasankarc
removed review request for @Alexand
mentioned in merge request !6887 (merged)
removed Pick into 15.10 label
mentioned in merge request !6888 (merged)
removed Pick into 15.11 label
mentioned in issue Alexand/growth-and-development#2 (closed)
mentioned in commit 3e42fbda
added workflowstaging-canary label and removed workflowin review label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added releasedcandidate label
added releasedpublished label and removed releasedcandidate label
mentioned in merge request gitlab!124757 (merged)