Class: Ci::AppendBuildTraceService
- Inherits:
-
Object
- Object
- Ci::AppendBuildTraceService
- Defined in:
- app/services/ci/append_build_trace_service.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- TraceRangeError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #execute(body_data) ⇒ Object
-
#initialize(build, params) ⇒ AppendBuildTraceService
constructor
A new instance of AppendBuildTraceService.
Constructor Details
#initialize(build, params) ⇒ AppendBuildTraceService
Returns a new instance of AppendBuildTraceService.
10 11 12 13 |
# File 'app/services/ci/append_build_trace_service.rb', line 10 def initialize(build, params) @build = build @params = params end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
8 9 10 |
# File 'app/services/ci/append_build_trace_service.rb', line 8 def build @build end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'app/services/ci/append_build_trace_service.rb', line 8 def params @params end |
Instance Method Details
#execute(body_data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/ci/append_build_trace_service.rb', line 15 def execute(body_data) # TODO: # it seems that `Content-Range` as formatted by runner is wrong, # the `byte_end` should point to final byte, but it points byte+1 # that means that we have to calculate end of body, # as we cannot use `content_length[1]` # Issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/3275 content_range = stream_range.split('-') body_start = content_range[0].to_i body_end = body_start + body_data.bytesize if first_debug_chunk?(body_start) # Update the build metadata prior to appending trace content build.enable_debug_trace! end if trace_size_exceeded?(body_end) build.drop(:trace_size_exceeded) return Result.new(status: 403) end stream_size = build.trace.append(body_data, body_start) unless stream_size == body_end log_range_error(stream_size, body_end) return Result.new(status: 416, stream_size: stream_size) end Result.new(status: 202, stream_size: stream_size) end |