diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 09:10:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 09:10:37 +0300 |
commit | e173c316de15057b099a93053c9ef16180d6d1de (patch) | |
tree | b0b7b4223b5450f4c77c6d6ce087f151e2415bb4 | |
parent | 6eba378ec4193d168af62094caf8a69dd62ad5fd (diff) |
Add latest changes from gitlab-org/gitlab@master
27 files changed, 138 insertions, 98 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index 12505642611..acb80bd194b 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -136,13 +136,13 @@ /doc/user/snippets.md @aqualls [Docs Growth] -/doc/administration/instance_review.md @aqualls -/doc/api/invitations.md @aqualls -/doc/api/experiments.md @aqualls -/doc/development/experiment_guide/ @aqualls -/doc/development/snowplow/ @aqualls -/doc/development/usage_ping/ @aqualls -/doc/user/admin_area/license.md @aqualls +/doc/administration/instance_review.md @kpaizee +/doc/api/invitations.md @kpaizee +/doc/api/experiments.md @kpaizee +/doc/development/experiment_guide/ @kpaizee +/doc/development/snowplow/ @kpaizee +/doc/development/usage_ping/ @kpaizee +/doc/user/admin_area/license.md @kpaizee [Frontend] *.scss @annabeldunstone @gitlab-org/maintainers/frontend diff --git a/app/assets/javascripts/pages/admin/labels/index/index.js b/app/assets/javascripts/pages/admin/labels/index/index.js index e5ab5d43bbf..17ee7c03ed6 100644 --- a/app/assets/javascripts/pages/admin/labels/index/index.js +++ b/app/assets/javascripts/pages/admin/labels/index/index.js @@ -1,3 +1,21 @@ -import initDeprecatedRemoveRowBehavior from '~/behaviors/deprecated_remove_row_behavior'; +document.addEventListener('DOMContentLoaded', () => { + const pagination = document.querySelector('.labels .gl-pagination'); + const emptyState = document.querySelector('.labels .nothing-here-block.hidden'); -document.addEventListener('DOMContentLoaded', initDeprecatedRemoveRowBehavior); + function removeLabelSuccessCallback() { + this.closest('li').classList.add('gl-display-none!'); + + const labelsCount = document.querySelectorAll( + 'ul.manage-labels-list li:not(.gl-display-none\\!)', + ).length; + + // display the empty state if there are no more labels + if (labelsCount < 1 && !pagination && emptyState) { + emptyState.classList.remove('hidden'); + } + } + + document.querySelectorAll('.js-remove-label').forEach((row) => { + row.addEventListener('ajax:success', removeLabelSuccessCallback); + }); +}); diff --git a/app/controllers/admin/labels_controller.rb b/app/controllers/admin/labels_controller.rb index be63bf4c7ce..6cc11b40de0 100644 --- a/app/controllers/admin/labels_controller.rb +++ b/app/controllers/admin/labels_controller.rb @@ -47,7 +47,7 @@ class Admin::LabelsController < Admin::ApplicationController format.html do redirect_to admin_labels_path, status: :found, notice: _('Label was removed') end - format.js + format.js { head :ok } end end diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 55801fea6c7..e03f2ae3d52 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -25,9 +25,7 @@ module Ci # rubocop: disable CodeReuse/ActiveRecord def reprocess!(build) - unless can?(current_user, :update_build, build) - raise Gitlab::Access::AccessDeniedError - end + check_access!(build) attributes = self.class.clone_accessors.to_h do |attribute| [attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend @@ -52,6 +50,12 @@ module Ci private + def check_access!(build) + unless can?(current_user, :update_build, build) + raise Gitlab::Access::AccessDeniedError + end + end + def create_build!(attributes) build = project.builds.new(attributes) build.assign_attributes(::Gitlab::Ci::Pipeline::Seed::Build.environment_attributes_for(build)) diff --git a/app/views/admin/labels/_label.html.haml b/app/views/admin/labels/_label.html.haml index a357c3d9d34..16661efce04 100644 --- a/app/views/admin/labels/_label.html.haml +++ b/app/views/admin/labels/_label.html.haml @@ -3,5 +3,5 @@ .label-actions-list = link_to edit_admin_label_path(label), class: 'btn btn-default gl-button btn-default-tertiary label-action has-tooltip', title: _('Edit'), data: { placement: 'bottom' }, aria_label: _('Edit') do = sprite_icon('pencil') - = link_to admin_label_path(label), class: 'btn btn-default gl-button btn-default-tertiary hover-red js-remove-row label-action has-tooltip', title: _('Delete'), data: { placement: 'bottom', confirm: "Delete this label? Are you sure?" }, aria_label: _('Delete'), method: :delete, remote: true do + = link_to admin_label_path(label), class: 'btn btn-default gl-button btn-default-tertiary hover-red js-remove-label label-action has-tooltip', title: _('Delete'), data: { placement: 'bottom', confirm: "Delete this label? Are you sure?" }, aria_label: _('Delete'), method: :delete, remote: true do = sprite_icon('remove') diff --git a/app/views/admin/labels/destroy.js.haml b/app/views/admin/labels/destroy.js.haml deleted file mode 100644 index 5ee53088230..00000000000 --- a/app/views/admin/labels/destroy.js.haml +++ /dev/null @@ -1,3 +0,0 @@ -- if @labels.size == 0 - var emptyState = document.querySelector('.labels .nothing-here-block.hidden'); - if (emptyState) emptyState.classList.remove('hidden'); diff --git a/app/views/ide/_show.html.haml b/app/views/ide/_show.html.haml index 89c029621e7..755c4151115 100644 --- a/app/views/ide/_show.html.haml +++ b/app/views/ide/_show.html.haml @@ -4,7 +4,7 @@ - add_page_specific_style 'page_bundles/build' - add_page_specific_style 'page_bundles/ide' -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco') #ide.ide-loading{ data: ide_data } diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 329c660f3a0..b28cd47efcc 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -32,7 +32,7 @@ - if page_canonical_link %link{ rel: 'canonical', href: page_canonical_link } - = yield :monaco_tag + = yield :prefetch_asset_tags = favicon_link_tag favicon, id: 'favicon', data: { original_href: favicon }, type: 'image/png' diff --git a/app/views/projects/blob/edit.html.haml b/app/views/projects/blob/edit.html.haml index 68c24e994f6..9f89981e7ca 100644 --- a/app/views/projects/blob/edit.html.haml +++ b/app/views/projects/blob/edit.html.haml @@ -1,6 +1,6 @@ - breadcrumb_title _("Repository") - page_title _("Edit"), @blob.path, @ref -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco') - if @conflict diff --git a/app/views/projects/blob/show.html.haml b/app/views/projects/blob/show.html.haml index d92ecd7e037..1ba38808937 100644 --- a/app/views/projects/blob/show.html.haml +++ b/app/views/projects/blob/show.html.haml @@ -1,7 +1,7 @@ - breadcrumb_title "Repository" - page_title @blob.path, @ref - signatures_path = namespace_project_signatures_path(namespace_id: @project.namespace.full_path, project_id: @project.path, id: @last_commit, limit: 1) -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco', prefetch: true) .js-signature-container{ data: { 'signatures-path': signatures_path } } diff --git a/app/views/projects/ci/pipeline_editor/show.html.haml b/app/views/projects/ci/pipeline_editor/show.html.haml index ca3f671c9fb..674765e9f89 100644 --- a/app/views/projects/ci/pipeline_editor/show.html.haml +++ b/app/views/projects/ci/pipeline_editor/show.html.haml @@ -1,5 +1,5 @@ - page_title s_('Pipelines|Pipeline Editor') -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco') #js-pipeline-editor{ data: js_pipeline_editor_data(@project) } diff --git a/app/views/snippets/edit.html.haml b/app/views/snippets/edit.html.haml index 6e0126fd2fd..f737e347c39 100644 --- a/app/views/snippets/edit.html.haml +++ b/app/views/snippets/edit.html.haml @@ -1,6 +1,6 @@ - page_title _("Edit"), "#{@snippet.title} (#{@snippet.to_reference})", _("Snippets") - @content_class = "limit-container-width" unless fluid_layout -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco') %h3.page-title diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index 534bbbef437..4fdb9e70742 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -9,7 +9,7 @@ - add_to_breadcrumbs _("Snippets"), dashboard_snippets_path - breadcrumb_title @snippet.to_reference - page_title "#{@snippet.title} (#{@snippet.to_reference})", _("Snippets") -- content_for :monaco_tag do +- content_for :prefetch_asset_tags do - webpack_preload_asset_tag('monaco', prefetch: true) #js-snippet-view{ data: {'qa-selector': 'snippet_view', 'snippet-gid': @snippet.to_global_id} } diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index b216c2bff28..07c1ce0d939 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -2116,15 +2116,6 @@ :idempotent: true :tags: - :exclude_from_kubernetes -- :name: git_garbage_collect - :worker_name: GitGarbageCollectWorker - :feature_category: :gitaly - :has_external_dependencies: - :urgency: :low - :resource_boundary: :unknown - :weight: 1 - :idempotent: - :tags: [] - :name: github_import_advance_stage :worker_name: Gitlab::GithubImport::AdvanceStageWorker :feature_category: :importers diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb deleted file mode 100644 index a2aab23db7b..00000000000 --- a/app/workers/git_garbage_collect_worker.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# According to our docs, we can only remove workers on major releases -# https://docs.gitlab.com/ee/development/sidekiq_style_guide.html#removing-workers. -# -# We need to still maintain this until 14.0 but with the current functionality. -# -# In https://gitlab.com/gitlab-org/gitlab/-/issues/299290 we track that removal. -class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker - include ApplicationWorker - - sidekiq_options retry: false - feature_category :gitaly - loggable_arguments 1, 2, 3 - - def perform(project_id, task = :gc, lease_key = nil, lease_uuid = nil) - ::Projects::GitGarbageCollectWorker.new.perform(project_id, task, lease_key, lease_uuid) - end -end diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb index 64d2b8e627a..dc14789fe73 100644 --- a/app/workers/pipeline_process_worker.rb +++ b/app/workers/pipeline_process_worker.rb @@ -10,6 +10,7 @@ class PipelineProcessWorker # rubocop:disable Scalability/IdempotentWorker feature_category :continuous_integration urgency :high loggable_arguments 1 + data_consistency :delayed, feature_flag: :load_balancing_for_pipeline_process_worker # rubocop: disable CodeReuse/ActiveRecord # `_build_ids` is deprecated and will be removed in 14.0 diff --git a/config/feature_flags/development/load_balancing_for_pipeline_process_worker.yml b/config/feature_flags/development/load_balancing_for_pipeline_process_worker.yml new file mode 100644 index 00000000000..08d7f6617d2 --- /dev/null +++ b/config/feature_flags/development/load_balancing_for_pipeline_process_worker.yml @@ -0,0 +1,8 @@ +--- +name: load_balancing_for_pipeline_process_worker +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61766 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/330960 +milestone: '13.12' +type: development +group: group::continuous integration +default_enabled: false diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index fed37b99715..02fe21a9e6e 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -152,8 +152,6 @@ - 1 - - geo - 1 -- - git_garbage_collect - - 1 - - github_import_advance_stage - 1 - - github_importer diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index b6130335654..dd3945ae324 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -246,6 +246,55 @@ Layout to be recalculated, which is much more expensive. For details on this, se If you _do_ need to change layout (for example, a sidebar that pushes main content over), prefer [FLIP](https://aerotwist.com/blog/flip-your-animations/). FLIP allows you to change expensive properties once, and handle the actual animation with transforms. +### Prefetching assets + +In addition to prefetching data from the [API](graphql.md#making-initial-queries-early-with-graphql-startup-calls) +we allow prefetching the named JavaScript "chunks" as +[defined in the Webpack configuration](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/webpack.config.js#L298-359). +We support two types of prefetching for the chunks: + +- The [`prefetch` link type](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/prefetch) + is used to prefetch a chunk for the future navigation +- The [`preload` link type](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preloadh) + is used to prefetch a chunk that is crucial for the current navigation but is not + discovered until later in the rendering process + +Both `prefetch` and `preload` links bring the loading performance benefit to the pages. Both are +fetched asynchronously, but contrary to [deferring the loading](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-defer) +of the assets which is used for other JavaScript resources in the product by default, `prefetch` and +`preload` neither parse nor execute the fetched script unless explicitly imported in any JavaScript +module. This allows to cache the fetched resources without blocking the execution of the +remaining page resources. + +To prefetch a JavaScript chunk in a HAML view, `:prefetch_asset_tags` with the combination of +the `webpack_preload_asset_tag` helper is provided: + +```javascript +- content_for :prefetch_asset_tags do + - webpack_preload_asset_tag('monaco') +``` + +This snippet will add a new `<link rel="preload">` element into the resulting HTML page: + +```HTML +<link rel="preload" href="/assets/webpack/monaco.chunk.js" as="script" type="text/javascript"> +``` + +By default, `webpack_preload_asset_tag` will `preload` the chunk. You don't need to worry about +`as` and `type` attributes for preloading the JavaScript chunks. However, when a chunk is not +critical, for the current navigation, one has to explicitly request `prefetch`: + +```javascript +- content_for :prefetch_asset_tags do + - webpack_preload_asset_tag('monaco', prefetch: true) +``` + +This snippet will add a new `<link rel="prefetch">` element into the resulting HTML page: + +```HTML +<link rel="prefetch" href="/assets/webpack/monaco.chunk.js"> +``` + ## Reducing Asset Footprint ### Universal code diff --git a/doc/development/performance.md b/doc/development/performance.md index f81e6417f0e..c6fe9f29b53 100644 --- a/doc/development/performance.md +++ b/doc/development/performance.md @@ -365,14 +365,16 @@ This patch is available by default for [GCK](https://gitlab.com/gitlab-org/gitlab-compose-kit/-/merge_requests/149) and can additionally be enabled for [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/advanced.md#apply-custom-patches-for-ruby). -This patch provides a set of 3 metrics that makes it easier to understand efficiency of memory usage for a given codepath: +This patch provides the following metrics that make it easier to understand efficiency of memory use for a given codepath: +- `mem_total_bytes`: the number of bytes consumed both due to new objects being allocated into existing object slots + plus additional memory allocated for large objects (that is, `mem_bytes + slot_size * mem_objects`). +- `mem_bytes`: the number of bytes allocated by `malloc` for objects that did not fit into an existing object slot. - `mem_objects`: the number of objects allocated. -- `mem_bytes`: the number of bytes allocated by malloc. -- `mem_mallocs`: the number of malloc allocations. +- `mem_mallocs`: the number of `malloc` calls. The number of objects and bytes allocated impact how often GC cycles happen. -Fewer objects allocations result in a significantly more responsive application. +Fewer object allocations result in a significantly more responsive application. It is advised that web server requests do not allocate more than `100k mem_objects` and `100M mem_bytes`. You can view the current usage on [GitLab.com](https://log.gprd.gitlab.net/goto/3a9678bb595e3f89a0c7b5c61bcc47b9). diff --git a/doc/user/project/merge_requests/test_coverage_visualization.md b/doc/user/project/merge_requests/test_coverage_visualization.md index 41b6044d1a5..c25ee1a8a94 100644 --- a/doc/user/project/merge_requests/test_coverage_visualization.md +++ b/doc/user/project/merge_requests/test_coverage_visualization.md @@ -82,6 +82,14 @@ to the project root: ```shell Auth/User.cs Lib/Utils/User.cs +src/main/java +``` + +In the Cobertura XML, the `filename` attribute in the `class` element assumes the value is a +relative path to project's root. + +```xml +<class name="packet.name" filename="src/main/java" line-rate="0.0" branch-rate="0.0" complexity="5"> ``` And the `sources` from Cobertura XML with paths in the format of `<CI_BUILDS_DIR>/<PROJECT_FULL_PATH>/...`: @@ -153,7 +161,7 @@ coverage-jdk11: stage: visualize image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 script: - # convert report from jacoco to cobertura + # convert report from jacoco to cobertura, use relative project path - 'python /opt/cover2cover.py target/site/jacoco/jacoco.xml src/main/java > target/site/cobertura.xml' # read the <source></source> tag and prepend the path to every filename attribute - 'python /opt/source2filename.py target/site/cobertura.xml' @@ -193,7 +201,7 @@ coverage-jdk11: stage: visualize image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.7 script: - # convert report from jacoco to cobertura + # convert report from jacoco to cobertura, use relative project path - 'python /opt/cover2cover.py build/jacoco/jacoco.xml src/main/java > build/cobertura.xml' # read the <source></source> tag and prepend the path to every filename attribute - 'python /opt/source2filename.py build/cobertura.xml' diff --git a/lib/gitlab/memory/instrumentation.rb b/lib/gitlab/memory/instrumentation.rb index 8f9f6d19ce8..e800fe14cf1 100644 --- a/lib/gitlab/memory/instrumentation.rb +++ b/lib/gitlab/memory/instrumentation.rb @@ -45,9 +45,12 @@ module Gitlab end # This method returns a hash with the following keys: - # - mem_objects: a number of allocated heap slots (as reflected by GC) - # - mem_mallocs: a number of malloc calls - # - mem_bytes: a number of bytes allocated with a mallocs tied to heap slots + # - mem_objects: number of allocated heap slots (as reflected by GC) + # - mem_mallocs: number of malloc calls + # - mem_bytes: number of bytes allocated by malloc for objects that did not fit + # into a heap slot + # - mem_total_bytes: number of bytes allocated for both objects consuming an object slot + # and objects that required a malloc (mem_malloc_bytes) def self.measure_thread_memory_allocations(previous) return unless available? return unless previous @@ -56,9 +59,13 @@ module Gitlab return unless current # calculate difference in a memory allocations - previous.to_h do |key, value| + result = previous.to_h do |key, value| [KEY_MAPPING.fetch(key), current[key].to_i - value] end + + result[:mem_total_bytes] = result[:mem_bytes] + result[:mem_objects] * GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] + + result end def self.with_memory_allocations diff --git a/lib/security/ci_configuration/sast_build_action.rb b/lib/security/ci_configuration/sast_build_action.rb index d670d5054ae..23dd4bd6d14 100644 --- a/lib/security/ci_configuration/sast_build_action.rb +++ b/lib/security/ci_configuration/sast_build_action.rb @@ -15,11 +15,6 @@ module Security private def variables(params) - # This early return is necessary for supporting REST API. - # Will be removed during the implementation of - # https://gitlab.com/gitlab-org/gitlab/-/issues/246737 - return params unless params['global'].present? - collect_values(params, 'value') end diff --git a/spec/features/admin/admin_labels_spec.rb b/spec/features/admin/admin_labels_spec.rb index 43fb1f31a0f..08d81906d9f 100644 --- a/spec/features/admin/admin_labels_spec.rb +++ b/spec/features/admin/admin_labels_spec.rb @@ -36,7 +36,7 @@ RSpec.describe 'admin issues labels' do it 'deletes all labels', :js do page.within '.labels' do - page.all('.js-remove-row').each do |remove| + page.all('.js-remove-label').each do |remove| accept_confirm { remove.click } wait_for_requests end diff --git a/spec/lib/gitlab/memory/instrumentation_spec.rb b/spec/lib/gitlab/memory/instrumentation_spec.rb index 6b53550a3d0..0dbe9a8e275 100644 --- a/spec/lib/gitlab/memory/instrumentation_spec.rb +++ b/spec/lib/gitlab/memory/instrumentation_spec.rb @@ -69,10 +69,12 @@ RSpec.describe Gitlab::Memory::Instrumentation do end it 'a hash is returned' do - is_expected.to include( + result = subject + expect(result).to include( mem_objects: be > 1000, mem_mallocs: be > 1000, - mem_bytes: be > 100_000 # 100 items * 100 bytes each + mem_bytes: be > 100_000, # 100 items * 100 bytes each + mem_total_bytes: eq(result[:mem_bytes] + 40 * result[:mem_objects]) ) end end diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb deleted file mode 100644 index 3df64c35166..00000000000 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -require 'fileutils' - -require 'spec_helper' - -RSpec.describe GitGarbageCollectWorker do - let_it_be(:project) { create(:project, :repository) } - - let(:lease_uuid) { SecureRandom.uuid } - let(:lease_key) { "project_housekeeping:#{project.id}" } - let(:task) { :full_repack } - let(:params) { [project.id, task, lease_key, lease_uuid] } - - subject { described_class.new } - - describe "#perform" do - it 'calls the Projects::GitGarbageGitGarbageCollectWorker with the same params' do - expect_next_instance_of(Projects::GitGarbageCollectWorker) do |instance| - expect(instance).to receive(:perform).with(*params) - end - - subject.perform(*params) - end - end -end diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb index 5d45a131095..0c1db3ccc5a 100644 --- a/spec/workers/pipeline_process_worker_spec.rb +++ b/spec/workers/pipeline_process_worker_spec.rb @@ -20,5 +20,10 @@ RSpec.describe PipelineProcessWorker do .not_to raise_error end end + + it_behaves_like 'worker with data consistency', + described_class, + feature_flag: :load_balancing_for_pipeline_process_worker, + data_consistency: :delayed end end |