Commit 2f3f1707 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 42d914d2 7d0c5285
# frozen_string_literal: true
module Ci
class AppendBuildTraceService
Result = Struct.new(:status, :stream_size, keyword_init: true)
TraceRangeError = Class.new(StandardError)
attr_reader :build, :params
def initialize(build, params)
@build = build
@params = params
end
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
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
private
def stream_range
params.fetch(:content_range)
end
def log_range_error(stream_size, body_end)
extra = {
build_id: build.id,
body_end: body_end,
stream_size: stream_size,
stream_class: stream_size.class,
stream_range: stream_range
}
build.trace_chunks.last.try do |chunk|
extra.merge!(
chunk_index: chunk.chunk_index,
chunk_store: chunk.data_store,
chunks_count: build.trace_chunks.count
)
end
::Gitlab::ErrorTracking
.log_exception(TraceRangeError.new, extra)
end
end
end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
- page_title _("Environments") - page_title _("Environments")
- add_page_specific_style 'page_bundles/xterm' - add_page_specific_style 'page_bundles/xterm'
- add_page_specific_style 'page_bundles/environments' - add_page_specific_style 'page_bundles/environments'
- add_page_specific_style 'page_bundles/ci_status'
#environments-detail-view{ data: { name: @environment.name, id: @environment.id, delete_path: environment_delete_path(@environment)} } #environments-detail-view{ data: { name: @environment.name, id: @environment.id, delete_path: environment_delete_path(@environment)} }
- if @environment.available? && can?(current_user, :stop_environment, @environment) - if @environment.available? && can?(current_user, :stop_environment, @environment)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
%button.dropdown-menu-toggle.js-user-search.js-author-search.js-multiselect.js-save-user-data.js-issue-board-sidebar{ type: 'button', ref: 'assigneeDropdown', data: board_sidebar_user_data, %button.dropdown-menu-toggle.js-user-search.js-author-search.js-multiselect.js-save-user-data.js-issue-board-sidebar{ type: 'button', ref: 'assigneeDropdown', data: board_sidebar_user_data,
":data-issuable-id" => "issue.iid" } ":data-issuable-id" => "issue.iid" }
= dropdown_options[:title] = dropdown_options[:title]
= icon("chevron-down") = sprite_icon('chevron-down', css_class: "dropdown-menu-toggle-icon gl-top-3")
.dropdown-menu.dropdown-select.dropdown-menu-user.dropdown-menu-selectable.dropdown-menu-author .dropdown-menu.dropdown-select.dropdown-menu-user.dropdown-menu-selectable.dropdown-menu-author
= dropdown_title("Assign to") = dropdown_title("Assign to")
= dropdown_filter("Search users") = dropdown_filter("Search users")
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
%button.dropdown-menu-toggle.js-due-date-select.js-issue-boards-due-date{ type: 'button', %button.dropdown-menu-toggle.js-due-date-select.js-issue-boards-due-date{ type: 'button',
data: { toggle: 'dropdown', field_name: "issue[due_date]", ability_name: "issue" } } data: { toggle: 'dropdown', field_name: "issue[due_date]", ability_name: "issue" } }
%span.dropdown-toggle-text= _("Due date") %span.dropdown-toggle-text= _("Due date")
= icon('chevron-down') = sprite_icon('chevron-down', css_class: "dropdown-menu-toggle-icon gl-top-3")
.dropdown-menu.dropdown-menu-due-date .dropdown-menu.dropdown-menu-due-date
= dropdown_title(_('Due date')) = dropdown_title(_('Due date'))
= dropdown_content do = dropdown_content do
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
data: label_dropdown_data(@project, namespace_path: @namespace_path, field_name: "issue[label_names][]") } data: label_dropdown_data(@project, namespace_path: @namespace_path, field_name: "issue[label_names][]") }
%span.dropdown-toggle-text %span.dropdown-toggle-text
{{ labelDropdownTitle }} {{ labelDropdownTitle }}
= icon('chevron-down') = sprite_icon('chevron-down', css_class: "dropdown-menu-toggle-icon gl-top-3")
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable.dropdown-extended-height .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable.dropdown-extended-height
= render partial: "shared/issuable/label_page_default" = render partial: "shared/issuable/label_page_default"
- if can?(current_user, :admin_label, current_board_parent) - if can?(current_user, :admin_label, current_board_parent)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
":data-issuable-id" => "issue.iid", ":data-issuable-id" => "issue.iid",
":data-project-id" => "issue.project_id" } ":data-project-id" => "issue.project_id" }
= _("Milestone") = _("Milestone")
= icon("chevron-down") = sprite_icon('chevron-down', css_class: "dropdown-menu-toggle-icon gl-top-3")
.dropdown-menu.dropdown-select.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-selectable
= dropdown_title(_("Assign milestone")) = dropdown_title(_("Assign milestone"))
= dropdown_filter(_("Search milestones")) = dropdown_filter(_("Search milestones"))
......
---
title: Replace chevron-down fa-icon in board sidebar
merge_request: 46075
author:
type: other
---
title: Add CI Status CSS to the Environments Page
merge_request: 46382
author:
type: fixed
...@@ -34,6 +34,6 @@ export default { ...@@ -34,6 +34,6 @@ export default {
data-toggle="dropdown" data-toggle="dropdown"
> >
<span class="dropdown-toggle-text" :class="toggleTextClass">{{ buttonText }}</span> <span class="dropdown-toggle-text" :class="toggleTextClass">{{ buttonText }}</span>
<gl-icon name="chevron-down" class="dropdown-menu-toggle-icon" /> <gl-icon name="chevron-down" class="dropdown-menu-toggle-icon gl-top-3" />
</button> </button>
</template> </template>
...@@ -207,27 +207,18 @@ module API ...@@ -207,27 +207,18 @@ module API
error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range') error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')
content_range = request.headers['Content-Range'] content_range = request.headers['Content-Range']
content_range = content_range.split('-')
# TODO: result = ::Ci::AppendBuildTraceService
# it seems that `Content-Range` as formatted by runner is wrong, .new(job, content_range: content_range)
# the `byte_end` should point to final byte, but it points byte+1 .execute(request.body.read)
# 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
body_data = request.body.read if result.status == 416
body_start = content_range[0].to_i break error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{result.stream_size}" })
body_end = body_start + body_data.bytesize
stream_size = job.trace.append(body_data, body_start)
unless stream_size == body_end
break error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{stream_size}" })
end end
status 202 status result.status
header 'Job-Status', job.status header 'Job-Status', job.status
header 'Range', "0-#{stream_size}" header 'Range', "0-#{result.stream_size}"
header 'X-GitLab-Trace-Update-Interval', job.trace.update_interval.to_s header 'X-GitLab-Trace-Update-Interval', job.trace.update_interval.to_s
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::AppendBuildTraceService do
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
before do
stub_feature_flags(ci_enable_live_trace: true)
end
context 'build trace append is successful' do
it 'returns a correct stream size and status code' do
stream_size = 192.kilobytes
body_data = 'x' * stream_size
content_range = "0-#{stream_size}"
result = described_class
.new(build, content_range: content_range)
.execute(body_data)
expect(result.status).to eq 202
expect(result.stream_size).to eq stream_size
expect(build.trace_chunks.count).to eq 2
end
end
context 'when could not correctly append to a trace' do
it 'responds with content range violation and data stored' do
allow(build).to receive_message_chain(:trace, :append) { 16 }
result = described_class
.new(build, content_range: '0-128')
.execute('x' * 128)
expect(result.status).to eq 416
expect(result.stream_size).to eq 16
end
it 'logs exception if build has live trace' do
build.trace.append('abcd', 0)
expect(::Gitlab::ErrorTracking)
.to receive(:log_exception)
.with(anything, hash_including(chunk_index: 0, chunk_store: 'redis'))
result = described_class
.new(build, content_range: '0-128')
.execute('x' * 128)
expect(result.status).to eq 416
expect(result.stream_size).to eq 4
end
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