diff --git a/Gemfile b/Gemfile index 00ec5e5c58d..7d63a5f50c0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '~> 6.0.3' +gem 'rails', '~> 6.0.3.1' gem 'bootsnap', '~> 1.4.6' diff --git a/Gemfile.lock b/Gemfile.lock index 92bc594a7d2..31ff0fb304c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,59 +6,59 @@ GEM ace-rails-ap (4.1.2) acme-client (2.0.5) faraday (~> 0.9, >= 0.9.1) - actioncable (6.0.3) - actionpack (= 6.0.3) + actioncable (6.0.3.1) + actionpack (= 6.0.3.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.3) - actionpack (= 6.0.3) - activejob (= 6.0.3) - activerecord (= 6.0.3) - activestorage (= 6.0.3) - activesupport (= 6.0.3) + actionmailbox (6.0.3.1) + actionpack (= 6.0.3.1) + activejob (= 6.0.3.1) + activerecord (= 6.0.3.1) + activestorage (= 6.0.3.1) + activesupport (= 6.0.3.1) mail (>= 2.7.1) - actionmailer (6.0.3) - actionpack (= 6.0.3) - actionview (= 6.0.3) - activejob (= 6.0.3) + actionmailer (6.0.3.1) + actionpack (= 6.0.3.1) + actionview (= 6.0.3.1) + activejob (= 6.0.3.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.3) - actionview (= 6.0.3) - activesupport (= 6.0.3) + actionpack (6.0.3.1) + actionview (= 6.0.3.1) + activesupport (= 6.0.3.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.3) - actionpack (= 6.0.3) - activerecord (= 6.0.3) - activestorage (= 6.0.3) - activesupport (= 6.0.3) + actiontext (6.0.3.1) + actionpack (= 6.0.3.1) + activerecord (= 6.0.3.1) + activestorage (= 6.0.3.1) + activesupport (= 6.0.3.1) nokogiri (>= 1.8.5) - actionview (6.0.3) - activesupport (= 6.0.3) + actionview (6.0.3.1) + activesupport (= 6.0.3.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.3) - activesupport (= 6.0.3) + activejob (6.0.3.1) + activesupport (= 6.0.3.1) globalid (>= 0.3.6) - activemodel (6.0.3) - activesupport (= 6.0.3) - activerecord (6.0.3) - activemodel (= 6.0.3) - activesupport (= 6.0.3) + activemodel (6.0.3.1) + activesupport (= 6.0.3.1) + activerecord (6.0.3.1) + activemodel (= 6.0.3.1) + activesupport (= 6.0.3.1) activerecord-explain-analyze (0.1.0) activerecord (>= 4) pg - activestorage (6.0.3) - actionpack (= 6.0.3) - activejob (= 6.0.3) - activerecord (= 6.0.3) + activestorage (6.0.3.1) + actionpack (= 6.0.3.1) + activejob (= 6.0.3.1) + activerecord (= 6.0.3.1) marcel (~> 0.3.1) - activesupport (6.0.3) + activesupport (6.0.3.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -801,20 +801,20 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rack-timeout (0.5.1) - rails (6.0.3) - actioncable (= 6.0.3) - actionmailbox (= 6.0.3) - actionmailer (= 6.0.3) - actionpack (= 6.0.3) - actiontext (= 6.0.3) - actionview (= 6.0.3) - activejob (= 6.0.3) - activemodel (= 6.0.3) - activerecord (= 6.0.3) - activestorage (= 6.0.3) - activesupport (= 6.0.3) + rails (6.0.3.1) + actioncable (= 6.0.3.1) + actionmailbox (= 6.0.3.1) + actionmailer (= 6.0.3.1) + actionpack (= 6.0.3.1) + actiontext (= 6.0.3.1) + actionview (= 6.0.3.1) + activejob (= 6.0.3.1) + activemodel (= 6.0.3.1) + activerecord (= 6.0.3.1) + activestorage (= 6.0.3.1) + activesupport (= 6.0.3.1) bundler (>= 1.3.0) - railties (= 6.0.3) + railties (= 6.0.3.1) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) @@ -828,9 +828,9 @@ GEM rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.0.3) - actionpack (= 6.0.3) - activesupport (= 6.0.3) + railties (6.0.3.1) + actionpack (= 6.0.3.1) + activesupport (= 6.0.3.1) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) @@ -1335,7 +1335,7 @@ DEPENDENCIES rack-oauth2 (~> 1.9.3) rack-proxy (~> 0.6.0) rack-timeout - rails (~> 6.0.3) + rails (~> 6.0.3.1) rails-controller-testing rails-i18n (~> 6.0) rainbow (~> 3.0) diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 905a0b9d5ef..e5cd1b005aa 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -244,22 +244,28 @@ export const contentTop = () => { ); }; -export const scrollToElement = element => { +export const scrollToElement = (element, options = {}) => { let $el = element; if (!(element instanceof $)) { $el = $(element); } const { top } = $el.offset(); + const { offset = 0 } = options; // eslint-disable-next-line no-jquery/no-animate return $('body, html').animate( { - scrollTop: top - contentTop(), + scrollTop: top - contentTop() + offset, }, 200, ); }; +export const scrollToElementWithContext = element => { + const offsetMultiplier = -0.1; + return scrollToElement(element, { offset: window.innerHeight * offsetMultiplier }); +}; + /** * Returns a function that can only be invoked once between * each browser screen repaint. diff --git a/app/assets/javascripts/notes/mixins/discussion_navigation.js b/app/assets/javascripts/notes/mixins/discussion_navigation.js index c9026352d18..9281149d9d3 100644 --- a/app/assets/javascripts/notes/mixins/discussion_navigation.js +++ b/app/assets/javascripts/notes/mixins/discussion_navigation.js @@ -1,5 +1,5 @@ import { mapGetters, mapActions, mapState } from 'vuex'; -import { scrollToElement } from '~/lib/utils/common_utils'; +import { scrollToElementWithContext } from '~/lib/utils/common_utils'; import eventHub from '../event_hub'; /** @@ -10,7 +10,7 @@ function scrollTo(selector) { const el = document.querySelector(selector); if (el) { - scrollToElement(el); + scrollToElementWithContext(el); return true; } diff --git a/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue b/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue index 2212428ced5..59c066b2683 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_artifacts.vue @@ -35,7 +35,7 @@ export default { diff --git a/app/assets/javascripts/registry/explorer/components/cli_commands.vue b/app/assets/javascripts/registry/explorer/components/list_page/cli_commands.vue similarity index 99% rename from app/assets/javascripts/registry/explorer/components/cli_commands.vue rename to app/assets/javascripts/registry/explorer/components/list_page/cli_commands.vue index 679d9cf7fab..8b06797c0ae 100644 --- a/app/assets/javascripts/registry/explorer/components/cli_commands.vue +++ b/app/assets/javascripts/registry/explorer/components/list_page/cli_commands.vue @@ -11,7 +11,7 @@ import { COPY_BUILD_TITLE, PUSH_COMMAND_LABEL, COPY_PUSH_TITLE, -} from '../constants/index'; +} from '../../constants/index'; export default { components: { diff --git a/app/assets/javascripts/registry/explorer/components/group_empty_state.vue b/app/assets/javascripts/registry/explorer/components/list_page/group_empty_state.vue similarity index 100% rename from app/assets/javascripts/registry/explorer/components/group_empty_state.vue rename to app/assets/javascripts/registry/explorer/components/list_page/group_empty_state.vue diff --git a/app/assets/javascripts/registry/explorer/components/image_list.vue b/app/assets/javascripts/registry/explorer/components/list_page/image_list.vue similarity index 100% rename from app/assets/javascripts/registry/explorer/components/image_list.vue rename to app/assets/javascripts/registry/explorer/components/list_page/image_list.vue diff --git a/app/assets/javascripts/registry/explorer/components/image_list_row.vue b/app/assets/javascripts/registry/explorer/components/list_page/image_list_row.vue similarity index 99% rename from app/assets/javascripts/registry/explorer/components/image_list_row.vue rename to app/assets/javascripts/registry/explorer/components/list_page/image_list_row.vue index a2b1f615029..f1252b24f6a 100644 --- a/app/assets/javascripts/registry/explorer/components/image_list_row.vue +++ b/app/assets/javascripts/registry/explorer/components/list_page/image_list_row.vue @@ -8,7 +8,7 @@ import { LIST_DELETE_BUTTON_DISABLED, REMOVE_REPOSITORY_LABEL, ROW_SCHEDULED_FOR_DELETION, -} from '../constants/index'; +} from '../../constants/index'; export default { name: 'ImageListrow', diff --git a/app/assets/javascripts/registry/explorer/components/project_empty_state.vue b/app/assets/javascripts/registry/explorer/components/list_page/project_empty_state.vue similarity index 99% rename from app/assets/javascripts/registry/explorer/components/project_empty_state.vue rename to app/assets/javascripts/registry/explorer/components/list_page/project_empty_state.vue index 87bb65ae0a9..c27d53f4351 100644 --- a/app/assets/javascripts/registry/explorer/components/project_empty_state.vue +++ b/app/assets/javascripts/registry/explorer/components/list_page/project_empty_state.vue @@ -8,7 +8,7 @@ import { COPY_BUILD_TITLE, COPY_PUSH_TITLE, QUICK_START, -} from '../constants/index'; +} from '../../constants/index'; export default { name: 'ProjectEmptyState', diff --git a/app/assets/javascripts/registry/explorer/components/registry_header.vue b/app/assets/javascripts/registry/explorer/components/list_page/registry_header.vue similarity index 99% rename from app/assets/javascripts/registry/explorer/components/registry_header.vue rename to app/assets/javascripts/registry/explorer/components/list_page/registry_header.vue index 870cffa0487..d4ff84447bb 100644 --- a/app/assets/javascripts/registry/explorer/components/registry_header.vue +++ b/app/assets/javascripts/registry/explorer/components/list_page/registry_header.vue @@ -9,7 +9,7 @@ import { EXPIRATION_POLICY_WILL_RUN_IN, EXPIRATION_POLICY_DISABLED_TEXT, EXPIRATION_POLICY_DISABLED_MESSAGE, -} from '../constants/index'; +} from '../../constants/index'; export default { components: { diff --git a/app/assets/javascripts/registry/explorer/pages/list.vue b/app/assets/javascripts/registry/explorer/pages/list.vue index c3e1febe087..e8a26dc58f2 100644 --- a/app/assets/javascripts/registry/explorer/pages/list.vue +++ b/app/assets/javascripts/registry/explorer/pages/list.vue @@ -12,11 +12,11 @@ import { } from '@gitlab/ui'; import Tracking from '~/tracking'; -import ProjectEmptyState from '../components/project_empty_state.vue'; -import GroupEmptyState from '../components/group_empty_state.vue'; -import RegistryHeader from '../components/registry_header.vue'; -import ImageList from '../components/image_list.vue'; -import CliCommands from '../components/cli_commands.vue'; +import ProjectEmptyState from '../components/list_page/project_empty_state.vue'; +import GroupEmptyState from '../components/list_page/group_empty_state.vue'; +import RegistryHeader from '../components/list_page/registry_header.vue'; +import ImageList from '../components/list_page/image_list.vue'; +import CliCommands from '../components/list_page/cli_commands.vue'; import { DELETE_IMAGE_SUCCESS_MESSAGE, diff --git a/app/assets/javascripts/user_callout.js b/app/assets/javascripts/user_callout.js index 96dfff77859..df00f38dd70 100644 --- a/app/assets/javascripts/user_callout.js +++ b/app/assets/javascripts/user_callout.js @@ -21,15 +21,16 @@ export default class UserCallout { dismissCallout(e) { const $currentTarget = $(e.currentTarget); + const cookieOptions = {}; - if (this.options.setCalloutPerProject) { - Cookies.set(this.cookieName, 'true', { - expires: 365, - path: this.userCalloutBody.data('projectPath'), - }); - } else { - Cookies.set(this.cookieName, 'true', { expires: 365 }); + if (!$currentTarget.hasClass('js-close-session')) { + cookieOptions.expires = 365; } + if (this.options.setCalloutPerProject) { + cookieOptions.path = this.userCalloutBody.data('projectPath'); + } + + Cookies.set(this.cookieName, 'true', cookieOptions); if ($currentTarget.hasClass('close') || $currentTarget.hasClass('js-close')) { this.userCalloutBody.remove(); diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index b47e3884072..9e8d9c70602 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -162,8 +162,8 @@ module GitlabRoutingHelper # against the arguments. We can speed this up 10x by generating the strings directly. # /*namespace_id/:project_id/-/jobs/:job_id/artifacts/download(.:format) - def fast_download_project_job_artifacts_path(project, job) - expose_fast_artifacts_path(project, job, :download) + def fast_download_project_job_artifacts_path(project, job, params = {}) + expose_fast_artifacts_path(project, job, :download, params) end # /*namespace_id/:project_id/-/jobs/:job_id/artifacts/keep(.:format) @@ -176,8 +176,13 @@ module GitlabRoutingHelper expose_fast_artifacts_path(project, job, :browse) end - def expose_fast_artifacts_path(project, job, action) + def expose_fast_artifacts_path(project, job, action, params = {}) path = "#{project.full_path}/-/jobs/#{job.id}/artifacts/#{action}" + + unless params.empty? + path += "?#{params.to_query}" + end + Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, path) end diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 146089c637d..33ba2af00e9 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -112,6 +112,7 @@ module Ci after_save :update_file_store, if: :saved_change_to_file? + scope :not_expired, -> { where('expire_at IS NULL OR expire_at > ?', Time.current) } scope :with_files_stored_locally, -> { where(file_store: [nil, ::JobArtifactUploader::Store::LOCAL]) } scope :with_files_stored_remotely, -> { where(file_store: ::JobArtifactUploader::Store::REMOTE) } scope :for_sha, ->(sha, project_id) { joins(job: :pipeline).where(ci_pipelines: { sha: sha, project_id: project_id }) } @@ -151,6 +152,7 @@ module Ci end scope :expired, -> (limit) { where('expire_at < ?', Time.current).limit(limit) } + scope :downloadable, -> { where(file_type: DOWNLOADABLE_TYPES) } scope :locked, -> { where(locked: true) } scope :unlocked, -> { where(locked: [false, nil]) } @@ -246,6 +248,14 @@ module Ci super || self.file_location.nil? end + def expired? + expire_at.present? && expire_at < Time.current + end + + def expiring? + expire_at.present? && expire_at > Time.current + end + def expire_in expire_at - Time.current if expire_at end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index f37525e56e4..c919f57a8fc 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -41,10 +41,13 @@ module Ci has_many :latest_statuses_ordered_by_stage, -> { latest.order(:stage_idx, :stage) }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :processables, class_name: 'Ci::Processable', foreign_key: :commit_id, inverse_of: :pipeline has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline + has_many :job_artifacts, through: :builds has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent has_many :variables, class_name: 'Ci::PipelineVariable' has_many :deployments, through: :builds has_many :environments, -> { distinct }, through: :deployments + has_many :latest_builds, -> { latest }, foreign_key: :commit_id, inverse_of: :pipeline, class_name: 'Ci::Build' + has_many :downloadable_artifacts, -> { not_expired.downloadable }, through: :latest_builds, source: :job_artifacts # Merge requests for which the current pipeline is running against # the merge request's latest commit. @@ -56,7 +59,6 @@ module Ci has_many :cancelable_statuses, -> { cancelable }, foreign_key: :commit_id, class_name: 'CommitStatus' has_many :manual_actions, -> { latest.manual_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build' has_many :scheduled_actions, -> { latest.scheduled_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build' - has_many :artifacts, -> { latest.with_artifacts_not_expired.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build' has_many :auto_canceled_pipelines, class_name: 'Ci::Pipeline', foreign_key: 'auto_canceled_by_id' has_many :auto_canceled_jobs, class_name: 'CommitStatus', foreign_key: 'auto_canceled_by_id' diff --git a/app/models/concerns/integration.rb b/app/models/concerns/integration.rb index 4a48a60803b..644a0ba1b5e 100644 --- a/app/models/concerns/integration.rb +++ b/app/models/concerns/integration.rb @@ -4,13 +4,16 @@ module Integration extend ActiveSupport::Concern class_methods do - def with_custom_integration_compared_to(integration) - custom_integrations = Service - .select('1') - .where(type: integration.type, inherit_from_id: nil) - .where('services.project_id = projects.id') + def with_custom_integration_for(integration, page = nil, per = nil) + custom_integration_project_ids = Service + .where(type: integration.type) + .where(inherit_from_id: nil) + .distinct # Required until https://gitlab.com/gitlab-org/gitlab/-/issues/207385 + .page(page) + .per(per) + .pluck(:project_id) - Project.where('EXISTS (?)', custom_integrations) + Project.where(id: custom_integration_project_ids) end end end diff --git a/app/serializers/build_artifact_entity.rb b/app/serializers/build_artifact_entity.rb index fac0fbd14b9..7a030372591 100644 --- a/app/serializers/build_artifact_entity.rb +++ b/app/serializers/build_artifact_entity.rb @@ -4,30 +4,28 @@ class BuildArtifactEntity < Grape::Entity include RequestAwareEntity include GitlabRoutingHelper - expose :name do |job| - job.name + alias_method :artifact, :object + + expose :name do |artifact| + "#{artifact.job.name}:#{artifact.file_type}" end - expose :artifacts_expired?, as: :expired - expose :artifacts_expire_at, as: :expire_at + expose :expire_at + expose :expired?, as: :expired - expose :path do |job| - fast_download_project_job_artifacts_path(project, job) + expose :path do |artifact| + fast_download_project_job_artifacts_path( + artifact.project, + artifact.job, + file_type: artifact.file_type + ) end - expose :keep_path, if: -> (*) { job.has_expiring_archive_artifacts? } do |job| - fast_keep_project_job_artifacts_path(project, job) + expose :keep_path, if: -> (*) { artifact.expiring? } do |artifact| + fast_keep_project_job_artifacts_path(artifact.project, artifact.job) end - expose :browse_path do |job| - fast_browse_project_job_artifacts_path(project, job) - end - - private - - alias_method :job, :object - - def project - job.project + expose :browse_path do |artifact| + fast_browse_project_job_artifacts_path(artifact.project, artifact.job) end end diff --git a/app/serializers/pipeline_details_entity.rb b/app/serializers/pipeline_details_entity.rb index a58278cf4ef..50efa9ea15d 100644 --- a/app/serializers/pipeline_details_entity.rb +++ b/app/serializers/pipeline_details_entity.rb @@ -9,8 +9,7 @@ class PipelineDetailsEntity < PipelineEntity expose :details do expose :artifacts do |pipeline, options| - rel = pipeline.artifacts - rel = rel.eager_load_job_artifacts_archive if options.fetch(:preload_job_artifacts_archive, true) + rel = pipeline.downloadable_artifacts BuildArtifactEntity.represent(rel, options) end diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index b2c0ceb640b..21d49c6c292 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -7,10 +7,6 @@ class PipelineSerializer < BaseSerializer # rubocop: disable CodeReuse/ActiveRecord def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) - # We don't want PipelineDetailsEntity to preload the job_artifacts_archive - # because we do it with preloaded_relations in a more optimal way - # if the given resource is a collection of multiple pipelines. - opts[:preload_job_artifacts_archive] = false resource = resource.preload(preloaded_relations) end @@ -44,35 +40,29 @@ class PipelineSerializer < BaseSerializer def preloaded_relations [ - :latest_statuses_ordered_by_stage, - :project, - :stages, - { - failed_builds: %i(project metadata) - }, - :retryable_builds, :cancelable_statuses, - :trigger_requests, + :latest_statuses_ordered_by_stage, :manual_actions, + :retryable_builds, :scheduled_actions, - :artifacts, + :stages, + :trigger_requests, :user, { + downloadable_artifacts: { + project: [:route, { namespace: :route }], + job: [] + }, + failed_builds: %i(project metadata), merge_request: { source_project: [:route, { namespace: :route }], target_project: [:route, { namespace: :route }] - } - }, - { + }, pending_builds: :project, project: [:route, { namespace: :route }], - artifacts: { - project: [:route, { namespace: :route }], - job_artifacts_archive: [] - } - }, - { triggered_by_pipeline: [:project, :user] }, - { triggered_pipelines: [:project, :user] } + triggered_by_pipeline: [:project, :user], + triggered_pipelines: [:project, :user] + } ] end end diff --git a/changelogs/unreleased/199732-show-more-context-to-jump-unresolved-button.yml b/changelogs/unreleased/199732-show-more-context-to-jump-unresolved-button.yml new file mode 100644 index 00000000000..0a654b11442 --- /dev/null +++ b/changelogs/unreleased/199732-show-more-context-to-jump-unresolved-button.yml @@ -0,0 +1,5 @@ +--- +title: Show more context in unresolved jump button +merge_request: 32737 +author: +type: changed diff --git a/changelogs/unreleased/218582-fix-artifact-downloads-without-new-route.yml b/changelogs/unreleased/218582-fix-artifact-downloads-without-new-route.yml new file mode 100644 index 00000000000..758b08c3a42 --- /dev/null +++ b/changelogs/unreleased/218582-fix-artifact-downloads-without-new-route.yml @@ -0,0 +1,5 @@ +--- +title: Fix 404 when downloading a non-archive artifact +merge_request: 32811 +author: +type: fixed diff --git a/config/initializers/action_cable.rb b/config/initializers/action_cable.rb index eb44ff00d09..c549dd45ad9 100644 --- a/config/initializers/action_cable.rb +++ b/config/initializers/action_cable.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'action_cable/subscription_adapter/redis' + Rails.application.configure do # We only mount the ActionCable engine in tests where we run it in-app # For other environments, we run it on a standalone Puma server @@ -7,3 +9,11 @@ Rails.application.configure do config.action_cable.url = Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, '/-/cable') config.action_cable.worker_pool_size = Gitlab.config.action_cable.worker_pool_size end + +# https://github.com/rails/rails/blob/bb5ac1623e8de08c1b7b62b1368758f0d3bb6379/actioncable/lib/action_cable/subscription_adapter/redis.rb#L18 +ActionCable::SubscriptionAdapter::Redis.redis_connector = lambda do |config| + args = config.except(:adapter, :channel_prefix) + .merge(instrumentation_class: ::Gitlab::Instrumentation::Redis::ActionCable) + + ::Redis.new(args) +end diff --git a/config/initializers/actionpack_generate_old_csrf_token.rb b/config/initializers/actionpack_generate_old_csrf_token.rb new file mode 100644 index 00000000000..6367a1d4d59 --- /dev/null +++ b/config/initializers/actionpack_generate_old_csrf_token.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Gitlab + module RequestForgeryProtectionPatch + private + + # Patch to generate 6.0.3 tokens so that we do not have CSRF errors while + # rolling out 6.0.3.1. This enables GitLab to have a mix of 6.0.3 and + # 6.0.3.1 Rails servers + # + # 1. Deploy this patch with :global_csrf_token FF disabled. + # 2. Once all Rails servers are on 6.0.3.1, enable :global_csrf_token FF. + # 3. On GitLab 13.2, remove this patch + def masked_authenticity_token(session, form_options: {}) + action, method = form_options.values_at(:action, :method) + + raw_token = if per_form_csrf_tokens && action && method + action_path = normalize_action_path(action) + per_form_csrf_token(session, action_path, method) + else + if Feature.enabled?(:global_csrf_token) + global_csrf_token(session) + else + real_csrf_token(session) + end + end + + mask_token(raw_token) + end + end +end + +ActionController::Base.include Gitlab::RequestForgeryProtectionPatch diff --git a/config/routes/admin.rb b/config/routes/admin.rb index fa357220d2f..f3b7fb5ed45 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -118,7 +118,6 @@ namespace :admin do resources :services, only: [:index, :edit, :update] resources :integrations, only: [:edit, :update] do member do - get :custom_integration_projects put :test end end diff --git a/doc/.vale/gitlab/Acronyms.yml b/doc/.vale/gitlab/Acronyms.yml index 5be8435b99f..d85c930ad82 100644 --- a/doc/.vale/gitlab/Acronyms.yml +++ b/doc/.vale/gitlab/Acronyms.yml @@ -3,7 +3,7 @@ # For a list of all options, see https://errata-ai.github.io/vale/styles/ extends: conditional message: "'%s' has no definition." -link: https://about.gitlab.com/handbook/marketing/corporate-marketing/content/editorial-team/#acronyms +link: https://about.gitlab.com/handbook/marketing/growth-marketing/content/editorial-team/#acronyms level: warning ignorecase: false # Ensures that the existence of 'first' implies the existence of 'second'. diff --git a/doc/administration/geo/replication/troubleshooting.md b/doc/administration/geo/replication/troubleshooting.md index d66ee4682b2..b03a2dae971 100644 --- a/doc/administration/geo/replication/troubleshooting.md +++ b/doc/administration/geo/replication/troubleshooting.md @@ -542,7 +542,7 @@ or `gitlab-ctl promote-to-primary-node`, either: ```ruby Rails.application.load_tasks; nil - Gitlab::Geo.expire_cache_keys!([:primary_node, :current_node]) + Gitlab::Geo.expire_cache! Rake::Task['geo:set_secondary_as_primary'].invoke ``` diff --git a/doc/install/aws/img/aws_ha_architecture_diagram.png b/doc/install/aws/img/aws_ha_architecture_diagram.png index e019ed61abf..dc63d36e0b3 100644 Binary files a/doc/install/aws/img/aws_ha_architecture_diagram.png and b/doc/install/aws/img/aws_ha_architecture_diagram.png differ diff --git a/doc/install/aws/index.md b/doc/install/aws/index.md index 18e1d34f9ca..b6b5c045467 100644 --- a/doc/install/aws/index.md +++ b/doc/install/aws/index.md @@ -12,9 +12,7 @@ For organizations with 300 users or less, the recommended AWS installation metho ## Introduction -GitLab on AWS can leverage many of the services that are already -configurable. These services offer a great deal of -flexibility and can be adapted to the needs of most companies. +For the most part, we'll make use of Omnibus GitLab in our setup, but we'll also leverage native AWS services. Instead of using the Omnibus bundled PostgreSQL and Redis, we will use AWS RDS and ElastiCache. In this guide, we'll go through a multi-node setup where we'll start by configuring our Virtual Private Cloud and subnets to later integrate @@ -225,16 +223,18 @@ We also need to create two private route tables so that instances in each privat ## Load Balancer +We'll create a load balancer to evenly distribute inbound traffic on ports `80` and `443` across our GitLab application servers. Based the on the [scaling policies](#create-an-auto-scaling-group) we'll create later, instances will be added to or removed from our load balancer as needed. Additionally, the load balance will perform health checks on our instances. + On the EC2 dashboard, look for Load Balancer in the left navigation bar: 1. Click the **Create Load Balancer** button. 1. Choose the **Classic Load Balancer**. 1. Give it a name (we'll use `gitlab-loadbalancer`) and for the **Create LB Inside** option, select `gitlab-vpc` from the dropdown menu. 1. In the **Listeners** section, set HTTP port 80, HTTPS port 443, and TCP port 22 for both load balancer and instance protocols and ports. - 1. In the **Select Subnets** section, select both public subnets from the list. -1. Click **Assign Security Groups** and select **Create a new security group**, give it a name + 1. In the **Select Subnets** section, select both public subnets from the list so that the load balancer can route traffic to both availability zones. +1. We'll add a security group for our load balancer to act as a firewall to control what traffic is allowed through. Click **Assign Security Groups** and select **Create a new security group**, give it a name (we'll use `gitlab-loadbalancer-sec-group`) and description, and allow both HTTP and HTTPS traffic - from anywhere (`0.0.0.0/0, ::/0`). Also allow SSH traffic from a single IP address or an IP address range in CIDR notation. + from anywhere (`0.0.0.0/0, ::/0`). Also allow SSH traffic, select a custom source, and add a single trusted IP address or an IP address range in CIDR notation. This will allow users to perform Git actions over SSH. 1. Click **Configure Security Settings** and set the following: 1. Select an SSL/TLS certificate from ACM or upload a certificate to IAM. 1. Under **Select a Cipher**, pick a predefined security policy from the dropdown. You can see a breakdown of [Predefined SSL Security Policies for Classic Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html) in the AWS docs. Check the GitLab codebase for a list of [supported SSL ciphers and protocols](https://gitlab.com/gitlab-org/gitlab/-/blob/9ee7ad433269b37251e0dd5b5e00a0f00d8126b4/lib/support/nginx/gitlab-ssl#L97-99). @@ -261,11 +261,16 @@ On the Route 53 dashboard, click **Hosted zones** in the left navigation bar: 1. Click **Create Record Set** and provide the following values: 1. **Name:** Use the domain name (the default value) or enter a subdomain. 1. **Type:** Select **A - IPv4 address**. + 1. **Alias:** Defaults to **No**. Select **Yes**. 1. **Alias Target:** Find the **ELB Classic Load Balancers** section and select the classic load balancer we created earlier. 1. **Routing Policy:** We'll use **Simple** but you can choose a different policy based on your use case. 1. **Evaluate Target Health:** We'll set this to **No** but you can choose to have the load balancer route traffic based on target health. 1. Click **Create**. -1. Update your DNS records with your domain registrar. The steps for doing this vary depending on which registrar you use and is beyond the scope of this guide. +1. If you registered your domain through Route 53, you're done. If you used a different domain registrar, you need to update your DNS records with your domain registrar. You'll need to: + 1. Click on **Hosted zones** and select the domain you added above. + 1. You'll see a list of `NS` records. From your domain registrar's admin panel, add each of these as `NS` records to your domain's DNS records. These steps may vary between domain registrars. If you're stuck, Google **"name of your registrar" add dns records** and you should find a help article specific to your domain registrar. + +The steps for doing this vary depending on which registrar you use and is beyond the scope of this guide. ## PostgreSQL with RDS diff --git a/doc/install/google_cloud_platform/img/boot_disk.png b/doc/install/google_cloud_platform/img/boot_disk.png deleted file mode 100644 index b9f7eed6601..00000000000 Binary files a/doc/install/google_cloud_platform/img/boot_disk.png and /dev/null differ diff --git a/doc/install/google_cloud_platform/img/vm_details.png b/doc/install/google_cloud_platform/img/vm_details.png index 85b9ca066c8..aab9a46fa11 100644 Binary files a/doc/install/google_cloud_platform/img/vm_details.png and b/doc/install/google_cloud_platform/img/vm_details.png differ diff --git a/doc/install/google_cloud_platform/index.md b/doc/install/google_cloud_platform/index.md index 433eeda00b1..8ca5c5c266a 100644 --- a/doc/install/google_cloud_platform/index.md +++ b/doc/install/google_cloud_platform/index.md @@ -33,13 +33,13 @@ To deploy GitLab on GCP you first need to create a virtual machine: ![Search for GitLab](img/launch_vm.png) 1. On the next page, you can select the type of VM as well as the - estimated costs. Provide the name of the instance, desired datacenter, and machine type. Note that GitLab recommends at least 2 vCPU's and 4GB of RAM. + estimated costs. Provide the name of the instance, desired datacenter, and machine type. + Note our [hardware requirements for different user base sizes](../requirements.md#hardware-requirements). ![Launch on Compute Engine](img/vm_details.png) -1. Click **Change** under Boot disk to select the size, type, and desired operating system. GitLab supports a [variety of linux operating systems](../requirements.md), including Ubuntu and Debian. Click **Select** when finished. - - ![Deploy in progress](img/boot_disk.png) +1. To select the size, type, and desired [operating system](../requirements.md#supported-linux-distributions), + click **Change** under `Boot disk`. Click **Select** when finished. 1. As a last step allow HTTP and HTTPS traffic, then click **Create**. The process will finish in a few seconds. diff --git a/doc/install/requirements.md b/doc/install/requirements.md index c7add46bd43..45b9ed5f6af 100644 --- a/doc/install/requirements.md +++ b/doc/install/requirements.md @@ -45,7 +45,7 @@ Please consider using a virtual machine to run GitLab. GitLab requires Ruby (MRI) 2.6. Beginning in GitLab 12.2, we no longer support Ruby 2.5 and lower. You must use the standard MRI implementation of Ruby. -We love [JRuby](https://www.jruby.org/) and [Rubinius](https://rubinius.com), but GitLab +We love [JRuby](https://www.jruby.org/) and [Rubinius](https://github.com/rubinius/rubinius#the-rubinius-language-platform), but GitLab needs several Gems that have native extensions. ### Go versions @@ -62,12 +62,12 @@ GitLab 11.11 and higher only supports Git 2.24.x and newer, and Beginning in GitLab 12.9, we only support node.js 10.13.0 or higher, and we have dropped support for node.js 8. (node.js 6 support was dropped in GitLab 11.8) -We recommend Node 12.x, as it is faster. +We recommend Node 12.x, as it's faster. GitLab uses [webpack](https://webpack.js.org/) to compile frontend assets, which requires a minimum version of Node.js 10.13.0. -You can check which version you are running with `node -v`. If you are running +You can check which version you're running with `node -v`. If you're running a version older than `v10.13.0`, you need to update it to a newer version. You can find instructions to install from community maintained packages or compile from source at the [Node.js website](https://nodejs.org/en/download/). @@ -80,30 +80,30 @@ GitLab requires Redis 5.0+. Beginning in GitLab 13.0, lower versions are not sup ### Storage -The necessary hard drive space largely depends on the size of the repos you want to store in GitLab but as a *rule of thumb* you should have at least as much free space as all your repos combined take up. +The necessary hard drive space largely depends on the size of the repositories you want to store in GitLab but as a *rule of thumb* you should have at least as much free space as all your repositories combined take up. -If you want to be flexible about growing your hard drive space in the future consider mounting it using LVM so you can add more hard drives when you need them. +If you want to be flexible about growing your hard drive space in the future consider mounting it using [logical volume management (LVM)](https://en.wikipedia.org/wiki/Logical_volume_management) so you can add more hard drives when you need them. Apart from a local hard drive you can also mount a volume that supports the network file system (NFS) protocol. This volume might be located on a file server, a network attached storage (NAS) device, a storage area network (SAN) or on an Amazon Web Services (AWS) Elastic Block Store (EBS) volume. -If you have enough RAM memory and a recent CPU the speed of GitLab is mainly limited by hard drive seek times. Having a fast drive (7200 RPM and up) or a solid state drive (SSD) will improve the responsiveness of GitLab. +If you have enough RAM and a recent CPU the speed of GitLab is mainly limited by hard drive seek times. Having a fast drive (7200 RPM and up) or a solid state drive (SSD) will improve the responsiveness of GitLab. -NOTE: **Note:** Since file system performance may affect GitLab's overall performance, we do not recommend using EFS for storage. See the [relevant documentation](../administration/high_availability/nfs.md#avoid-using-awss-elastic-file-system-efs) for more details. +NOTE: **Note:** Since file system performance may affect GitLab's overall performance, [we don't recommend using AWS EFS for storage](../administration/high_availability/nfs.md#avoid-using-awss-elastic-file-system-efs). ### CPU -This is the recommended minimum hardware for a handful of example GitLab user base sizes. Your exact needs may be more, depending on your workload. Your workload is influenced by factors such as - but not limited to - how active your users are, how much automation you use, mirroring, and repo/change size. +This is the recommended minimum hardware for a handful of example GitLab user base sizes. Your exact needs may be more, depending on your workload. Your workload is influenced by factors such as - but not limited to - how active your users are, how much automation you use, mirroring, and repository/change size. - 1 core supports up to 100 users but the application can be a bit slower due to having all workers and background jobs running on the same core - **2 cores** is the **recommended** minimum number of cores and supports up to 100 users -- 4 cores supports up to 500 users -- 8 cores supports up to 1,000 users -- 32 cores supports up to 5,000 users +- 4 cores support up to 500 users +- 8 cores support up to 1,000 users +- 32 cores support up to 5,000 users - More users? Consult the [reference architectures page](../administration/reference_architectures/index.md) ### Memory -This is the recommended minimum hardware for a handful of example GitLab user base sizes. Your exact needs may be more, depending on your workload. Your workload is influenced by factors such as - but not limited to - how active your users are, how much automation you use, mirroring, and repo/change size. +This is the recommended minimum hardware for a handful of example GitLab user base sizes. Your exact needs may be more, depending on your workload. Your workload is influenced by factors such as - but not limited to - how active your users are, how much automation you use, mirroring, and the size of repositories as well as changes/commits. You need at least 8GB of addressable memory (RAM + swap) to install and use GitLab! The operating system and any other running applications will also be using memory @@ -130,56 +130,43 @@ NOTE: **Note:** The 25 workers of Sidekiq will show up as separate processes in ## Database -The server running the database should have _at least_ 5-10 GB of storage -available, though the exact requirements depend on the size of the GitLab -installation (e.g. the number of users, projects, etc). - -We currently support the following databases: - -- PostgreSQL - +PostgreSQL is the only supported database, which is bundled with the Omnibus GitLab package. +You can also use an [external PostgreSQL database](https://docs.gitlab.com/omnibus/settings/database.html#using-a-non-packaged-postgresql-database-management-server). Support for MySQL was removed in GitLab 12.1. Existing users using GitLab with MySQL/MariaDB are advised to [migrate to PostgreSQL](../update/mysql_to_postgresql.md) before upgrading. ### PostgreSQL Requirements +The server running PostgreSQL should have _at least_ 5-10 GB of storage +available, though the exact requirements [depend on the number of users](../administration/reference_architectures/index.md). + We highly recommend users to use the minimum PostgreSQL versions specified below as these are the versions used for development and testing. GitLab version | Minimum PostgreSQL version -|- 10.0 | 9.6 12.10 | 11 +13.0 | 11 -Users using PostgreSQL must ensure the `pg_trgm` extension is loaded into every -GitLab database. This extension can be enabled (using a PostgreSQL super user) -by running the following query for every database: +You must also ensure the `pg_trgm` extension is loaded into every +GitLab database. This extension [can be enabled](https://www.postgresql.org/docs/11/sql-createextension.html) using a PostgreSQL super user. -```sql -CREATE EXTENSION pg_trgm; -``` - -On some systems you may need to install an additional package (e.g. +On some systems you may need to install an additional package (for example, `postgresql-contrib`) for this extension to become available. -NOTE: **Note:** Support for PostgreSQL 9.6 and 10 will be removed in GitLab 13.0 so that GitLab can benefit from PostgreSQL 11 improvements, such as partitioning. For the schedule on adding support for PostgreSQL 11 and 12, see [the related epic](https://gitlab.com/groups/gitlab-org/-/epics/2184). For the release schedule for GitLab 13.0, see [GitLab's release and maintenance policy](../policy/maintenance.md). +NOTE: **Note:** Support for [PostgreSQL 9.6 and 10 has been removed in GitLab 13.0](https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-released/#postgresql-11-is-now-the-minimum-required-version-to-install-gitlab) so that GitLab can benefit from PostgreSQL 11 improvements, such as partitioning. For the schedule of transitioning to PostgreSQL 12, see [the related epic](https://gitlab.com/groups/gitlab-org/-/epics/2184). #### Additional requirements for GitLab Geo -If you are using [GitLab Geo](../development/geo.md): +If you're using [GitLab Geo](../administration/geo/replication/index.md): - We strongly recommend running Omnibus-managed instances as they are actively developed and tested. We aim to be compatible with most external (not managed - by Omnibus) databases (for example, AWS RDS) but we do not guarantee - compatibility. -- The - [tracking database](../development/geo.md#using-the-tracking-database) - requires the - [postgres_fdw](https://www.postgresql.org/docs/11/postgres-fdw.html) - extension. - -```sql -CREATE EXTENSION postgres_fdw; -``` + by Omnibus) databases (for example, [AWS Relational Database Service (RDS)](https://aws.amazon.com/rds/)) but we don't guarantee compatibility. +- You must also ensure the `postgres_fdw` extension is loaded into every + GitLab database. This extension + [can be enabled](https://www.postgresql.org/docs/11/sql-createextension.html) + using a PostgreSQL super user. ## Unicorn Workers @@ -204,7 +191,7 @@ Omnibus GitLab defaults to the recommended Puma settings. Regardless of installa tune the Puma settings. If you're using Omnibus GitLab, see [Puma settings](https://docs.gitlab.com/omnibus/settings/puma.html) -for instructions on changing the Puma settings. If you are using the GitLab Helm chart, see the [Webservice chart](https://docs.gitlab.com/charts/charts/gitlab/webservice/index.html). +for instructions on changing the Puma settings. If you're using the GitLab Helm chart, see the [Webservice chart](https://docs.gitlab.com/charts/charts/gitlab/webservice/index.html). ### Puma workers @@ -228,7 +215,7 @@ of [legacy Rugged code](../development/gitaly.md#legacy-rugged-code). - If the operating system has a maximum 2 GB of memory, the recommended number of threads is `1`. A higher value will result in excess swapping, and decrease performance. - If legacy Rugged code is in use, the recommended number of threads is `1`. -- In all other cases, the recommended number of threads is `4`. We do not recommend setting this +- In all other cases, the recommended number of threads is `4`. We don't recommend setting this higher, due to how [Ruby MRI multi-threading](https://en.wikipedia.org/wiki/Global_interpreter_lock) works. @@ -257,11 +244,11 @@ to install GitLab on. Depending on how you decide to configure GitLab Runner and what tools you use to exercise your application in the CI environment, GitLab Runner can consume significant amount of available memory. -Memory consumption calculations, that are available above, will not be valid if +Memory consumption calculations, that are available above, won't be valid if you decide to run GitLab Runner and the GitLab Rails application on the same machine. -It is also not safe to install everything on a single machine, because of the +It's also not safe to install everything on a single machine, because of the [security reasons](https://docs.gitlab.com/runner/security/), especially when you plan to use shell executor with GitLab Runner. @@ -282,7 +269,7 @@ For reference, GitLab.com's [auto-scaling shared runner](../user/gitlab_com/inde ## Supported web browsers -CAUTION: **Caution:** With GitLab 13.0 (May 2020) we are removing official support for Internet Explorer 11. +CAUTION: **Caution:** With GitLab 13.0 (May 2020) we have removed official support for Internet Explorer 11. With the release of GitLab 13.4 (September 2020) we will remove all code that supports Internet Explorer 11. You can provide feedback [on this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/197987) or via your usual support channels. @@ -293,14 +280,13 @@ GitLab supports the following web browsers: - [Chromium](https://www.chromium.org/getting-involved/dev-channel) - [Apple Safari](https://www.apple.com/safari/) - [Microsoft Edge](https://www.microsoft.com/edge) -- Internet Explorer 11 (until May 2020) For the listed web browsers, GitLab supports: - The current and previous major versions of browsers except Internet Explorer. - The current minor version of a supported major version. -NOTE: **Note:** We do not support running GitLab with JavaScript disabled in the browser and have no plans of supporting that +NOTE: **Note:** We don't support running GitLab with JavaScript disabled in the browser and have no plans of supporting that in the future because we have features such as Issue Boards which require JavaScript extensively.