Commit 72b5d954 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-fix-admin-logs-timeout' into 'master'

Fix a potential timeout in `Gitlab::Logger.read_latest`

See merge request !13751
parents 08c07ad1 e288afec
class Admin::LogsController < Admin::ApplicationController class Admin::LogsController < Admin::ApplicationController
def show
@loggers = [
Gitlab::AppLogger,
Gitlab::GitLogger,
Gitlab::EnvironmentLogger,
Gitlab::SidekiqLogger,
Gitlab::RepositoryCheckLogger
]
end
end end
- @no_container = true - @no_container = true
- page_title "Logs" - page_title "Logs"
- loggers = [Gitlab::GitLogger, Gitlab::AppLogger,
Gitlab::EnvironmentLogger, Gitlab::SidekiqLogger,
Gitlab::RepositoryCheckLogger]
= render 'admin/monitoring/head' = render 'admin/monitoring/head'
%div{ class: container_class } %div{ class: container_class }
%ul.nav-links.log-tabs %ul.nav-links.log-tabs
- loggers.each do |klass| - @loggers.each do |klass|
%li{ class: active_when(klass == Gitlab::GitLogger) }> %li{ class: active_when(klass == @loggers.first) }>
= link_to klass::file_name, "##{klass::file_name_noext}", = link_to klass.file_name, "##{klass.file_name_noext}", data: { toggle: 'tab' }
'data-toggle' => 'tab'
.row-content-block .row-content-block
To prevent performance issues admin logs output the last 2000 lines To prevent performance issues admin logs output the last 2000 lines
.tab-content .tab-content
- loggers.each do |klass| - @loggers.each do |klass|
.tab-pane{ class: active_when(klass == Gitlab::GitLogger), id: klass::file_name_noext } .tab-pane{ class: active_when(klass == @loggers.first), id: klass.file_name_noext }
.file-holder#README .file-holder#README
.js-file-title.file-title .js-file-title.file-title
%i.fa.fa-file %i.fa.fa-file
= klass::file_name = klass.file_name
.pull-right .pull-right
= link_to '#', class: 'log-bottom' do = link_to '#', class: 'log-bottom' do
%i.fa.fa-arrow-down %i.fa.fa-arrow-down
......
...@@ -14,13 +14,9 @@ module Gitlab ...@@ -14,13 +14,9 @@ module Gitlab
def self.read_latest def self.read_latest
path = Rails.root.join("log", file_name) path = Rails.root.join("log", file_name)
self.build unless File.exist?(path)
tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
tail_output.split("\n")
end
def self.read_latest_for(filename) return [] unless File.readable?(path)
path = Rails.root.join("log", filename)
tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
tail_output.split("\n") tail_output.split("\n")
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment