From f3b1e07903a7f509b11ad7cf188fac46d98f77f6 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 6 Apr 2020 15:10:04 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- doc/administration/troubleshooting/debug.md | 74 +++++++++++++++++++-- .../troubleshooting/gitlab_rails_cheat_sheet.md | 36 ---------- .../troubleshooting/img/Okta-SAMLsetup.png | Bin 53899 -> 18920 bytes .../troubleshooting/img/Okta-advancedsettings.png | Bin 47658 -> 15614 bytes .../troubleshooting/img/Okta-attributes.png | Bin 22228 -> 5540 bytes .../troubleshooting/img/Okta-linkscert.png | Bin 159197 -> 58832 bytes .../navigating_gitlab_via_rails_console.md | 2 +- doc/administration/troubleshooting/ssl.md | 2 +- 8 files changed, 69 insertions(+), 45 deletions(-) (limited to 'doc/administration/troubleshooting') diff --git a/doc/administration/troubleshooting/debug.md b/doc/administration/troubleshooting/debug.md index 6a22b22a5be..295dab2be38 100644 --- a/doc/administration/troubleshooting/debug.md +++ b/doc/administration/troubleshooting/debug.md @@ -3,9 +3,10 @@ Sometimes things don't work the way they should. Here are some tips on debugging issues out in production. -## Starting a Rails console +## Starting a Rails console session -Troubleshooting and debugging often requires a rails console. +Troubleshooting and debugging your GitLab instance often requires a +[Rails console](https://guides.rubyonrails.org/command_line.html#rails-console). **For Omnibus installations** @@ -13,22 +14,81 @@ Troubleshooting and debugging often requires a rails console. sudo gitlab-rails console ``` ---- - **For installations from source** ```shell -bundle exec rails console production +sudo -u git -H bundle exec rails console -e production ``` Kubernetes: the console is in the task-runner pod, refer to our [Kubernetes cheat sheet](kubernetes_cheat_sheet.md#gitlab-specific-kubernetes-information) for details. +### Enabling Active Record logging + +You can enable output of Active Record debug logging in the Rails console +session by running: + +```ruby +ActiveRecord::Base.logger = Logger.new(STDOUT) +``` + +This will show information about database queries triggered by any Ruby code +you may run in the console. To turn off logging again, run: + +```ruby +ActiveRecord::Base.logger = nil +``` + +### Disabling database statement timeout + +You can disable the PostgreSQL statement timeout for the current Rails console +session by running: + +```ruby +ActiveRecord::Base.connection.execute('SET statement_timeout TO 0') +``` + +Note that this change only affects the current Rails console session and will +not be persisted in the GitLab production environment or in the next Rails +console session. + +### Output Rails console session history + +If you'd like to output your Rails console command history in a format that's +easy to copy and save for future reference, you can run: + +```ruby +puts Readline::HISTORY.to_a +``` + +## Using the Rails Runner + +If you need to run some Ruby code in thex context of your GitLab production +environment, you can do so using the [Rails Runner](https://guides.rubyonrails.org/command_line.html#rails-runner). + +**For Omnibus installations** + +```shell +sudo gitlab-rails runner "RAILS_COMMAND" + +# Example with a two-line Ruby script +sudo gitlab-rails runner "user = User.first; puts user.username" +``` + +**For installations from source** + +```shell +sudo -u git -H bundle exec rails runner -e production "RAILS_COMMAND" + +# Example with a two-line Ruby script +sudo -u git -H bundle exec rails runner -e production "user = User.first; puts user.username" +``` + ## Mail not working A common problem is that mails are not being sent for some reason. Suppose you configured an SMTP server, but you're not seeing mail delivered. Here's how to check the settings: -1. Run a [Rails console.](#starting-a-rails-console) +1. Run a [Rails console](#starting-a-rails-console-session). 1. Look at the ActionMailer `delivery_method` to make sure it matches what you intended. If you configured SMTP, it should say `:smtp`. If you're using @@ -168,7 +228,7 @@ separate Rails process to debug the issue: 1. Log in to your GitLab account. 1. Copy the URL that is causing problems (e.g. `https://gitlab.com/ABC`). 1. Create a Personal Access Token for your user (Profile Settings -> Access Tokens). -1. Bring up the [GitLab Rails console.](#starting-a-rails-console) +1. Bring up the [GitLab Rails console.](#starting-a-rails-console-session) 1. At the Rails console, run: ```ruby diff --git a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md index 15ed436fb34..0471c7b7ffd 100644 --- a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md +++ b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md @@ -25,36 +25,6 @@ mentioned above, we recommend running these scripts under the supervision of a Support Engineer, who can also verify that they will continue to work as they should and, if needed, update the script for the latest version of GitLab. -## Use the Rails Runner - -If the script you want to run is short, you can use the Rails Runner to avoid -entering the rails console in the first place. Here's an example of its use: - -```shell -gitlab-rails runner "RAILS_COMMAND" - -# Example with a 2-line script -gitlab-rails runner "user = User.first; puts user.username" -``` - -## Enable debug logging on rails console - -```ruby -Rails.logger.level = 0 -``` - -## Enable debug logging for ActiveRecord (db issues) - -```ruby -ActiveRecord::Base.logger = Logger.new(STDOUT) -``` - -## Temporarily Disable Timeout - -```ruby -ActiveRecord::Base.connection.execute('SET statement_timeout TO 0') -``` - ## Find specific methods for an object ```ruby @@ -85,12 +55,6 @@ o = Object.where('attribute like ?', 'ex') Rails.cache.instance_variable_get(:@data).keys ``` -## Rails console history - -```ruby -puts Readline::HISTORY.to_a -``` - ## Profile a page ```ruby diff --git a/doc/administration/troubleshooting/img/Okta-SAMLsetup.png b/doc/administration/troubleshooting/img/Okta-SAMLsetup.png index 8171febb5bc..1bd9bf4d7e9 100644 Binary files a/doc/administration/troubleshooting/img/Okta-SAMLsetup.png and b/doc/administration/troubleshooting/img/Okta-SAMLsetup.png differ diff --git a/doc/administration/troubleshooting/img/Okta-advancedsettings.png b/doc/administration/troubleshooting/img/Okta-advancedsettings.png index 43eb546f238..45e378d1d12 100644 Binary files a/doc/administration/troubleshooting/img/Okta-advancedsettings.png and b/doc/administration/troubleshooting/img/Okta-advancedsettings.png differ diff --git a/doc/administration/troubleshooting/img/Okta-attributes.png b/doc/administration/troubleshooting/img/Okta-attributes.png index e4a7b33fe55..a3405e4de9b 100644 Binary files a/doc/administration/troubleshooting/img/Okta-attributes.png and b/doc/administration/troubleshooting/img/Okta-attributes.png differ diff --git a/doc/administration/troubleshooting/img/Okta-linkscert.png b/doc/administration/troubleshooting/img/Okta-linkscert.png index 33e6b3cc53e..38cae415f7e 100644 Binary files a/doc/administration/troubleshooting/img/Okta-linkscert.png and b/doc/administration/troubleshooting/img/Okta-linkscert.png differ diff --git a/doc/administration/troubleshooting/navigating_gitlab_via_rails_console.md b/doc/administration/troubleshooting/navigating_gitlab_via_rails_console.md index 01c3da80481..b78d5490cd2 100644 --- a/doc/administration/troubleshooting/navigating_gitlab_via_rails_console.md +++ b/doc/administration/troubleshooting/navigating_gitlab_via_rails_console.md @@ -3,7 +3,7 @@ At the heart of GitLab is a web application [built using the Ruby on Rails framework](https://about.gitlab.com/blog/2018/10/29/why-we-use-rails-to-build-gitlab/). Thanks to this, we also get access to the amazing tools built right into Rails. -In this guide, we'll introduce the [Rails console](https://docs.gitlab.com/omnibus/maintenance/#starting-a-rails-console-session) +In this guide, we'll introduce the [Rails console](debug.md#starting-a-rails-console-session) and the basics of interacting with your GitLab instance from the command line. CAUTION: **CAUTION:** diff --git a/doc/administration/troubleshooting/ssl.md b/doc/administration/troubleshooting/ssl.md index 9474126e5c8..475b7d44eac 100644 --- a/doc/administration/troubleshooting/ssl.md +++ b/doc/administration/troubleshooting/ssl.md @@ -23,7 +23,7 @@ After configuring a GitLab instance with an internal CA certificate, you might n More details here: https://curl.haxx.se/docs/sslcerts.html ``` -- Testing via the [rails console](https://docs.gitlab.com/omnibus/maintenance/#starting-a-rails-console-session) also fails: +- Testing via the [rails console](debug.md#starting-a-rails-console-session) also fails: ```ruby uri = URI.parse("https://gitlab.domain.tld") -- cgit v1.2.1