Class: Gitlab::Ci::Trace
- Inherits:
-
Object
show all
- Includes:
- Checksummable, ExclusiveLeaseHelpers
- Defined in:
- lib/gitlab/ci/trace.rb,
lib/gitlab/ci/trace/stream.rb,
lib/gitlab/ci/trace/metrics.rb,
lib/gitlab/ci/trace/chunked_io.rb,
lib/gitlab/ci/trace/section_parser.rb
Defined Under Namespace
Classes: ChunkedIO, Metrics, SectionParser, Stream
Constant Summary
collapse
- LOCK_TTL =
10.minutes
- LOCK_RETRIES =
2
- LOCK_SLEEP =
0.001.seconds
- WATCH_FLAG_TTL =
10.seconds
- UPDATE_FREQUENCY_DEFAULT =
30.seconds
- UPDATE_FREQUENCY_WHEN_BEING_WATCHED =
3.seconds
- ArchiveError =
Class.new(StandardError)
- AlreadyArchivedError =
Class.new(StandardError)
ExclusiveLeaseHelpers::FailedToObtainLockError
Instance Attribute Summary collapse
Instance Method Summary
collapse
#crc32
#in_lock
Constructor Details
#initialize(job) ⇒ Trace
Returns a new instance of Trace.
24
25
26
|
# File 'lib/gitlab/ci/trace.rb', line 24
def initialize(job)
@job = job
end
|
Instance Attribute Details
#job ⇒ Object
Returns the value of attribute job
20
21
22
|
# File 'lib/gitlab/ci/trace.rb', line 20
def job
@job
end
|
Instance Method Details
#append(data, offset) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/gitlab/ci/trace.rb', line 59
def append(data, offset)
write('a+b') do |stream|
current_length = stream.size
break current_length unless current_length == offset
data = job.hide_secrets(data)
stream.append(data, offset)
stream.size
end
end
|
#archive! ⇒ Object
111
112
113
114
115
|
# File 'lib/gitlab/ci/trace.rb', line 111
def archive!
in_write_lock do
unsafe_archive!
end
end
|
#archived_trace_exist? ⇒ Boolean
74
75
76
|
# File 'lib/gitlab/ci/trace.rb', line 74
def archived_trace_exist?
trace_artifact&.exists?
end
|
#being_watched? ⇒ Boolean
127
128
129
130
131
|
# File 'lib/gitlab/ci/trace.rb', line 127
def being_watched?
Gitlab::Redis::SharedState.with do |redis|
redis.exists(being_watched_cache_key)
end
end
|
#erase! ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/gitlab/ci/trace.rb', line 97
def erase!
trace_artifact&.destroy!
job.trace_chunks.fast_destroy_all FileUtils.rm_f(current_path) if current_path job.erase_old_trace! if job.has_old_trace? ensure
@current_path = nil
end
|
#exist? ⇒ Boolean
70
71
72
|
# File 'lib/gitlab/ci/trace.rb', line 70
def exist?
archived_trace_exist? || live_trace_exist?
end
|
40
41
42
43
44
|
# File 'lib/gitlab/ci/trace.rb', line 40
def (regex)
read do |stream|
stream.(regex)
end
end
|
46
47
48
49
50
|
# File 'lib/gitlab/ci/trace.rb', line 46
def
read do |stream|
stream.
end
end
|
#html(last_lines: nil) ⇒ Object
28
29
30
31
32
|
# File 'lib/gitlab/ci/trace.rb', line 28
def html(last_lines: nil)
read do |stream|
stream.html(last_lines: last_lines)
end
end
|
#live_trace_exist? ⇒ Boolean
78
79
80
|
# File 'lib/gitlab/ci/trace.rb', line 78
def live_trace_exist?
job.trace_chunks.any? || current_path.present? || old_trace.present?
end
|
#raw(last_lines: nil) ⇒ Object
34
35
36
37
38
|
# File 'lib/gitlab/ci/trace.rb', line 34
def raw(last_lines: nil)
read do |stream|
stream.raw(last_lines: last_lines)
end
end
|
#read(should_retry: true, &block) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/gitlab/ci/trace.rb', line 82
def read(should_retry: true, &block)
read_stream(&block)
rescue Errno::ENOENT
raise unless should_retry
job.reset
read_stream(&block)
end
|
#set(data) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/gitlab/ci/trace.rb', line 52
def set(data)
write('w+b') do |stream|
data = job.hide_secrets(data)
stream.set(data)
end
end
|
#update_interval ⇒ Object
#write(mode, &blk) ⇒ Object
91
92
93
94
95
|
# File 'lib/gitlab/ci/trace.rb', line 91
def write(mode, &blk)
in_write_lock do
unsafe_write!(mode, &blk)
end
end
|