diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-08-22 17:09:45 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-08-22 17:09:45 -0400 |
commit | 4598e0c3924b30d11495e803e88a6ded11094318 (patch) | |
tree | 6463fd25b23813d4695ec902dbd965aa876a37f9 /lib | |
parent | 7965f4e7c3826093a74d4909233dc7fb9c0aac97 (diff) | |
download | gitlab-ce-4598e0c3924b30d11495e803e88a6ded11094318.tar.gz |
Fix a potential timeout in `Gitlab::Logger.read_latest`
If this method was called for a file that didn't exist, we attempted to
first `build` it. But if the file wasn't writeable, such as a symlink
pointing to an unmounted filesystem, the method would just hang and
eventually timeout.
Further, this was entirely pointless since we were creating a file and
then shelling out to `tail`, eventually returning an empty Array. Now we
just skip building it and return the empty Array straight away.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/logger.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 59b21149a9a..6bffd410ed0 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -14,13 +14,9 @@ module Gitlab def self.read_latest 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) - path = Rails.root.join("log", filename) + return [] unless File.readable?(path) + tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) tail_output.split("\n") end |