From a0fdcfcdd514c2af98f18cadfa75f8a6a85b4d2c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 1 Jul 2022 15:08:30 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .stylelintrc | 9 +- .../issues/show/components/incidents/utils.js | 2 + .../javascripts/pages/projects/logs/index.js | 3 - .../components/usage_quotas/usage_banner.vue | 8 - app/assets/stylesheets/mailer.scss | 2 - .../page_bundles/_ide_monaco_overrides.scss | 6 - .../page_bundles/merge_requests.scss | 2 - .../concerns/integrations/params.rb | 1 - .../concerns/verifies_with_email.rb | 194 +++ .../projects/service_ping_controller.rb | 3 +- app/controllers/sessions_controller.rb | 1 + app/graphql/mutations/snippets/create.rb | 2 +- app/graphql/mutations/snippets/update.rb | 2 +- app/helpers/emails_helper.rb | 8 + app/helpers/sessions_helper.rb | 12 + app/mailers/emails/identity_verification.rb | 15 + app/mailers/notify.rb | 1 + app/mailers/previews/notify_preview.rb | 4 + app/models/authentication_event.rb | 5 + .../concerns/require_email_verification.rb | 52 + app/models/user.rb | 3 +- .../after_update_service.rb | 8 + .../timeline_events/create_service.rb | 48 +- app/services/issues/close_service.rb | 5 +- app/services/issues/create_service.rb | 7 + app/services/issues/reopen_service.rb | 7 + .../devise/sessions/email_verification.haml | 19 + .../sessions/successful_verification.haml | 11 + .../verification_instructions_email.html.haml | 12 + .../verification_instructions_email.text.erb | 8 + app/views/projects/logs/empty_logs.html.haml | 14 - app/views/projects/logs/index.html.haml | 1 - .../1655726589_ide_edit_g_edit_by_web_ide.yml | 22 + ...726622_ide_edit_g_edit_by_live_preview.yml | 22 + .../1655726650_ide_edit_g_edit_by_sfe.yml | 22 + ...5726683_ide_edit_g_edit_by_snippet_ide.yml | 22 + .../require_email_verification.yml | 8 + config/gitlab.yml.example | 6 - config/initializers/1_settings.rb | 2 - config/routes/user.rb | 2 + ..._success_index_to_authentication_events.rb | 18 + db/schema_migrations/20220601152916 | 1 + db/structure.sql | 2 +- .../geo/disaster_recovery/planned_failover.md | 4 +- doc/administration/geo/setup/index.md | 4 +- doc/administration/object_storage.md | 6 +- .../operations/moving_repositories.md | 4 +- .../reference_architectures/10k_users.md | 2 +- .../reference_architectures/25k_users.md | 2 +- .../reference_architectures/2k_users.md | 2 +- .../reference_architectures/3k_users.md | 2 +- .../reference_architectures/50k_users.md | 2 +- .../reference_architectures/5k_users.md | 2 +- .../reference_architectures/index.md | 2 +- .../troubleshooting.md | 2 +- doc/api/integrations.md | 1 - .../cloud_deployment/ecs/deploy_to_aws_ecs.md | 6 +- .../testing_guide/end_to_end/resources.md | 10 +- doc/install/aws/manual_install_aws.md | 8 +- doc/raketasks/backup_gitlab.md | 908 ++++++++++++ doc/raketasks/backup_restore.md | 1265 +---------------- doc/raketasks/restore_gitlab.md | 367 +++++ doc/update/package/downgrade.md | 2 +- doc/update/plan_your_upgrade.md | 4 +- .../incident_management_rate_limits.md | 4 +- doc/user/analytics/index.md | 6 +- doc/user/application_security/index.md | 2 +- .../group/value_stream_analytics/index.md | 2 +- .../img/attention_request_list_v14_10.png | Bin 11932 -> 0 bytes .../img/attention_request_sidebar_v14_10.png | Bin 20471 -> 0 bytes doc/user/project/merge_requests/index.md | 47 - .../project/merge_requests/reviews/index.md | 6 - doc/user/project/quick_actions.md | 1 - lefthook.yml | 7 +- lib/api/commits.rb | 2 +- lib/gitlab/application_rate_limiter.rb | 5 +- lib/gitlab/ci/yaml_processor.rb | 12 +- lib/gitlab/ci/yaml_processor/feature_flags.rb | 50 + .../editor_unique_counter.rb | 28 +- locale/gitlab.pot | 54 +- package.json | 3 +- qa/qa/page/mattermost/login.rb | 2 +- .../stylelint_duplicate_selectors.js | 25 - .../stylelint/stylelint_utility_classes.js | 25 - .../stylelint/stylelint_utility_map.js | 64 - scripts/frontend/stylelint/stylelint_utils.js | 78 - .../frontend/stylelint/utility_classes_map.js | 259 ---- .../projects/service_ping_controller_spec.rb | 12 +- spec/controllers/search_controller_spec.rb | 5 +- .../users/email_verification_on_login_spec.rb | 357 +++++ .../show/components/incidents/utils_spec.js | 6 +- spec/helpers/sessions_helper_spec.rb | 47 + .../ci/yaml_processor/feature_flags_spec.rb | 80 ++ .../editor_unique_counter_spec.rb | 30 +- spec/lib/gitlab/usage_data_spec.rb | 33 +- ...ess_index_to_authentication_events_spec.rb | 24 + spec/models/authentication_event_spec.rb | 27 + .../require_email_verification_spec.rb | 103 ++ spec/requests/api/commits_spec.rb | 17 +- .../graphql/mutations/snippets/update_spec.rb | 17 +- spec/requests/verifies_with_email_spec.rb | 232 +++ .../after_update_service_spec.rb | 14 + .../timeline_events/create_service_spec.rb | 101 ++ spec/services/issues/close_service_spec.rb | 17 +- spec/services/issues/create_service_spec.rb | 8 + spec/services/issues/reopen_service_spec.rb | 33 +- spec/spec_helper.rb | 4 + .../snowplow_event_tracking_examples.rb | 1 - .../ipynbdiff/lib/transformed_notebook.rb | 2 +- .../source_with_linebreak/expected.md | 3 + .../expected_symbols.txt | 3 + .../source_with_linebreak/input.ipynb | 11 + .../gems/ipynbdiff/spec/transformer_spec.rb | 1 + 113 files changed, 3137 insertions(+), 1940 deletions(-) delete mode 100644 app/assets/javascripts/pages/projects/logs/index.js create mode 100644 app/controllers/concerns/verifies_with_email.rb create mode 100644 app/mailers/emails/identity_verification.rb create mode 100644 app/models/concerns/require_email_verification.rb create mode 100644 app/views/devise/sessions/email_verification.haml create mode 100644 app/views/devise/sessions/successful_verification.haml create mode 100644 app/views/notify/verification_instructions_email.html.haml create mode 100644 app/views/notify/verification_instructions_email.text.erb delete mode 100644 app/views/projects/logs/empty_logs.html.haml delete mode 100644 app/views/projects/logs/index.html.haml create mode 100644 config/events/1655726589_ide_edit_g_edit_by_web_ide.yml create mode 100644 config/events/1655726622_ide_edit_g_edit_by_live_preview.yml create mode 100644 config/events/1655726650_ide_edit_g_edit_by_sfe.yml create mode 100644 config/events/1655726683_ide_edit_g_edit_by_snippet_ide.yml create mode 100644 config/feature_flags/development/require_email_verification.yml create mode 100644 db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb create mode 100644 db/schema_migrations/20220601152916 create mode 100644 doc/raketasks/backup_gitlab.md create mode 100644 doc/raketasks/restore_gitlab.md delete mode 100644 doc/user/project/merge_requests/img/attention_request_list_v14_10.png delete mode 100644 doc/user/project/merge_requests/img/attention_request_sidebar_v14_10.png create mode 100644 lib/gitlab/ci/yaml_processor/feature_flags.rb delete mode 100644 scripts/frontend/stylelint/stylelint_duplicate_selectors.js delete mode 100644 scripts/frontend/stylelint/stylelint_utility_classes.js delete mode 100644 scripts/frontend/stylelint/stylelint_utility_map.js delete mode 100644 scripts/frontend/stylelint/stylelint_utils.js delete mode 100644 scripts/frontend/stylelint/utility_classes_map.js create mode 100644 spec/features/users/email_verification_on_login_spec.rb create mode 100644 spec/lib/gitlab/ci/yaml_processor/feature_flags_spec.rb create mode 100644 spec/migrations/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events_spec.rb create mode 100644 spec/models/concerns/require_email_verification_spec.rb create mode 100644 spec/requests/verifies_with_email_spec.rb create mode 100644 vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected.md create mode 100644 vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected_symbols.txt create mode 100644 vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/input.ipynb diff --git a/.stylelintrc b/.stylelintrc index 458fd51bdd7..faab22862fc 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -7,12 +7,5 @@ "app/assets/stylesheets/lazy_bundles/select2.scss", "app/assets/stylesheets/highlight/themes/*.scss", "app/assets/stylesheets/lazy_bundles/cropper.css" - ], - "plugins":[ - "./scripts/frontend/stylelint/stylelint_duplicate_selectors.js", - "./scripts/frontend/stylelint/stylelint_utility_classes.js", - ], - "rules":{ - "stylelint-gitlab/utility-classes":[true,{ "severity": "warning" }], - } + ] } diff --git a/app/assets/javascripts/issues/show/components/incidents/utils.js b/app/assets/javascripts/issues/show/components/incidents/utils.js index 8b5a2ec4031..d8e5b693b85 100644 --- a/app/assets/javascripts/issues/show/components/incidents/utils.js +++ b/app/assets/javascripts/issues/show/components/incidents/utils.js @@ -10,6 +10,8 @@ export const displayAndLogError = (error) => const EVENT_ICONS = { comment: 'comment', + issues: 'issues', + status: 'status', default: 'comment', }; diff --git a/app/assets/javascripts/pages/projects/logs/index.js b/app/assets/javascripts/pages/projects/logs/index.js deleted file mode 100644 index 0cff1ffc27e..00000000000 --- a/app/assets/javascripts/pages/projects/logs/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import logsBundle from '~/logs'; - -logsBundle(); diff --git a/app/assets/javascripts/vue_shared/components/usage_quotas/usage_banner.vue b/app/assets/javascripts/vue_shared/components/usage_quotas/usage_banner.vue index 20a666509a4..1ac822982e1 100644 --- a/app/assets/javascripts/vue_shared/components/usage_quotas/usage_banner.vue +++ b/app/assets/javascripts/vue_shared/components/usage_quotas/usage_banner.vue @@ -1,7 +1,6 @@ diff --git a/app/assets/stylesheets/mailer.scss b/app/assets/stylesheets/mailer.scss index b8cbe64df38..da120b5fb4e 100644 --- a/app/assets/stylesheets/mailer.scss +++ b/app/assets/stylesheets/mailer.scss @@ -2,8 +2,6 @@ // Do not use 3-letter hex codes, bgcolor vs css background-color is problematic in emails // -// stylelint-disable color-hex-length - $mailer-font: 'Helvetica Neue', Helvetica, Arial, sans-serif; $mailer-text-color: #333; $mailer-bg-color: #fafafa; diff --git a/app/assets/stylesheets/page_bundles/_ide_monaco_overrides.scss b/app/assets/stylesheets/page_bundles/_ide_monaco_overrides.scss index 57053c7f0cb..d93b4f75d77 100644 --- a/app/assets/stylesheets/page_bundles/_ide_monaco_overrides.scss +++ b/app/assets/stylesheets/page_bundles/_ide_monaco_overrides.scss @@ -1,9 +1,3 @@ - -// stylelint-disable selector-class-pattern -// stylelint-disable selector-max-compound-selectors -// stylelint-disable stylelint-gitlab/duplicate-selectors -// stylelint-disable stylelint-gitlab/utility-classes - .blob-editor-container { flex: 1; height: 0; diff --git a/app/assets/stylesheets/page_bundles/merge_requests.scss b/app/assets/stylesheets/page_bundles/merge_requests.scss index 14873c54cd7..2c1e15cf8b7 100644 --- a/app/assets/stylesheets/page_bundles/merge_requests.scss +++ b/app/assets/stylesheets/page_bundles/merge_requests.scss @@ -46,9 +46,7 @@ $tabs-holder-z-index: 250; position: -webkit-sticky; position: sticky; // Unitless zero values are not allowed in calculations - // stylelint-disable-next-line length-zero-no-unit top: calc(#{$top-pos} + var(--system-header-height, 0px) + var(--performance-bar-height, 0px)); - // stylelint-disable-next-line length-zero-no-unit max-height: calc(100vh - #{$top-pos} - var(--system-header-height, 0px) - var(--performance-bar-height, 0px) - var(--review-bar-height, 0px)); .drag-handle { diff --git a/app/controllers/concerns/integrations/params.rb b/app/controllers/concerns/integrations/params.rb index d256b331174..c3ad9d3dff3 100644 --- a/app/controllers/concerns/integrations/params.rb +++ b/app/controllers/concerns/integrations/params.rb @@ -6,7 +6,6 @@ module Integrations ALLOWED_PARAMS_CE = [ :active, - :add_pusher, :alert_events, :api_key, :api_token, diff --git a/app/controllers/concerns/verifies_with_email.rb b/app/controllers/concerns/verifies_with_email.rb new file mode 100644 index 00000000000..0dcc95e30e7 --- /dev/null +++ b/app/controllers/concerns/verifies_with_email.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true + +# == VerifiesWithEmail +# +# Controller concern to handle verification by email +module VerifiesWithEmail + extend ActiveSupport::Concern + include ActionView::Helpers::DateHelper + + TOKEN_LENGTH = 6 + TOKEN_VALID_FOR_MINUTES = 60 + + included do + prepend_before_action :verify_with_email, only: :create, unless: -> { two_factor_enabled? } + end + + def verify_with_email + return unless user = find_user || find_verification_user + + if session[:verification_user_id] && token = verification_params[:verification_token].presence + # The verification token is submitted, verify it + verify_token(user, token) + elsif require_email_verification_enabled? + # Limit the amount of password guesses, since we now display the email verification page + # when the password is correct, which could be a giveaway when brute-forced. + return render_sign_in_rate_limited if check_rate_limit!(:user_sign_in, scope: user) { true } + + if user.valid_password?(user_params[:password]) + # The user has logged in successfully. + if user.unlock_token + # Prompt for the token if it already has been set + prompt_for_email_verification(user) + elsif user.access_locked? || !AuthenticationEvent.initial_login_or_known_ip_address?(user, request.ip) + # require email verification if: + # - their account has been locked because of too many failed login attempts, or + # - they have logged in before, but never from the current ip address + send_verification_instructions(user) + prompt_for_email_verification(user) + end + end + end + end + + def resend_verification_code + return unless user = find_verification_user + + send_verification_instructions(user) + prompt_for_email_verification(user) + end + + def successful_verification + session.delete(:verification_user_id) + @redirect_url = after_sign_in_path_for(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables + + render layout: 'minimal' + end + + private + + def find_verification_user + return unless session[:verification_user_id] + + User.find_by_id(session[:verification_user_id]) + end + + # After successful verification and calling sign_in, devise redirects the + # user to this path. Override it to show the successful verified page. + def after_sign_in_path_for(resource) + if action_name == 'create' && session[:verification_user_id] + return users_successful_verification_path + end + + super + end + + def send_verification_instructions(user) + return if send_rate_limited?(user) + + raw_token, encrypted_token = generate_token + user.unlock_token = encrypted_token + user.lock_access!({ send_instructions: false }) + send_verification_instructions_email(user, raw_token) + end + + def send_verification_instructions_email(user, token) + return unless user.can?(:receive_notifications) + + Notify.verification_instructions_email( + user.id, + token: token, + expires_in: TOKEN_VALID_FOR_MINUTES).deliver_later + + log_verification(user, :instructions_sent) + end + + def verify_token(user, token) + return handle_verification_failure(user, :rate_limited) if verification_rate_limited?(user) + return handle_verification_failure(user, :invalid) unless valid_token?(user, token) + return handle_verification_failure(user, :expired) if expired_token?(user) + + handle_verification_success(user) + end + + def generate_token + raw_token = SecureRandom.random_number(10**TOKEN_LENGTH).to_s.rjust(TOKEN_LENGTH, '0') + encrypted_token = digest_token(raw_token) + [raw_token, encrypted_token] + end + + def digest_token(token) + Devise.token_generator.digest(User, :unlock_token, token) + end + + def render_sign_in_rate_limited + message = s_('IdentityVerification|Maximum login attempts exceeded. '\ + 'Wait %{interval} and try again.') % { interval: user_sign_in_interval } + redirect_to new_user_session_path, alert: message + end + + def user_sign_in_interval + interval_in_seconds = Gitlab::ApplicationRateLimiter.rate_limits[:user_sign_in][:interval] + distance_of_time_in_words(interval_in_seconds) + end + + def verification_rate_limited?(user) + Gitlab::ApplicationRateLimiter.throttled?(:email_verification, scope: user.unlock_token) + end + + def send_rate_limited?(user) + Gitlab::ApplicationRateLimiter.throttled?(:email_verification_code_send, scope: user) + end + + def expired_token?(user) + user.locked_at < (Time.current - TOKEN_VALID_FOR_MINUTES.minutes) + end + + def valid_token?(user, token) + user.unlock_token == digest_token(token) + end + + def handle_verification_failure(user, reason) + message = case reason + when :rate_limited + s_("IdentityVerification|You've reached the maximum amount of tries. "\ + 'Wait %{interval} or resend a new code and try again.') % { interval: email_verification_interval } + when :expired + s_('IdentityVerification|The code has expired. Resend a new code and try again.') + when :invalid + s_('IdentityVerification|The code is incorrect. Enter it again, or resend a new code.') + end + + user.errors.add(:base, message) + log_verification(user, :failed_attempt, reason) + + prompt_for_email_verification(user) + end + + def email_verification_interval + interval_in_seconds = Gitlab::ApplicationRateLimiter.rate_limits[:email_verification][:interval] + distance_of_time_in_words(interval_in_seconds) + end + + def handle_verification_success(user) + user.unlock_access! + log_verification(user, :successful) + + sign_in(user) + end + + def prompt_for_email_verification(user) + session[:verification_user_id] = user.id + self.resource = user + + render 'devise/sessions/email_verification' + end + + def verification_params + params.require(:user).permit(:verification_token) + end + + def log_verification(user, event, reason = nil) + Gitlab::AppLogger.info( + message: 'Email Verification', + event: event.to_s.titlecase, + username: user.username, + ip: request.ip, + reason: reason.to_s + ) + end + + def require_email_verification_enabled? + Feature.enabled?(:require_email_verification) + end +end diff --git a/app/controllers/projects/service_ping_controller.rb b/app/controllers/projects/service_ping_controller.rb index d8f1785d95e..43c249afd8e 100644 --- a/app/controllers/projects/service_ping_controller.rb +++ b/app/controllers/projects/service_ping_controller.rb @@ -17,7 +17,8 @@ class Projects::ServicePingController < Projects::ApplicationController return render_404 unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? Gitlab::UsageDataCounters::WebIdeCounter.increment_previews_success_count - Gitlab::UsageDataCounters::EditorUniqueCounter.track_live_preview_edit_action(author: current_user) + Gitlab::UsageDataCounters::EditorUniqueCounter.track_live_preview_edit_action(author: current_user, + project: project) head(200) end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9000e9c39de..fc51ee47bd2 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -11,6 +11,7 @@ class SessionsController < Devise::SessionsController include Gitlab::Utils::StrongMemoize include OneTrustCSP include BizibleCSP + include VerifiesWithEmail skip_before_action :check_two_factor_requirement, only: [:destroy] skip_before_action :check_password_expiration, only: [:destroy] diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb index 2921a77b86d..96ac3f8a113 100644 --- a/app/graphql/mutations/snippets/create.rb +++ b/app/graphql/mutations/snippets/create.rb @@ -54,7 +54,7 @@ module Mutations # Only when the user is not an api user and the operation was successful if !api_user? && service_response.success? - ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user) + ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user, project: project) end snippet = service_response.payload[:snippet] diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb index 2a2941c5328..39843a3714a 100644 --- a/app/graphql/mutations/snippets/update.rb +++ b/app/graphql/mutations/snippets/update.rb @@ -43,7 +43,7 @@ module Mutations # Only when the user is not an api user and the operation was successful if !api_user? && service_response.success? - ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user) + ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user, project: snippet.project) end snippet = service_response.payload[:snippet] diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index c23d905a008..dc4e2e9709a 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -276,6 +276,14 @@ module EmailsHelper end end + def link_start(url) + ''.html_safe % { url: url } + end + + def link_end + ''.html_safe + end + def contact_your_administrator_text _('Please contact your administrator with any questions.') end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index f0389000eb3..129180d1ccf 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -39,4 +39,16 @@ module SessionsHelper # 2. https://github.com/redis-store/redis-store/blob/3acfa95f4eb6260c714fdb00a3d84be8eedc13b2/lib/redis/store/ttl.rb#L32 request.env['rack.session.options'][:expire_after] = expiry_s end + + def send_rate_limited?(user) + Gitlab::ApplicationRateLimiter.peek(:email_verification_code_send, scope: user) + end + + def obfuscated_email(email) + regex = ::Gitlab::UntrustedRegexp.new('^(..?)(.*)(@.?)(.*)(\..*)$') + match = regex.match(email) + return email unless match + + match[1] + '*' * match[2].length + match[3] + '*' * match[4].length + match[5] + end end diff --git a/app/mailers/emails/identity_verification.rb b/app/mailers/emails/identity_verification.rb new file mode 100644 index 00000000000..2fc8cae06fe --- /dev/null +++ b/app/mailers/emails/identity_verification.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Emails + module IdentityVerification + def verification_instructions_email(user_id, token:, expires_in:) + @token = token + @expires_in_minutes = expires_in + @password_link = edit_profile_password_url + @two_fa_link = help_page_url('user/profile/account/two_factor_authentication') + + user = User.find(user_id) + email_with_layout(to: user.email, subject: s_('IdentityVerification|Verify your identity')) + end + end +end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index b70ce1d3655..ed7681e595f 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -23,6 +23,7 @@ class Notify < ApplicationMailer include Emails::ServiceDesk include Emails::InProductMarketing include Emails::AdminNotification + include Emails::IdentityVerification helper TimeboxesHelper helper MergeRequestsHelper diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index 074aec54b10..be8d96012cc 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -213,6 +213,10 @@ class NotifyPreview < ActionMailer::Preview ::Notify.user_auto_banned_email(user.id, user.id, max_project_downloads: 5, within_seconds: 600, group: group).message end + def verification_instructions_email + Notify.verification_instructions_email(user.id, token: '123456', expires_in: 60).message + end + private def project diff --git a/app/models/authentication_event.rb b/app/models/authentication_event.rb index 1e822629ba1..0ed197f32df 100644 --- a/app/models/authentication_event.rb +++ b/app/models/authentication_event.rb @@ -25,4 +25,9 @@ class AuthenticationEvent < ApplicationRecord def self.providers STATIC_PROVIDERS | Devise.omniauth_providers.map(&:to_s) end + + def self.initial_login_or_known_ip_address?(user, ip_address) + !where(user_id: user).exists? || + where(user_id: user, ip_address: ip_address).success.exists? + end end diff --git a/app/models/concerns/require_email_verification.rb b/app/models/concerns/require_email_verification.rb new file mode 100644 index 00000000000..eb00a9647a3 --- /dev/null +++ b/app/models/concerns/require_email_verification.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# == Require Email Verification module +# +# Contains functionality to handle email verification +module RequireEmailVerification + extend ActiveSupport::Concern + include Gitlab::Utils::StrongMemoize + + # This value is twice the amount we want it to be, because due to a bug in the devise-two-factor + # gem every failed login attempt increments the value of failed_attempts by 2 instead of 1. + # See: https://github.com/tinfoil/devise-two-factor/issues/127 + MAXIMUM_ATTEMPTS = 3 * 2 + UNLOCK_IN = 24.hours + + included do + # Virtual attribute for the email verification token form + attr_accessor :verification_token + end + + # When overridden, do not send Devise unlock instructions when locking access. + def lock_access!(opts = {}) + return super unless override_devise_lockable? + + super({ send_instructions: false }) + end + + protected + + # We cannot override the class methods `maximum_attempts` and `unlock_in`, because we want to + # check for 2FA being enabled on the instance. So instead override the Devise Lockable methods + # where those values are used. + def attempts_exceeded? + return super unless override_devise_lockable? + + failed_attempts >= MAXIMUM_ATTEMPTS + end + + def lock_expired? + return super unless override_devise_lockable? + + locked_at && locked_at < UNLOCK_IN.ago + end + + private + + def override_devise_lockable? + strong_memoize(:override_devise_lockable) do + Feature.enabled?(:require_email_verification) && !two_factor_enabled? + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index b35036d0af7..20ff796aba0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -88,6 +88,7 @@ class User < ApplicationRecord # and should be added after Devise modules are initialized. include AsyncDeviseEmail include ForcedEmailConfirmation + include RequireEmailVerification MINIMUM_INACTIVE_DAYS = 90 MINIMUM_DAYS_CREATED = 7 @@ -1899,7 +1900,7 @@ class User < ApplicationRecord end # override, from Devise - def lock_access! + def lock_access!(opts = {}) Gitlab::AppLogger.info("Account Locked: username=#{username}") super end diff --git a/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb b/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb index b7f8b268f18..b5f105a6c89 100644 --- a/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb +++ b/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb @@ -24,6 +24,7 @@ module IncidentManagement def after_update sync_status_to_alert add_status_system_note + add_timeline_event end def sync_status_to_alert @@ -43,6 +44,13 @@ module IncidentManagement SystemNoteService.change_incident_status(issuable, current_user, params[:status_change_reason]) end + + def add_timeline_event + return unless escalation_status.status_previously_changed? + + IncidentManagement::TimelineEvents::CreateService + .change_incident_status(issuable, current_user, escalation_status) + end end end end diff --git a/app/services/incident_management/timeline_events/create_service.rb b/app/services/incident_management/timeline_events/create_service.rb index 5e5feed65c2..3cb67ccf2b1 100644 --- a/app/services/incident_management/timeline_events/create_service.rb +++ b/app/services/incident_management/timeline_events/create_service.rb @@ -4,6 +4,7 @@ module IncidentManagement module TimelineEvents DEFAULT_ACTION = 'comment' DEFAULT_EDITABLE = false + DEFAULT_AUTO_CREATED = false class CreateService < TimelineEvents::BaseService def initialize(incident, user, params) @@ -11,6 +12,42 @@ module IncidentManagement @incident = incident @user = user @params = params + @auto_created = !!params.fetch(:auto_created, DEFAULT_AUTO_CREATED) + end + + class << self + def create_incident(incident, user) + note = "@#{user.username} created the incident" + occurred_at = incident.created_at + action = 'issues' + + new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute + end + + def reopen_incident(incident, user) + note = "@#{user.username} reopened the incident" + occurred_at = incident.updated_at + action = 'issues' + + new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute + end + + def resolve_incident(incident, user) + note = "@#{user.username} resolved the incident" + occurred_at = incident.updated_at + action = 'status' + + new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute + end + + def change_incident_status(incident, user, escalation_status) + status = escalation_status.status_name.to_s.titleize + note = "@#{user.username} changed the incident status to **#{status}**" + occurred_at = incident.updated_at + action = 'status' + + new(incident, user, note: note, occurred_at: occurred_at, action: action, auto_created: true).execute + end end def execute @@ -32,8 +69,8 @@ module IncidentManagement if timeline_event.save add_system_note(timeline_event) - track_usage_event(:incident_management_timeline_event_created, user.id) + success(timeline_event) else error_in_save(timeline_event) @@ -42,9 +79,16 @@ module IncidentManagement private - attr_reader :project, :user, :incident, :params + attr_reader :project, :user, :incident, :params, :auto_created + + def allowed? + return true if auto_created + + super + end def add_system_note(timeline_event) + return if auto_created return unless Feature.enabled?(:incident_timeline, project) SystemNoteService.add_timeline_event(timeline_event) diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb index ff45091c7e6..d08e4d12a92 100644 --- a/app/services/issues/close_service.rb +++ b/app/services/issues/close_service.rb @@ -97,7 +97,10 @@ module Issues status = issue.incident_management_issuable_escalation_status || issue.build_incident_management_issuable_escalation_status - SystemNoteService.change_incident_status(issue, current_user, ' by closing the incident') if status.resolve + return unless status.resolve + + SystemNoteService.change_incident_status(issue, current_user, ' by closing the incident') + IncidentManagement::TimelineEvents::CreateService.resolve_incident(issue, current_user) end def store_first_mentioned_in_commit_at(issue, merge_request, max_commit_lookup: 100) diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index d4fbbf67420..91fbe75640f 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -57,6 +57,7 @@ module Issues handle_add_related_issue(issue) resolve_discussions_with_issue(issue) create_escalation_status(issue) + create_timeline_event(issue) try_to_associate_contacts(issue) super @@ -92,6 +93,12 @@ module Issues ::IncidentManagement::IssuableEscalationStatuses::CreateService.new(issue).execute if issue.supports_escalation? end + def create_timeline_event(issue) + return unless issue.incident? + + IncidentManagement::TimelineEvents::CreateService.create_incident(issue, current_user) + end + def user_agent_detail_service UserAgentDetailService.new(spammable: @issue, spam_params: spam_params) end diff --git a/app/services/issues/reopen_service.rb b/app/services/issues/reopen_service.rb index 4abd1dfbf4e..e003ecacb3f 100644 --- a/app/services/issues/reopen_service.rb +++ b/app/services/issues/reopen_service.rb @@ -32,11 +32,18 @@ module Issues end def perform_incident_management_actions(issue) + return unless issue.incident? + + create_timeline_event(issue) end def create_note(issue, state = issue.state) SystemNoteService.change_status(issue, issue.project, current_user, state, nil) end + + def create_timeline_event(issue) + IncidentManagement::TimelineEvents::CreateService.reopen_incident(issue, current_user) + end end end diff --git a/app/views/devise/sessions/email_verification.haml b/app/views/devise/sessions/email_verification.haml new file mode 100644 index 00000000000..6cafcb941b4 --- /dev/null +++ b/app/views/devise/sessions/email_verification.haml @@ -0,0 +1,19 @@ +%div + = render 'devise/shared/tab_single', tab_title: s_('IdentityVerification|Help us protect your account') + .login-box.gl-p-5 + .login-body + = form_for(resource, as: resource_name, url: session_path(resource_name), method: :post, html: { class: 'gl-show-field-errors' }) do |f| + %p + = s_("IdentityVerification|For added security, you'll need to verify your identity. We've sent a verification code to %{email}").html_safe % { email: "#{sanitize(obfuscated_email(resource.email))}".html_safe } + %div + = f.label :verification_token, s_('IdentityVerification|Verification code') + = f.text_field :verification_token, class: 'form-control gl-form-input', required: true, autofocus: true, autocomplete: 'off', title: s_('IdentityVerification|Please enter a valid code'), inputmode: 'numeric', maxlength: 6, pattern: '[0-9]{6}' + %p.gl-field-error.gl-mt-2 + = resource.errors.full_messages.to_sentence + .gl-mt-5 + = f.submit s_('IdentityVerification|Verify code'), class: 'gl-button btn btn-confirm' + - unless send_rate_limited?(resource) + = link_to s_('IdentityVerification|Resend code'), users_resend_verification_code_path, method: :post, class: 'form-control gl-button btn-link gl-mt-3 gl-mb-0' + %p.gl-p-5.gl-text-secondary + - support_link_start = ''.html_safe + = s_("IdentityVerification|If you've lost access to the email associated to this account or having trouble with the code, %{link_start}here are some other steps you can take.%{link_end}").html_safe % { link_start: support_link_start, link_end: ''.html_safe } diff --git a/app/views/devise/sessions/successful_verification.haml b/app/views/devise/sessions/successful_verification.haml new file mode 100644 index 00000000000..8af80fbdceb --- /dev/null +++ b/app/views/devise/sessions/successful_verification.haml @@ -0,0 +1,11 @@ += content_for :meta_tags do + %meta{ 'http-equiv': 'refresh', content: "3; url=#{@redirect_url}" } +.gl-text-center.gl-max-w-62.gl-mx-auto + .svg-content.svg-80 + = image_tag 'illustrations/success-sm.svg' + %h2 + = s_('IdentityVerification|Verification successful') + %p.gl-pt-2 + - redirect_url_start = ''.html_safe % { url: @redirect_url } + - redirect_url_end = ''.html_safe + = html_escape(s_("IdentityVerification|Your account has been successfully verified. You'll be redirected to your account in just a moment or %{redirect_url_start}click here%{redirect_url_end} to refresh.")) % { redirect_url_start: redirect_url_start, redirect_url_end: redirect_url_end } diff --git a/app/views/notify/verification_instructions_email.html.haml b/app/views/notify/verification_instructions_email.html.haml new file mode 100644 index 00000000000..63d8d1b2461 --- /dev/null +++ b/app/views/notify/verification_instructions_email.html.haml @@ -0,0 +1,12 @@ +%div{ style: 'text-align:center;color:#1F1F1F;line-height:1.25em;max-width:400px;margin:0 auto;' } + %h3 + = s_('IdentityVerification|Help us protect your account') + %p{ style: 'font-size:0.9em' } + = s_('IdentityVerification|Before you sign in, we need to verify your identity. Enter the following code on the sign-in page.') + %div{ style: 'margin:26px 0;width:207px;height:53px;background-color:#F0F0F0;line-height:53px;font-weight:700;font-size:1.5em;color:#303030;' } + = @token + %p{ style: 'font-size:0.75em' } + = s_('IdentityVerification|If you have not recently tried to sign into GitLab, we recommend %{password_link_start}changing your password%{link_end} and %{two_fa_link_start}setting up Two-Factor Authentication%{link_end} to keep your account safe. Your verification code expires after %{expires_in_minutes} minutes.').html_safe % { link_end: link_end, + password_link_start: link_start(@password_link), + two_fa_link_start: link_start(@two_fa_link), + expires_in_minutes: @expires_in_minutes } diff --git a/app/views/notify/verification_instructions_email.text.erb b/app/views/notify/verification_instructions_email.text.erb new file mode 100644 index 00000000000..df507b5db71 --- /dev/null +++ b/app/views/notify/verification_instructions_email.text.erb @@ -0,0 +1,8 @@ +<%= s_('IdentityVerification|Help us protect your account') %> + +<%= s_('IdentityVerification|Before you sign in, we need to verify your identity. Enter the following code on the sign-in page.') %> + +<%= @token %> + +<%= s_('IdentityVerification|If you have not recently tried to sign into GitLab, we recommend changing your password (%{password_link}) and setting up Two-Factor Authentication (%{two_fa_link}) to keep your account safe.') % { password_link: @password_link, two_fa_link: @two_fa_link } %> +<%= s_('IdentityVerification|Your verification code expires after %{expires_in_minutes} minutes.') % { expires_in_minutes: @expires_in_minutes } %> diff --git a/app/views/projects/logs/empty_logs.html.haml b/app/views/projects/logs/empty_logs.html.haml deleted file mode 100644 index 48403f5e55e..00000000000 --- a/app/views/projects/logs/empty_logs.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- page_title _('Logs') - -.row.empty-state - .col-sm-12 - .svg-content - = image_tag 'illustrations/operations_log_pods_empty.svg' - .col-12 - .text-content - %h4.text-center - = s_('Environments|No deployed environments') - %p.state-description.text-center - = s_('Logs|To see the logs, deploy your code to an environment.') - .text-center - = link_to s_('Environments|Learn about environments'), help_page_path('ci/environments/index.md'), class: 'gl-button btn btn-confirm' diff --git a/app/views/projects/logs/index.html.haml b/app/views/projects/logs/index.html.haml deleted file mode 100644 index 1f74eb52fd9..00000000000 --- a/app/views/projects/logs/index.html.haml +++ /dev/null @@ -1 +0,0 @@ -#environment-logs{ data: environment_logs_data(@project, @environment) } diff --git a/config/events/1655726589_ide_edit_g_edit_by_web_ide.yml b/config/events/1655726589_ide_edit_g_edit_by_web_ide.yml new file mode 100644 index 00000000000..128bfaf6029 --- /dev/null +++ b/config/events/1655726589_ide_edit_g_edit_by_web_ide.yml @@ -0,0 +1,22 @@ +--- +description: Triggered from backend on editing file in web ide +category: ide_edit +action: g_edit_by_web_ide +identifiers: +- project +- user +- namespace +product_section: dev +product_stage: create +product_group: group::editor +product_category: web_ide +milestone: "15.1" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90484 +distributions: +- ce +- ee +tiers: +- free +- premium +- ultimate + diff --git a/config/events/1655726622_ide_edit_g_edit_by_live_preview.yml b/config/events/1655726622_ide_edit_g_edit_by_live_preview.yml new file mode 100644 index 00000000000..d9d54e1c311 --- /dev/null +++ b/config/events/1655726622_ide_edit_g_edit_by_live_preview.yml @@ -0,0 +1,22 @@ +--- +description: Triggered from backend on showing a file in live preview +category: ide_edit +action: g_edit_by_live_preview +identifiers: + - project + - user + - namespace +product_section: dev +product_stage: create +product_group: group::editor +product_category: web_ide +milestone: "15.1" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90484 +distributions: + - ce + - ee +tiers: + - free + - premium + - ultimate + diff --git a/config/events/1655726650_ide_edit_g_edit_by_sfe.yml b/config/events/1655726650_ide_edit_g_edit_by_sfe.yml new file mode 100644 index 00000000000..9acdc317cf5 --- /dev/null +++ b/config/events/1655726650_ide_edit_g_edit_by_sfe.yml @@ -0,0 +1,22 @@ +--- +description: Triggered from backend on editing file by sfe +category: ide_edit +action: g_edit_by_sfe +identifiers: + - project + - user + - namespace +product_section: dev +product_stage: create +product_group: group::editor +product_category: web_ide +milestone: "15.1" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90484 +distributions: + - ce + - ee +tiers: + - free + - premium + - ultimate + diff --git a/config/events/1655726683_ide_edit_g_edit_by_snippet_ide.yml b/config/events/1655726683_ide_edit_g_edit_by_snippet_ide.yml new file mode 100644 index 00000000000..2b3ed1a5d7a --- /dev/null +++ b/config/events/1655726683_ide_edit_g_edit_by_snippet_ide.yml @@ -0,0 +1,22 @@ +--- +description: Triggered from backend on editing file by ide snippet +category: ide_edit +action: g_edit_by_snippet_ide +identifiers: + - project + - user + - namespace +product_section: dev +product_stage: create +product_group: group::editor +product_category: web_ide +milestone: "15.1" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90484 +distributions: + - ce + - ee +tiers: + - free + - premium + - ultimate + diff --git a/config/feature_flags/development/require_email_verification.yml b/config/feature_flags/development/require_email_verification.yml new file mode 100644 index 00000000000..e6cb78ffcf7 --- /dev/null +++ b/config/feature_flags/development/require_email_verification.yml @@ -0,0 +1,8 @@ +--- +name: require_email_verification +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86352 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/364835 +milestone: "15.2" +type: development +group: group::anti-abuse +default_enabled: false diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 91b197afd32..ed1684b48a5 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -661,12 +661,6 @@ production: &base gitlab_ci: # Default project notifications settings: - # - # Send emails only on broken builds (default: true) - # all_broken_builds: true - # - # Add pusher to recipients list (default: false) - # add_pusher: true # The location where build traces are stored (default: builds/). Relative paths are relative to Rails.root # builds_path: builds/ diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index c94f0009678..dca82e73075 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -241,8 +241,6 @@ end # Settings['gitlab_ci'] ||= Settingslogic.new({}) Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil? -Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil? -Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil? Settings.gitlab_ci['builds_path'] = Settings.absolute(Settings.gitlab_ci['builds_path'] || "builds/") Settings.gitlab_ci['url'] ||= Settings.__send__(:build_gitlab_ci_url) diff --git a/config/routes/user.rb b/config/routes/user.rb index ccacf817cc5..a5fc53b61d2 100644 --- a/config/routes/user.rb +++ b/config/routes/user.rb @@ -53,6 +53,8 @@ end devise_scope :user do get '/users/almost_there' => 'confirmations#almost_there' + post '/users/resend_verification_code', to: 'sessions#resend_verification_code' + get '/users/successful_verification', to: 'sessions#successful_verification' end scope '-/users', module: :users do diff --git a/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb b/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb new file mode 100644 index 00000000000..aa860959c20 --- /dev/null +++ b/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUserIdAndIpAddressSuccessIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0] + OLD_INDEX_NAME = 'index_authentication_events_on_user_id' + NEW_INDEX_NAME = 'index_authentication_events_on_user_and_ip_address_and_result' + + disable_ddl_transaction! + + def up + add_concurrent_index :authentication_events, [:user_id, :ip_address, :result], name: NEW_INDEX_NAME + remove_concurrent_index_by_name :authentication_events, OLD_INDEX_NAME + end + + def down + add_concurrent_index :authentication_events, :user_id, name: OLD_INDEX_NAME + remove_concurrent_index_by_name :authentication_events, NEW_INDEX_NAME + end +end diff --git a/db/schema_migrations/20220601152916 b/db/schema_migrations/20220601152916 new file mode 100644 index 00000000000..4858976aa3a --- /dev/null +++ b/db/schema_migrations/20220601152916 @@ -0,0 +1 @@ +f460407888e289580dec15ea27e19fa5cc2d2116a831105b71b980c617971743 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index e511bd88618..21880fea0af 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -27282,7 +27282,7 @@ CREATE INDEX index_authentication_events_on_provider ON authentication_events US CREATE INDEX index_authentication_events_on_provider_user_id_created_at ON authentication_events USING btree (provider, user_id, created_at) WHERE (result = 1); -CREATE INDEX index_authentication_events_on_user_id ON authentication_events USING btree (user_id); +CREATE INDEX index_authentication_events_on_user_and_ip_address_and_result ON authentication_events USING btree (user_id, ip_address, result); CREATE INDEX index_award_emoji_on_awardable_type_and_awardable_id ON award_emoji USING btree (awardable_type, awardable_id); diff --git a/doc/administration/geo/disaster_recovery/planned_failover.md b/doc/administration/geo/disaster_recovery/planned_failover.md index c351b4031b5..5a5d896c20a 100644 --- a/doc/administration/geo/disaster_recovery/planned_failover.md +++ b/doc/administration/geo/disaster_recovery/planned_failover.md @@ -60,8 +60,8 @@ Alternatively, you can [back up](../../../raketasks/backup_restore.md#back-up-gi the container registry on the primary site and restore it onto the secondary site: -1. On your primary site, back up only the registry and [exclude specific directories -from the backup](../../../raketasks/backup_restore.md#excluding-specific-directories-from-the-backup): +1. On your primary site, back up only the registry and + [exclude specific directories from the backup](../../../raketasks/backup_gitlab.md#excluding-specific-directories-from-the-backup): ```shell # Create a backup in the /var/opt/gitlab/backups folder diff --git a/doc/administration/geo/setup/index.md b/doc/administration/geo/setup/index.md index f7d47d82e71..5ddfee6774e 100644 --- a/doc/administration/geo/setup/index.md +++ b/doc/administration/geo/setup/index.md @@ -16,13 +16,13 @@ You must use a [GitLab Premium](https://about.gitlab.com/pricing/) license or hi but you only need one license for all the sites. WARNING: -The steps below should be followed in the order they appear. **Make sure the GitLab version is the same on all sites.** +The steps below should be followed in the order they appear. **Make sure the GitLab version is the same on all sites. Do not create an account or log in to the new secondary.** ## Using Omnibus GitLab If you installed GitLab using the Omnibus packages (highly recommended): -1. [Install GitLab Enterprise Edition](https://about.gitlab.com/install/) on the nodes that serve as the **secondary** site. Do not create an account or log in to the new **secondary** site. The **GitLab version must match** across primary and secondary sites. +1. [Install GitLab Enterprise Edition](https://about.gitlab.com/install/) on the nodes that serve as the **secondary** site. **Do not create an account or log in** to the new **secondary** site. The **GitLab version must match** across primary and secondary sites. 1. [Add the GitLab License](../../../user/admin_area/license.md) on the **primary** site to unlock Geo. The license must be for [GitLab Premium](https://about.gitlab.com/pricing/) or higher. 1. [Set up the database replication](database.md) (`primary (read-write) <-> secondary (read-only)` topology). 1. [Configure fast lookup of authorized SSH keys in the database](../../operations/fast_ssh_key_lookup.md). This step is required and needs to be done on **both** the **primary** and **secondary** sites. diff --git a/doc/administration/object_storage.md b/doc/administration/object_storage.md index 5e54835c670..ddeaf0280eb 100644 --- a/doc/administration/object_storage.md +++ b/doc/administration/object_storage.md @@ -76,7 +76,7 @@ because it does not require a shared folder. Consolidated object storage configuration can't be used for backups or Mattermost. See the [full table for a complete list](#storage-specific-configuration). -However, backups can be configured with [server side encryption](../raketasks/backup_restore.md#s3-encrypted-buckets) separately. +However, backups can be configured with [server side encryption](../raketasks/backup_gitlab.md#s3-encrypted-buckets) separately. Enabling consolidated object storage enables object storage for all object types. If not all buckets are specified, `sudo gitlab-ctl reconfigure` may fail with the error like: @@ -528,7 +528,7 @@ supported by consolidated configuration form, refer to the following guides: | Object storage type | Supported by consolidated configuration? | |---------------------|------------------------------------------| -| [Backups](../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | **{dotted-circle}** No | +| [Backups](../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | **{dotted-circle}** No | | [Job artifacts](job_artifacts.md#using-object-storage) including archived job logs | **{check-circle}** Yes | | [LFS objects](lfs/index.md#storing-lfs-objects-in-remote-object-storage) | **{check-circle}** Yes | | [Uploads](uploads.md#using-object-storage) | **{check-circle}** Yes | @@ -587,7 +587,7 @@ Helm-based installs require separate buckets to ### S3 API compatibility issues -Not all S3 providers [are fully compatible](../raketasks/backup_restore.md#other-s3-providers) +Not all S3 providers [are fully compatible](../raketasks/backup_gitlab.md#other-s3-providers) with the Fog library that GitLab uses. Symptoms include an error in `production.log`: ```plaintext diff --git a/doc/administration/operations/moving_repositories.md b/doc/administration/operations/moving_repositories.md index 1de04978958..8d36a40663f 100644 --- a/doc/administration/operations/moving_repositories.md +++ b/doc/administration/operations/moving_repositories.md @@ -189,9 +189,9 @@ should be used. Git repositories are accessed, managed, and stored on GitLab ser can result from directly accessing and copying Gitaly's files using tools like `rsync`. - From GitLab 13.3, backup performance can be improved by - [processing multiple repositories concurrently](../../raketasks/backup_restore.md#back-up-git-repositories-concurrently). + [processing multiple repositories concurrently](../../raketasks/backup_gitlab.md#back-up-git-repositories-concurrently). - Backups can be created of just the repositories using the - [skip feature](../../raketasks/backup_restore.md#excluding-specific-directories-from-the-backup). + [skip feature](../../raketasks/backup_gitlab.md#excluding-specific-directories-from-the-backup). No other method works for Gitaly Cluster targets. diff --git a/doc/administration/reference_architectures/10k_users.md b/doc/administration/reference_architectures/10k_users.md index 99272cdd226..7901fcaf78d 100644 --- a/doc/administration/reference_architectures/10k_users.md +++ b/doc/administration/reference_architectures/10k_users.md @@ -2202,7 +2202,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/25k_users.md b/doc/administration/reference_architectures/25k_users.md index 367654b8e59..3ebe37efe4e 100644 --- a/doc/administration/reference_architectures/25k_users.md +++ b/doc/administration/reference_architectures/25k_users.md @@ -2206,7 +2206,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/2k_users.md b/doc/administration/reference_architectures/2k_users.md index 3b9a8f966c8..30af94cd745 100644 --- a/doc/administration/reference_architectures/2k_users.md +++ b/doc/administration/reference_architectures/2k_users.md @@ -916,7 +916,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/3k_users.md b/doc/administration/reference_architectures/3k_users.md index a43d33a4d4a..0dbeb480ed0 100644 --- a/doc/administration/reference_architectures/3k_users.md +++ b/doc/administration/reference_architectures/3k_users.md @@ -2141,7 +2141,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/50k_users.md b/doc/administration/reference_architectures/50k_users.md index 316969dfacc..ac41a6fbf53 100644 --- a/doc/administration/reference_architectures/50k_users.md +++ b/doc/administration/reference_architectures/50k_users.md @@ -2222,7 +2222,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/5k_users.md b/doc/administration/reference_architectures/5k_users.md index fda539a3989..2751443ca65 100644 --- a/doc/administration/reference_architectures/5k_users.md +++ b/doc/administration/reference_architectures/5k_users.md @@ -2141,7 +2141,7 @@ on what features you intend to use: |Object storage type|Supported by consolidated configuration?| |-------------------|----------------------------------------| -| [Backups](../../raketasks/backup_restore.md#uploading-backups-to-a-remote-cloud-storage) | No | +| [Backups](../../raketasks/backup_gitlab.md#uploading-backups-to-a-remote-cloud-storage) | No | | [Job artifacts](../job_artifacts.md#using-object-storage) including archived job logs | Yes | | [LFS objects](../lfs/index.md#storing-lfs-objects-in-remote-object-storage) | Yes | | [Uploads](../uploads.md#using-object-storage) | Yes | diff --git a/doc/administration/reference_architectures/index.md b/doc/administration/reference_architectures/index.md index e56c5ba1277..aa11d2a8866 100644 --- a/doc/administration/reference_architectures/index.md +++ b/doc/administration/reference_architectures/index.md @@ -401,7 +401,7 @@ have more actual perceived uptime for your users. This solution is appropriate for many teams that have the default GitLab installation. With automatic backups of the GitLab repositories, configuration, and the database, this can be an optimal solution if you don't have strict requirements. -[Automated backups](../../raketasks/backup_restore.md#configuring-cron-to-make-daily-backups) +[Automated backups](../../raketasks/backup_gitlab.md#configuring-cron-to-make-daily-backups) is the least complex to setup. This provides a point-in-time recovery of a predetermined schedule. ### Traffic load balancer **(PREMIUM SELF)** diff --git a/doc/administration/reference_architectures/troubleshooting.md b/doc/administration/reference_architectures/troubleshooting.md index 2d10d05da37..ce14e0f96ef 100644 --- a/doc/administration/reference_architectures/troubleshooting.md +++ b/doc/administration/reference_architectures/troubleshooting.md @@ -13,7 +13,7 @@ the [reference architectures](index.md#reference-architectures). ### S3 API compatibility issues -Not all S3 providers [are fully compatible](../../raketasks/backup_restore.md#other-s3-providers) +Not all S3 providers [are fully compatible](../../raketasks/backup_gitlab.md#other-s3-providers) with the Fog library that GitLab uses. Symptoms include: ```plaintext diff --git a/doc/api/integrations.md b/doc/api/integrations.md index eaa826b3686..fca1d02161b 100644 --- a/doc/api/integrations.md +++ b/doc/api/integrations.md @@ -1033,7 +1033,6 @@ Parameters: | Parameter | Type | Required | Description | | --------- | ---- | -------- | ----------- | | `recipients` | string | yes | Comma-separated list of recipient email addresses | -| `add_pusher` | boolean | no | Add pusher to recipients list | | `notify_only_broken_pipelines` | boolean | no | Notify only broken pipelines | | `branches_to_be_notified` | string | false | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected. The default value is "default" | | `notify_only_default_branch` | boolean | no | Send notifications only for the default branch ([introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/28271)) | diff --git a/doc/ci/cloud_deployment/ecs/deploy_to_aws_ecs.md b/doc/ci/cloud_deployment/ecs/deploy_to_aws_ecs.md index 5894efa95ab..aea7b492d4e 100644 --- a/doc/ci/cloud_deployment/ecs/deploy_to_aws_ecs.md +++ b/doc/ci/cloud_deployment/ecs/deploy_to_aws_ecs.md @@ -252,7 +252,7 @@ To use [Review Apps](../../../development/testing_guide/review_apps.md) with ECS 1. Set up a new [service](#create-an-ecs-service). 1. Use the `CI_AWS_ECS_SERVICE` variable to set the name. -1. Set the environment scope to `review/*`. +1. Set the environment scope to `review/*`. Only one Review App at a time can be deployed because this service is shared by all review apps. @@ -282,9 +282,9 @@ include: To use DAST on the default branch: 1. Set up a new [service](#create-an-ecs-service). This service will be used to deploy a temporary -DAST environment. +DAST environment. 1. Use the `CI_AWS_ECS_SERVICE` variable to set the name. -1. Set the scope to the `dast-default` environment. +1. Set the scope to the `dast-default` environment. 1. Add the following to your `.gitlab-ci.yml` file: ```yaml diff --git a/doc/development/testing_guide/end_to_end/resources.md b/doc/development/testing_guide/end_to_end/resources.md index a7626d372a8..a519d1ecb47 100644 --- a/doc/development/testing_guide/end_to_end/resources.md +++ b/doc/development/testing_guide/end_to_end/resources.md @@ -570,12 +570,12 @@ end ### Resources cleanup -We have a mechanism to [collect](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resource_data_processor.rb#L32) -all resources created during test executions, and another to [handle](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resources_handler.rb#L44) -these resources. On [dotcom environments](https://about.gitlab.com/handbook/engineering/infrastructure/environments/#environments), after a test suite finishes in the [QA pipelines](https://about.gitlab.com/handbook/engineering/quality/quality-engineering/debugging-qa-test-failures/#scheduled-qa-test-pipelines), resources from all passing test are -automatically deleted in the same pipeline run. Resources from all failed tests are reserved for investigation, +We have a mechanism to [collect](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resource_data_processor.rb#L32) +all resources created during test executions, and another to [handle](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resources_handler.rb#L44) +these resources. On [dotcom environments](https://about.gitlab.com/handbook/engineering/infrastructure/environments/#environments), after a test suite finishes in the [QA pipelines](https://about.gitlab.com/handbook/engineering/quality/quality-engineering/debugging-qa-test-failures/#scheduled-qa-test-pipelines), resources from all passing test are +automatically deleted in the same pipeline run. Resources from all failed tests are reserved for investigation, and won't be deleted until the following Saturday by a scheduled pipeline. When introducing new resources, please -also make sure to add any resource that cannot be deleted to the [IGNORED_RESOURCES](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resources_handler.rb#L29) +also make sure to add any resource that cannot be deleted to the [IGNORED_RESOURCES](https://gitlab.com/gitlab-org/gitlab/-/blob/44345381e89d6bbd440f7b4c680d03e8b75b86de/qa/qa/tools/test_resources_handler.rb#L29) list. ## Where to ask for help? diff --git a/doc/install/aws/manual_install_aws.md b/doc/install/aws/manual_install_aws.md index 060bd08580f..7494dc1e95e 100644 --- a/doc/install/aws/manual_install_aws.md +++ b/doc/install/aws/manual_install_aws.md @@ -754,10 +754,10 @@ and restore its Git data, database, attachments, LFS objects, and so on. Some important things to know: - The backup/restore tool **does not** store some configuration files, like secrets; you - must [configure this yourself](../../raketasks/backup_restore.md#storing-configuration-files). + must [configure this yourself](../../raketasks/backup_gitlab.md#storing-configuration-files). - By default, the backup files are stored locally, but you can - [backup GitLab using S3](../../raketasks/backup_restore.md#using-amazon-s3). -- You can [exclude specific directories form the backup](../../raketasks/backup_restore.md#excluding-specific-directories-from-the-backup). + [backup GitLab using S3](../../raketasks/backup_gitlab.md#using-amazon-s3). +- You can [exclude specific directories form the backup](../../raketasks/backup_gitlab.md#excluding-specific-directories-from-the-backup). ### Backing up GitLab @@ -777,7 +777,7 @@ For GitLab 12.1 and earlier, use `gitlab-rake gitlab:backup:create`. To restore GitLab, first review the [restore documentation](../../raketasks/backup_restore.md#restore-gitlab), and primarily the restore prerequisites. Then, follow the steps under the -[Omnibus installations section](../../raketasks/backup_restore.md#restore-for-omnibus-gitlab-installations). +[Omnibus installations section](../../raketasks/restore_gitlab.md#restore-for-omnibus-gitlab-installations). ## Updating GitLab diff --git a/doc/raketasks/backup_gitlab.md b/doc/raketasks/backup_gitlab.md new file mode 100644 index 00000000000..8d5ae14a043 --- /dev/null +++ b/doc/raketasks/backup_gitlab.md @@ -0,0 +1,908 @@ +--- +stage: Systems +group: Geo +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Back up GitLab + +GitLab provides a command line interface to back up your entire instance, +including: + +- Database +- Attachments +- Git repositories data +- CI/CD job output logs +- CI/CD job artifacts +- LFS objects +- Terraform states ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/331806) in GitLab 14.7) +- Container Registry images +- GitLab Pages content +- Packages ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332006) in GitLab 14.7) +- Snippets +- [Group wikis](../user/project/wiki/group.md) + +Backups do not include: + +- [Mattermost data](https://docs.mattermost.com/administration/config-settings.html#file-storage) +- Redis (and thus Sidekiq jobs) + +WARNING: +GitLab does not back up any configuration files (`/etc/gitlab`), TLS keys and certificates, or system +files. You are highly advised to read about [storing configuration files](#storing-configuration-files). + +WARNING: +The backup command requires [additional parameters](backup_restore.md#back-up-and-restore-for-installations-using-pgbouncer) when +your installation is using PgBouncer, for either performance reasons or when using it with a Patroni cluster. + +Depending on your version of GitLab, use the following command if you installed +GitLab using the Omnibus package: + +- GitLab 12.2 or later: + + ```shell + sudo gitlab-backup create + ``` + +- GitLab 12.1 and earlier: + + ```shell + gitlab-rake gitlab:backup:create + ``` + +If you installed GitLab from source, use the following command: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +If you're running GitLab from within a Docker container, run the backup from +the host, based on your installed version of GitLab: + +- GitLab 12.2 or later: + + ```shell + docker exec -t gitlab-backup create + ``` + +- GitLab 12.1 and earlier: + + ```shell + docker exec -t gitlab-rake gitlab:backup:create + ``` + +If you're using the [GitLab Helm chart](https://gitlab.com/gitlab-org/charts/gitlab) +on a Kubernetes cluster, you can run the backup task by using `kubectl` to run the `backup-utility` +script on the GitLab toolbox pod. For more details, see the +[charts backup documentation](https://docs.gitlab.com/charts/backup-restore/backup.html). + +Similar to the Kubernetes case, if you have scaled out your GitLab cluster to +use multiple application servers, you should pick a designated node (that isn't +auto-scaled away) for running the backup Rake task. Because the backup Rake +task is tightly coupled to the main Rails application, this is typically a node +on which you're also running Puma or Sidekiq. + +Example output: + +```plaintext +Dumping database tables: +- Dumping table events... [DONE] +- Dumping table issues... [DONE] +- Dumping table keys... [DONE] +- Dumping table merge_requests... [DONE] +- Dumping table milestones... [DONE] +- Dumping table namespaces... [DONE] +- Dumping table notes... [DONE] +- Dumping table projects... [DONE] +- Dumping table protected_branches... [DONE] +- Dumping table schema_migrations... [DONE] +- Dumping table services... [DONE] +- Dumping table snippets... [DONE] +- Dumping table taggings... [DONE] +- Dumping table tags... [DONE] +- Dumping table users... [DONE] +- Dumping table users_projects... [DONE] +- Dumping table web_hooks... [DONE] +- Dumping table wikis... [DONE] +Dumping repositories: +- Dumping repository abcd... [DONE] +Creating backup archive: $TIMESTAMP_gitlab_backup.tar [DONE] +Deleting tmp directories...[DONE] +Deleting old backups... [SKIPPING] +``` + +## Storing configuration files + +The [backup Rake task](#back-up-gitlab) GitLab provides does _not_ store your +configuration files. The primary reason for this is that your database contains +items including encrypted information for two-factor authentication and the +CI/CD _secure variables_. Storing encrypted information in the same location +as its key defeats the purpose of using encryption in the first place. + +WARNING: +The secrets file is essential to preserve your database encryption key. + +At the very **minimum**, you must back up: + +For Omnibus: + +- `/etc/gitlab/gitlab-secrets.json` +- `/etc/gitlab/gitlab.rb` + +For installation from source: + +- `/home/git/gitlab/config/secrets.yml` +- `/home/git/gitlab/config/gitlab.yml` + +For [Docker installations](https://docs.gitlab.com/omnibus/docker/), you must +back up the volume where the configuration files are stored. If you created +the GitLab container according to the documentation, it should be in the +`/srv/gitlab/config` directory. + +For [GitLab Helm chart installations](https://gitlab.com/gitlab-org/charts/gitlab) +on a Kubernetes cluster, you must follow the +[Back up the secrets](https://docs.gitlab.com/charts/backup-restore/backup.html#backup-the-secrets) +instructions. + +You may also want to back up any TLS keys and certificates (`/etc/gitlab/ssl`, `/etc/gitlab/trusted-certs`), and your +[SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079) +to avoid man-in-the-middle attack warnings if you have to perform a full machine restore. + +If you use Omnibus GitLab, review additional information to +[backup your configuration](https://docs.gitlab.com/omnibus/settings/backups.html). + +In the unlikely event that the secrets file is lost, see the +[troubleshooting section](backup_restore.md#when-the-secrets-file-is-lost). + +## Backup options + +The command line tool GitLab provides to backup your instance can accept more +options. + +### Backup strategy option + +The default backup strategy is to essentially stream data from the respective +data locations to the backup using the Linux command `tar` and `gzip`. This works +fine in most cases, but can cause problems when data is rapidly changing. + +When data changes while `tar` is reading it, the error `file changed as we read +it` may occur, and causes the backup process to fail. To combat this, 8.17 +introduces a new backup strategy called `copy`. The strategy copies data files +to a temporary location before calling `tar` and `gzip`, avoiding the error. + +A side-effect is that the backup process takes up to an additional 1X disk +space. The process does its best to clean up the temporary files at each stage +so the problem doesn't compound, but it could be a considerable change for large +installations. This is why the `copy` strategy is not the default in 8.17. + +To use the `copy` strategy instead of the default streaming strategy, specify +`STRATEGY=copy` in the Rake task command. For example: + +```shell +sudo gitlab-backup create STRATEGY=copy +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +### Backup filename + +WARNING: +If you use a custom backup filename, you can't +[limit the lifetime of the backups](#limit-backup-lifetime-for-local-files-prune-old-backups). + +By default, a backup file is created according to the specification in the +previous [Backup timestamp](backup_restore.md#backup-timestamp) section. You can, however, +override the `[TIMESTAMP]` portion of the filename by setting the `BACKUP` +environment variable. For example: + +```shell +sudo gitlab-backup create BACKUP=dump +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +The resulting file is named `dump_gitlab_backup.tar`. This is useful for +systems that make use of rsync and incremental backups, and results in +considerably faster transfer speeds. + +### Confirm archive can be transferred + +To ensure the generated archive is transferable by rsync, you can set the `GZIP_RSYNCABLE=yes` +option. This sets the `--rsyncable` option to `gzip`, which is useful only in +combination with setting [the Backup filename option](#backup-filename). + +Note that the `--rsyncable` option in `gzip` isn't guaranteed to be available +on all distributions. To verify that it's available in your distribution, run +`gzip --help` or consult the man pages. + +```shell +sudo gitlab-backup create BACKUP=dump GZIP_RSYNCABLE=yes +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +### Excluding specific directories from the backup + +You can exclude specific directories from the backup by adding the environment variable `SKIP`, whose values are a comma-separated list of the following options: + +- `db` (database) +- `uploads` (attachments) +- `builds` (CI job output logs) +- `artifacts` (CI job artifacts) +- `lfs` (LFS objects) +- `terraform_state` (Terraform states) +- `registry` (Container Registry images) +- `pages` (Pages content) +- `repositories` (Git repositories data) +- `packages` (Packages) + +All wikis are backed up as part of the `repositories` group. Non-existent wikis are skipped during a backup. + +NOTE: +When [backing up and restoring Helm Charts](https://docs.gitlab.com/charts/architecture/backup-restore.html), there is an additional option `packages`, which refers to any packages managed by the GitLab [package registry](../user/packages/package_registry/index.md). +For more information see [command line arguments](https://docs.gitlab.com/charts/architecture/backup-restore.html#command-line-arguments). + +All wikis are backed up as part of the `repositories` group. Non-existent +wikis are skipped during a backup. + +For Omnibus GitLab packages: + +```shell +sudo gitlab-backup create SKIP=db,uploads +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +For installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create SKIP=db,uploads RAILS_ENV=production +``` + +### Skipping tar creation + +NOTE: +It is not possible to skip the tar creation when using [object storage](#uploading-backups-to-a-remote-cloud-storage) for backups. + +The last part of creating a backup is generation of a `.tar` file containing +all the parts. In some cases (for example, if the backup is picked up by other +backup software) creating a `.tar` file might be wasted effort or even directly +harmful, so you can skip this step by adding `tar` to the `SKIP` environment +variable. + +Adding `tar` to the `SKIP` variable leaves the files and directories containing the +backup in the directory used for the intermediate files. These files are +overwritten when a new backup is created, so you should make sure they are copied +elsewhere, because you can only have one backup on the system. + +For Omnibus GitLab packages: + +```shell +sudo gitlab-backup create SKIP=tar +``` + +For installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create SKIP=tar RAILS_ENV=production +``` + +### Back up Git repositories concurrently + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37158) in GitLab 13.3. +> - [Concurrent restore introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69330) in GitLab 14.3 + +When using [multiple repository storages](../administration/repository_storage_paths.md), +repositories can be backed up or restored concurrently to help fully use CPU time. The +following variables are available to modify the default behavior of the Rake +task: + +- `GITLAB_BACKUP_MAX_CONCURRENCY`: The maximum number of projects to back up at + the same time. Defaults to the number of logical CPUs (in GitLab 14.1 and + earlier, defaults to `1`). +- `GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY`: The maximum number of projects to + back up at the same time on each storage. This allows the repository backups + to be spread across storages. Defaults to `2` (in GitLab 14.1 and earlier, + defaults to `1`). + +For example, for Omnibus GitLab installations with 4 repository storages: + +```shell +sudo gitlab-backup create GITLAB_BACKUP_MAX_CONCURRENCY=4 GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY=1 +``` + +For example, for installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create GITLAB_BACKUP_MAX_CONCURRENCY=4 GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY=1 +``` + +### Incremental repository backups + +> - Introduced in GitLab 14.9 [with a flag](../administration/feature_flags.md) named `incremental_repository_backup`. Disabled by default. +> - [Enabled on self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/355945) in GitLab 14.10. +> - `PREVIOUS_BACKUP` option [introduced](https://gitlab.com/gitlab-org/gitaly/-/issues/4184) in GitLab 15.0. + +FLAG: +On self-managed GitLab, by default this feature is available. To hide the feature, ask an administrator to [disable the feature flag](../administration/feature_flags.md) named `incremental_repository_backup`. +On GitLab.com, this feature is not available. + +Incremental backups can be faster than full backups because they only pack changes since the last backup into the backup +bundle for each repository. There must be an existing backup to create an incremental backup from: + +- In GitLab 14.9 and 14.10, use the `BACKUP=` option to choose the backup to use. The chosen previous backup is overwritten. +- In GitLab 15.0 and later, use the `PREVIOUS_BACKUP=` option to choose the backup to use. By default, a backup file is created + as documented in the [Backup timestamp](backup_restore.md#backup-timestamp) section. You can override the `[TIMESTAMP]` portion of the filename by setting the + [`BACKUP` environment variable](#backup-filename). + +To create an incremental backup, run: + +```shell +sudo gitlab-backup create INCREMENTAL=yes PREVIOUS_BACKUP= +``` + +Incremental backups can also be created from [an untarred backup](#skipping-tar-creation) by using `SKIP=tar`: + +```shell +sudo gitlab-backup create INCREMENTAL=yes SKIP=tar +``` + +### Back up specific repository storages + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86896) in GitLab 15.0. + +When using [multiple repository storages](../administration/repository_storage_paths.md), +repositories from specific repository storages can be backed up separately +using the `REPOSITORIES_STORAGES` option. The option accepts a comma-separated list of +storage names. + +For example, for Omnibus GitLab installations: + +```shell +sudo gitlab-backup create REPOSITORIES_STORAGES=storage1,storage2 +``` + +For example, for installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create REPOSITORIES_STORAGES=storage1,storage2 +``` + +### Back up specific repositories + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88094) in GitLab 15.1. + +You can back up a specific repositories using the `REPOSITORIES_PATHS` option. +The option accepts a comma-separated list of project and group paths. If you +specify a group path, all repositories in all projects in the group and +descendent groups are included. + +For example, to back up all repositories for all projects in **Group A** (`group-a`), and the repository for **Project C** in **Group B** (`group-b/project-c`): + +- Omnibus GitLab installations: + + ```shell + sudo gitlab-backup create REPOSITORIES_PATHS=group-a,group-b/project-c + ``` + +- Installations from source: + + ```shell + sudo -u git -H bundle exec rake gitlab:backup:create REPOSITORIES_PATHS=group-a,group-b/project-c + ``` + +### Uploading backups to a remote (cloud) storage + +NOTE: +It is not possible to [skip the tar creation](#skipping-tar-creation) when using object storage for backups. + +You can let the backup script upload (using the [Fog library](https://fog.io/)) +the `.tar` file it creates. In the following example, we use Amazon S3 for +storage, but Fog also lets you use [other storage providers](https://fog.io/storage/). +GitLab also [imports cloud drivers](https://gitlab.com/gitlab-org/gitlab/-/blob/da46c9655962df7d49caef0e2b9f6bbe88462a02/Gemfile#L113) +for AWS, Google, OpenStack Swift, Rackspace, and Aliyun. A local driver is +[also available](#uploading-to-locally-mounted-shares). + +[Read more about using object storage with GitLab](../administration/object_storage.md). + +#### Using Amazon S3 + +For Omnibus GitLab packages: + +1. Add the following to `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_upload_connection'] = { + 'provider' => 'AWS', + 'region' => 'eu-west-1', + 'aws_access_key_id' => 'AKIAKIAKI', + 'aws_secret_access_key' => 'secret123' + # If using an IAM Profile, don't configure aws_access_key_id & aws_secret_access_key + # 'use_iam_profile' => true + } + gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect + +#### S3 Encrypted Buckets + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64765) in GitLab 14.3. + +AWS supports these [modes for server side encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html): + +- Amazon S3-Managed Keys (SSE-S3) +- Customer Master Keys (CMKs) Stored in AWS Key Management Service (SSE-KMS) +- Customer-Provided Keys (SSE-C) + +Use your mode of choice with GitLab. Each mode has similar, but slightly +different, configuration methods. + +##### SSE-S3 + +To enable SSE-S3, in the backup storage options set the `server_side_encryption` +field to `AES256`. For example, in Omnibus GitLab: + +```ruby +gitlab_rails['backup_upload_storage_options'] = { + 'server_side_encryption' => 'AES256' +} +``` + +##### SSE-KMS + +To enable SSE-KMS, you'll need the [KMS key via its Amazon Resource Name (ARN) +in the `arn:aws:kms:region:acct-id:key/key-id` format](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html). Under the `backup_upload_storage_options` configuration setting, set: + +- `server_side_encryption` to `aws:kms`. +- `server_side_encryption_kms_key_id` to the ARN of the key. + +For example, in Omnibus GitLab: + +```ruby +gitlab_rails['backup_upload_storage_options'] = { + 'server_side_encryption' => 'aws:kms', + 'server_side_encryption_kms_key_id' => 'arn:aws::' +} +``` + +##### SSE-C + +SSE-C requires you to set these encryption options: + +- `backup_encryption`: AES256. +- `backup_encryption_key`: Unencoded, 32-byte (256 bits) key. The upload fails if this isn't exactly 32 bytes. + +For example, in Omnibus GitLab: + +```ruby +gitlab_rails['backup_encryption'] = 'AES256' +gitlab_rails['backup_encryption_key'] = '' +``` + +If the key contains binary characters and cannot be encoded in UTF-8, +instead, specify the key with the `GITLAB_BACKUP_ENCRYPTION_KEY` environment variable. +For example: + +```ruby +gitlab_rails['env'] = { 'GITLAB_BACKUP_ENCRYPTION_KEY' => "\xDE\xAD\xBE\xEF" * 8 } +``` + +#### Digital Ocean Spaces + +This example can be used for a bucket in Amsterdam (AMS3): + +1. Add the following to `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_upload_connection'] = { + 'provider' => 'AWS', + 'region' => 'ams3', + 'aws_access_key_id' => 'AKIAKIAKI', + 'aws_secret_access_key' => 'secret123', + 'endpoint' => 'https://ams3.digitaloceanspaces.com' + } + gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect + +If you see a `400 Bad Request` error message when using Digital Ocean Spaces, +the cause may be the use of backup encryption. Because Digital Ocean Spaces +doesn't support encryption, remove or comment the line that contains +`gitlab_rails['backup_encryption']`. + +#### Other S3 Providers + +Not all S3 providers are fully compatible with the Fog library. For example, +if you see a `411 Length Required` error message after attempting to upload, +you may need to downgrade the `aws_signature_version` value from the default +value to `2`, [due to this issue](https://github.com/fog/fog-aws/issues/428). + +For installations from source: + +1. Edit `home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + # snip + upload: + # Fog storage connection settings, see https://fog.io/storage/ . + connection: + provider: AWS + region: eu-west-1 + aws_access_key_id: AKIAKIAKI + aws_secret_access_key: 'secret123' + # If using an IAM Profile, leave aws_access_key_id & aws_secret_access_key empty + # ie. aws_access_key_id: '' + # use_iam_profile: 'true' + # The remote 'directory' to store your backups. For S3, this would be the bucket name. + remote_directory: 'my.s3.bucket' + # Specifies Amazon S3 storage class to use for backups, this is optional + # storage_class: 'STANDARD' + # + # Turns on AWS Server-Side Encryption with Amazon Customer-Provided Encryption Keys for backups, this is optional + # 'encryption' must be set in order for this to have any effect. + # 'encryption_key' should be set to the 256-bit encryption key for Amazon S3 to use to encrypt or decrypt. + # To avoid storing the key on disk, the key can also be specified via the `GITLAB_BACKUP_ENCRYPTION_KEY` your data. + # encryption: 'AES256' + # encryption_key: '' + # + # + # Turns on AWS Server-Side Encryption with Amazon S3-Managed keys (optional) + # https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html + # For SSE-S3, set 'server_side_encryption' to 'AES256'. + # For SS3-KMS, set 'server_side_encryption' to 'aws:kms'. Set + # 'server_side_encryption_kms_key_id' to the ARN of customer master key. + # storage_options: + # server_side_encryption: 'aws:kms' + # server_side_encryption_kms_key_id: 'arn:aws:kms:YOUR-KEY-ID-HERE' + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect + +If you're uploading your backups to S3, you should create a new +IAM user with restricted access rights. To give the upload user access only for +uploading backups create the following IAM profile, replacing `my.s3.bucket` +with the name of your bucket: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "Stmt1412062044000", + "Effect": "Allow", + "Action": [ + "s3:AbortMultipartUpload", + "s3:GetBucketAcl", + "s3:GetBucketLocation", + "s3:GetObject", + "s3:GetObjectAcl", + "s3:ListBucketMultipartUploads", + "s3:PutObject", + "s3:PutObjectAcl" + ], + "Resource": [ + "arn:aws:s3:::my.s3.bucket/*" + ] + }, + { + "Sid": "Stmt1412062097000", + "Effect": "Allow", + "Action": [ + "s3:GetBucketLocation", + "s3:ListAllMyBuckets" + ], + "Resource": [ + "*" + ] + }, + { + "Sid": "Stmt1412062128000", + "Effect": "Allow", + "Action": [ + "s3:ListBucket" + ], + "Resource": [ + "arn:aws:s3:::my.s3.bucket" + ] + } + ] +} +``` + +#### Using Google Cloud Storage + +To use Google Cloud Storage to save backups, you must first create an +access key from the Google console: + +1. Go to the [Google storage settings page](https://console.cloud.google.com/storage/settings). +1. Select **Interoperability**, and then create an access key. +1. Make note of the **Access Key** and **Secret** and replace them in the + following configurations. +1. In the buckets advanced settings ensure the Access Control option + **Set object-level and bucket-level permissions** is selected. +1. Ensure you have already created a bucket. + +For Omnibus GitLab packages: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_upload_connection'] = { + 'provider' => 'Google', + 'google_storage_access_key_id' => 'Access Key', + 'google_storage_secret_access_key' => 'Secret', + + ## If you have CNAME buckets (foo.example.com), you might run into SSL issues + ## when uploading backups ("hostname foo.example.com.storage.googleapis.com + ## does not match the server certificate"). In that case, uncomnent the following + ## setting. See: https://github.com/fog/fog/issues/2834 + #'path_style' => true + } + gitlab_rails['backup_upload_remote_directory'] = 'my.google.bucket' + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect + +For installations from source: + +1. Edit `home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + upload: + connection: + provider: 'Google' + google_storage_access_key_id: 'Access Key' + google_storage_secret_access_key: 'Secret' + remote_directory: 'my.google.bucket' + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect + +#### Using Azure Blob storage + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/25877) in GitLab 13.4. + +For Omnibus GitLab packages: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_upload_connection'] = { + 'provider' => 'AzureRM', + 'azure_storage_account_name' => '', + 'azure_storage_access_key' => '', + 'azure_storage_domain' => 'blob.core.windows.net', # Optional + } + gitlab_rails['backup_upload_remote_directory'] = '' + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect + +For installations from source: + +1. Edit `home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + upload: + connection: + provider: 'AzureRM' + azure_storage_account_name: '' + azure_storage_access_key: '' + remote_directory: '' + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect + +For more details, see the [table of Azure parameters](../administration/object_storage.md#azure-blob-storage). + +#### Specifying a custom directory for backups + +This option works only for remote storage. If you want to group your backups, +you can pass a `DIRECTORY` environment variable: + +```shell +sudo gitlab-backup create DIRECTORY=daily +sudo gitlab-backup create DIRECTORY=weekly +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +### Skip uploading backups to remote storage + +If you have configured GitLab to [upload backups in a remote storage](#uploading-backups-to-a-remote-cloud-storage), +you can use the `SKIP=remote` option to skip uploading your backups to the remote storage. + +For Omnibus GitLab packages: + +```shell +sudo gitlab-backup create SKIP=remote +``` + +For installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:create SKIP=remote RAILS_ENV=production +``` + +### Uploading to locally mounted shares + +You may also send backups to a mounted share (for example, `NFS`,`CIFS`, or +`SMB`) by using the Fog [`Local`](https://github.com/fog/fog-local#usage) +storage provider. The directory pointed to by the `local_root` key _must_ be +owned by the `git` user _when mounted_ (mounting with the `uid=` of the `git` +user for `CIFS` and `SMB`) or the user that you are executing the backup tasks +as (for Omnibus packages, this is the `git` user). + +The `backup_upload_remote_directory` _must_ be set in addition to the +`local_root` key. This is the sub directory inside the mounted directory that +backups are copied to, and is created if it does not exist. If the +directory that you want to copy the tarballs to is the root of your mounted +directory, use `.` instead. + +Because file system performance may affect overall GitLab performance, +[GitLab doesn't recommend using cloud-based file systems for storage](../administration/nfs.md#avoid-using-cloud-based-file-systems). + +For Omnibus GitLab packages: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_upload_connection'] = { + :provider => 'Local', + :local_root => '/mnt/backups' + } + + # The directory inside the mounted folder to copy backups to + # Use '.' to store them in the root directory + gitlab_rails['backup_upload_remote_directory'] = 'gitlab_backups' + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +For installations from source: + +1. Edit `home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + upload: + # Fog storage connection settings, see https://fog.io/storage/ . + connection: + provider: Local + local_root: '/mnt/backups' + # The directory inside the mounted folder to copy backups to + # Use '.' to store them in the root directory + remote_directory: 'gitlab_backups' + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect. + +### Backup archive permissions + +The backup archives created by GitLab (`1393513186_2014_02_27_gitlab_backup.tar`) +have the owner/group `git`/`git` and 0600 permissions by default. This is +meant to avoid other system users reading GitLab data. If you need the backup +archives to have different permissions, you can use the `archive_permissions` +setting. + +For Omnibus GitLab packages: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['backup_archive_permissions'] = 0644 # Makes the backup archives world-readable + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +For installations from source: + +1. Edit `/home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + archive_permissions: 0644 # Makes the backup archives world-readable + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect. + +### Configuring cron to make daily backups + +WARNING: +The following cron jobs do not [back up your GitLab configuration files](#storing-configuration-files) +or [SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079). + +You can schedule a cron job that backs up your repositories and GitLab metadata. + +For Omnibus GitLab packages: + +1. Edit the crontab for the `root` user: + + ```shell + sudo su - + crontab -e + ``` + +1. There, add the following line to schedule the backup for everyday at 2 AM: + + ```plaintext + 0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1 + ``` + + Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +For installations from source: + +1. Edit the crontab for the `git` user: + + ```shell + sudo -u git crontab -e + ``` + +1. Add the following lines at the bottom: + + ```plaintext + # Create a full backup of the GitLab repositories and SQL database every day at 2am + 0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production CRON=1 + ``` + +The `CRON=1` environment setting directs the backup script to hide all progress +output if there aren't any errors. This is recommended to reduce cron spam. +When troubleshooting backup problems, however, replace `CRON=1` with `--trace` to log verbosely. + +## Limit backup lifetime for local files (prune old backups) + +WARNING: +The process described in this section don't work if you used a [custom filename](#backup-filename) +for your backups. + +To prevent regular backups from using all your disk space, you may want to set a limited lifetime +for backups. The next time the backup task runs, backups older than the `backup_keep_time` are +pruned. + +This configuration option manages only local files. GitLab doesn't prune old +files stored in a third-party [object storage](#uploading-backups-to-a-remote-cloud-storage) +because the user may not have permission to list and delete files. It's +recommended that you configure the appropriate retention policy for your object +storage (for example, [AWS S3](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-lifecycle.html)). + +For Omnibus GitLab packages: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + ## Limit backup lifetime to 7 days - 604800 seconds + gitlab_rails['backup_keep_time'] = 604800 + ``` + +1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +For installations from source: + +1. Edit `/home/git/gitlab/config/gitlab.yml`: + + ```yaml + backup: + ## Limit backup lifetime to 7 days - 604800 seconds + keep_time: 604800 + ``` + +1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) + for the changes to take effect. diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index 16185310d99..58222196077 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -49,1268 +49,11 @@ the timestamp is `1493107454_2018_04_25_10.6.4-ce`. ## Back up GitLab -GitLab provides a command line interface to back up your entire instance, -including: - -- Database -- Attachments -- Git repositories data -- CI/CD job output logs -- CI/CD job artifacts -- LFS objects -- Terraform states ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/331806) in GitLab 14.7) -- Container Registry images -- GitLab Pages content -- Packages ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332006) in GitLab 14.7) -- Snippets -- [Group wikis](../user/project/wiki/group.md) - -Backups do not include: - -- [Mattermost data](https://docs.mattermost.com/administration/config-settings.html#file-storage) -- Redis (and thus Sidekiq jobs) - -WARNING: -GitLab does not back up any configuration files (`/etc/gitlab`), TLS keys and certificates, or system -files. You are highly advised to read about [storing configuration files](#storing-configuration-files). - -WARNING: -The backup command requires [additional parameters](#back-up-and-restore-for-installations-using-pgbouncer) when -your installation is using PgBouncer, for either performance reasons or when using it with a Patroni cluster. - -Depending on your version of GitLab, use the following command if you installed -GitLab using the Omnibus package: - -- GitLab 12.2 or later: - - ```shell - sudo gitlab-backup create - ``` - -- GitLab 12.1 and earlier: - - ```shell - gitlab-rake gitlab:backup:create - ``` - -If you installed GitLab from source, use the following command: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production -``` - -If you're running GitLab from within a Docker container, run the backup from -the host, based on your installed version of GitLab: - -- GitLab 12.2 or later: - - ```shell - docker exec -t gitlab-backup create - ``` - -- GitLab 12.1 and earlier: - - ```shell - docker exec -t gitlab-rake gitlab:backup:create - ``` - -If you're using the [GitLab Helm chart](https://gitlab.com/gitlab-org/charts/gitlab) -on a Kubernetes cluster, you can run the backup task by using `kubectl` to run the `backup-utility` -script on the GitLab toolbox pod. For more details, see the -[charts backup documentation](https://docs.gitlab.com/charts/backup-restore/backup.html). - -Similar to the Kubernetes case, if you have scaled out your GitLab cluster to -use multiple application servers, you should pick a designated node (that isn't -auto-scaled away) for running the backup Rake task. Because the backup Rake -task is tightly coupled to the main Rails application, this is typically a node -on which you're also running Puma or Sidekiq. - -Example output: - -```plaintext -Dumping database tables: -- Dumping table events... [DONE] -- Dumping table issues... [DONE] -- Dumping table keys... [DONE] -- Dumping table merge_requests... [DONE] -- Dumping table milestones... [DONE] -- Dumping table namespaces... [DONE] -- Dumping table notes... [DONE] -- Dumping table projects... [DONE] -- Dumping table protected_branches... [DONE] -- Dumping table schema_migrations... [DONE] -- Dumping table services... [DONE] -- Dumping table snippets... [DONE] -- Dumping table taggings... [DONE] -- Dumping table tags... [DONE] -- Dumping table users... [DONE] -- Dumping table users_projects... [DONE] -- Dumping table web_hooks... [DONE] -- Dumping table wikis... [DONE] -Dumping repositories: -- Dumping repository abcd... [DONE] -Creating backup archive: $TIMESTAMP_gitlab_backup.tar [DONE] -Deleting tmp directories...[DONE] -Deleting old backups... [SKIPPING] -``` - -### Storing configuration files - -The [backup Rake task](#back-up-gitlab) GitLab provides does _not_ store your -configuration files. The primary reason for this is that your database contains -items including encrypted information for two-factor authentication and the -CI/CD _secure variables_. Storing encrypted information in the same location -as its key defeats the purpose of using encryption in the first place. - -WARNING: -The secrets file is essential to preserve your database encryption key. - -At the very **minimum**, you must back up: - -For Omnibus: - -- `/etc/gitlab/gitlab-secrets.json` -- `/etc/gitlab/gitlab.rb` - -For installation from source: - -- `/home/git/gitlab/config/secrets.yml` -- `/home/git/gitlab/config/gitlab.yml` - -For [Docker installations](https://docs.gitlab.com/omnibus/docker/), you must -back up the volume where the configuration files are stored. If you created -the GitLab container according to the documentation, it should be in the -`/srv/gitlab/config` directory. - -For [GitLab Helm chart installations](https://gitlab.com/gitlab-org/charts/gitlab) -on a Kubernetes cluster, you must follow the -[Back up the secrets](https://docs.gitlab.com/charts/backup-restore/backup.html#backup-the-secrets) -instructions. - -You may also want to back up any TLS keys and certificates (`/etc/gitlab/ssl`, `/etc/gitlab/trusted-certs`), and your -[SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079) -to avoid man-in-the-middle attack warnings if you have to perform a full machine restore. - -If you use Omnibus GitLab, review additional information to -[backup your configuration](https://docs.gitlab.com/omnibus/settings/backups.html). - -In the unlikely event that the secrets file is lost, see the -[troubleshooting section](#when-the-secrets-file-is-lost). - -### Backup options - -The command line tool GitLab provides to backup your instance can accept more -options. - -#### Backup strategy option - -The default backup strategy is to essentially stream data from the respective -data locations to the backup using the Linux command `tar` and `gzip`. This works -fine in most cases, but can cause problems when data is rapidly changing. - -When data changes while `tar` is reading it, the error `file changed as we read -it` may occur, and causes the backup process to fail. To combat this, 8.17 -introduces a new backup strategy called `copy`. The strategy copies data files -to a temporary location before calling `tar` and `gzip`, avoiding the error. - -A side-effect is that the backup process takes up to an additional 1X disk -space. The process does its best to clean up the temporary files at each stage -so the problem doesn't compound, but it could be a considerable change for large -installations. This is why the `copy` strategy is not the default in 8.17. - -To use the `copy` strategy instead of the default streaming strategy, specify -`STRATEGY=copy` in the Rake task command. For example: - -```shell -sudo gitlab-backup create STRATEGY=copy -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -#### Backup filename - -WARNING: -If you use a custom backup filename, you can't -[limit the lifetime of the backups](#limit-backup-lifetime-for-local-files-prune-old-backups). - -By default, a backup file is created according to the specification in the -previous [Backup timestamp](#backup-timestamp) section. You can, however, -override the `[TIMESTAMP]` portion of the filename by setting the `BACKUP` -environment variable. For example: - -```shell -sudo gitlab-backup create BACKUP=dump -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -The resulting file is named `dump_gitlab_backup.tar`. This is useful for -systems that make use of rsync and incremental backups, and results in -considerably faster transfer speeds. - -#### Confirm archive can be transferred - -To ensure the generated archive is transferable by rsync, you can set the `GZIP_RSYNCABLE=yes` -option. This sets the `--rsyncable` option to `gzip`, which is useful only in -combination with setting [the Backup filename option](#backup-filename). - -Note that the `--rsyncable` option in `gzip` isn't guaranteed to be available -on all distributions. To verify that it's available in your distribution, run -`gzip --help` or consult the man pages. - -```shell -sudo gitlab-backup create BACKUP=dump GZIP_RSYNCABLE=yes -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -#### Excluding specific directories from the backup - -You can exclude specific directories from the backup by adding the environment variable `SKIP`, whose values are a comma-separated list of the following options: - -- `db` (database) -- `uploads` (attachments) -- `builds` (CI job output logs) -- `artifacts` (CI job artifacts) -- `lfs` (LFS objects) -- `terraform_state` (Terraform states) -- `registry` (Container Registry images) -- `pages` (Pages content) -- `repositories` (Git repositories data) -- `packages` (Packages) - -All wikis are backed up as part of the `repositories` group. Non-existent wikis are skipped during a backup. - -NOTE: -When [backing up and restoring Helm Charts](https://docs.gitlab.com/charts/architecture/backup-restore.html), there is an additional option `packages`, which refers to any packages managed by the GitLab [package registry](../user/packages/package_registry/index.md). -For more information see [command line arguments](https://docs.gitlab.com/charts/architecture/backup-restore.html#command-line-arguments). - -All wikis are backed up as part of the `repositories` group. Non-existent -wikis are skipped during a backup. - -For Omnibus GitLab packages: - -```shell -sudo gitlab-backup create SKIP=db,uploads -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -For installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create SKIP=db,uploads RAILS_ENV=production -``` - -#### Skipping tar creation - -NOTE: -It is not possible to skip the tar creation when using [object storage](#uploading-backups-to-a-remote-cloud-storage) for backups. - -The last part of creating a backup is generation of a `.tar` file containing -all the parts. In some cases (for example, if the backup is picked up by other -backup software) creating a `.tar` file might be wasted effort or even directly -harmful, so you can skip this step by adding `tar` to the `SKIP` environment -variable. - -Adding `tar` to the `SKIP` variable leaves the files and directories containing the -backup in the directory used for the intermediate files. These files are -overwritten when a new backup is created, so you should make sure they are copied -elsewhere, because you can only have one backup on the system. - -For Omnibus GitLab packages: - -```shell -sudo gitlab-backup create SKIP=tar -``` - -For installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create SKIP=tar RAILS_ENV=production -``` - -#### Disabling prompts during restore - -During a restore from backup, the restore script may ask for confirmation before -proceeding. If you wish to disable these prompts, you can set the `GITLAB_ASSUME_YES` -environment variable to `1`. - -For Omnibus GitLab packages: - -```shell -sudo GITLAB_ASSUME_YES=1 gitlab-backup restore -``` - -For installations from source: - -```shell -sudo -u git -H GITLAB_ASSUME_YES=1 bundle exec rake gitlab:backup:restore RAILS_ENV=production -``` - -#### Back up Git repositories concurrently - -> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37158) in GitLab 13.3. -> - [Concurrent restore introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69330) in GitLab 14.3 - -When using [multiple repository storages](../administration/repository_storage_paths.md), -repositories can be backed up or restored concurrently to help fully use CPU time. The -following variables are available to modify the default behavior of the Rake -task: - -- `GITLAB_BACKUP_MAX_CONCURRENCY`: The maximum number of projects to back up at - the same time. Defaults to the number of logical CPUs (in GitLab 14.1 and - earlier, defaults to `1`). -- `GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY`: The maximum number of projects to - back up at the same time on each storage. This allows the repository backups - to be spread across storages. Defaults to `2` (in GitLab 14.1 and earlier, - defaults to `1`). - -For example, for Omnibus GitLab installations with 4 repository storages: - -```shell -sudo gitlab-backup create GITLAB_BACKUP_MAX_CONCURRENCY=4 GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY=1 -``` - -For example, for installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create GITLAB_BACKUP_MAX_CONCURRENCY=4 GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY=1 -``` - -#### Incremental repository backups - -> - Introduced in GitLab 14.9 [with a flag](../administration/feature_flags.md) named `incremental_repository_backup`. Disabled by default. -> - [Enabled on self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/355945) in GitLab 14.10. -> - `PREVIOUS_BACKUP` option [introduced](https://gitlab.com/gitlab-org/gitaly/-/issues/4184) in GitLab 15.0. - -FLAG: -On self-managed GitLab, by default this feature is available. To hide the feature, ask an administrator to [disable the feature flag](../administration/feature_flags.md) named `incremental_repository_backup`. -On GitLab.com, this feature is not available. - -Incremental backups can be faster than full backups because they only pack changes since the last backup into the backup -bundle for each repository. There must be an existing backup to create an incremental backup from: - -- In GitLab 14.9 and 14.10, use the `BACKUP=` option to choose the backup to use. The chosen previous backup is overwritten. -- In GitLab 15.0 and later, use the `PREVIOUS_BACKUP=` option to choose the backup to use. By default, a backup file is created - as documented in the [Backup timestamp](#backup-timestamp) section. You can override the `[TIMESTAMP]` portion of the filename by setting the - [`BACKUP` environment variable](#backup-filename). - -To create an incremental backup, run: - -```shell -sudo gitlab-backup create INCREMENTAL=yes PREVIOUS_BACKUP= -``` - -Incremental backups can also be created from [an untarred backup](#skipping-tar-creation) by using `SKIP=tar`: - -```shell -sudo gitlab-backup create INCREMENTAL=yes SKIP=tar -``` - -#### Back up specific repository storages - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86896) in GitLab 15.0. - -When using [multiple repository storages](../administration/repository_storage_paths.md), -repositories from specific repository storages can be backed up separately -using the `REPOSITORIES_STORAGES` option. The option accepts a comma-separated list of -storage names. - -For example, for Omnibus GitLab installations: - -```shell -sudo gitlab-backup create REPOSITORIES_STORAGES=storage1,storage2 -``` - -For example, for installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create REPOSITORIES_STORAGES=storage1,storage2 -``` - -#### Back up specific repositories - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88094) in GitLab 15.1. - -You can back up a specific repositories using the `REPOSITORIES_PATHS` option. -The option accepts a comma-separated list of project and group paths. If you -specify a group path, all repositories in all projects in the group and -descendent groups are included. - -For example, to back up all repositories for all projects in **Group A** (`group-a`), and the repository for **Project C** in **Group B** (`group-b/project-c`): - -- Omnibus GitLab installations: - - ```shell - sudo gitlab-backup create REPOSITORIES_PATHS=group-a,group-b/project-c - ``` - -- Installations from source: - - ```shell - sudo -u git -H bundle exec rake gitlab:backup:create REPOSITORIES_PATHS=group-a,group-b/project-c - ``` - -#### Uploading backups to a remote (cloud) storage - -NOTE: -It is not possible to [skip the tar creation](#skipping-tar-creation) when using object storage for backups. - -You can let the backup script upload (using the [Fog library](https://fog.io/)) -the `.tar` file it creates. In the following example, we use Amazon S3 for -storage, but Fog also lets you use [other storage providers](https://fog.io/storage/). -GitLab also [imports cloud drivers](https://gitlab.com/gitlab-org/gitlab/-/blob/da46c9655962df7d49caef0e2b9f6bbe88462a02/Gemfile#L113) -for AWS, Google, OpenStack Swift, Rackspace, and Aliyun. A local driver is -[also available](#uploading-to-locally-mounted-shares). - -[Read more about using object storage with GitLab](../administration/object_storage.md). - -##### Using Amazon S3 - -For Omnibus GitLab packages: - -1. Add the following to `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_upload_connection'] = { - 'provider' => 'AWS', - 'region' => 'eu-west-1', - 'aws_access_key_id' => 'AKIAKIAKI', - 'aws_secret_access_key' => 'secret123' - # If using an IAM Profile, don't configure aws_access_key_id & aws_secret_access_key - # 'use_iam_profile' => true - } - gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect - -##### S3 Encrypted Buckets - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64765) in GitLab 14.3. - -AWS supports these [modes for server side encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html): - -- Amazon S3-Managed Keys (SSE-S3) -- Customer Master Keys (CMKs) Stored in AWS Key Management Service (SSE-KMS) -- Customer-Provided Keys (SSE-C) - -Use your mode of choice with GitLab. Each mode has similar, but slightly -different, configuration methods. - -###### SSE-S3 - -To enable SSE-S3, in the backup storage options set the `server_side_encryption` -field to `AES256`. For example, in Omnibus GitLab: - -```ruby -gitlab_rails['backup_upload_storage_options'] = { - 'server_side_encryption' => 'AES256' -} -``` - -###### SSE-KMS - -To enable SSE-KMS, you'll need the [KMS key via its Amazon Resource Name (ARN) -in the `arn:aws:kms:region:acct-id:key/key-id` format](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html). Under the `backup_upload_storage_options` configuration setting, set: - -- `server_side_encryption` to `aws:kms`. -- `server_side_encryption_kms_key_id` to the ARN of the key. - -For example, in Omnibus GitLab: - -```ruby -gitlab_rails['backup_upload_storage_options'] = { - 'server_side_encryption' => 'aws:kms', - 'server_side_encryption_kms_key_id' => 'arn:aws::' -} -``` - -###### SSE-C - -SSE-C requires you to set these encryption options: - -- `backup_encryption`: AES256. -- `backup_encryption_key`: Unencoded, 32-byte (256 bits) key. The upload fails if this isn't exactly 32 bytes. - -For example, in Omnibus GitLab: - -```ruby -gitlab_rails['backup_encryption'] = 'AES256' -gitlab_rails['backup_encryption_key'] = '' -``` - -If the key contains binary characters and cannot be encoded in UTF-8, -instead, specify the key with the `GITLAB_BACKUP_ENCRYPTION_KEY` environment variable. -For example: - -```ruby -gitlab_rails['env'] = { 'GITLAB_BACKUP_ENCRYPTION_KEY' => "\xDE\xAD\xBE\xEF" * 8 } -``` - -##### Digital Ocean Spaces - -This example can be used for a bucket in Amsterdam (AMS3): - -1. Add the following to `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_upload_connection'] = { - 'provider' => 'AWS', - 'region' => 'ams3', - 'aws_access_key_id' => 'AKIAKIAKI', - 'aws_secret_access_key' => 'secret123', - 'endpoint' => 'https://ams3.digitaloceanspaces.com' - } - gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect - -If you see a `400 Bad Request` error message when using Digital Ocean Spaces, -the cause may be the use of backup encryption. Because Digital Ocean Spaces -doesn't support encryption, remove or comment the line that contains -`gitlab_rails['backup_encryption']`. - -##### Other S3 Providers - -Not all S3 providers are fully compatible with the Fog library. For example, -if you see a `411 Length Required` error message after attempting to upload, -you may need to downgrade the `aws_signature_version` value from the default -value to `2`, [due to this issue](https://github.com/fog/fog-aws/issues/428). - -For installations from source: - -1. Edit `home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - # snip - upload: - # Fog storage connection settings, see https://fog.io/storage/ . - connection: - provider: AWS - region: eu-west-1 - aws_access_key_id: AKIAKIAKI - aws_secret_access_key: 'secret123' - # If using an IAM Profile, leave aws_access_key_id & aws_secret_access_key empty - # ie. aws_access_key_id: '' - # use_iam_profile: 'true' - # The remote 'directory' to store your backups. For S3, this would be the bucket name. - remote_directory: 'my.s3.bucket' - # Specifies Amazon S3 storage class to use for backups, this is optional - # storage_class: 'STANDARD' - # - # Turns on AWS Server-Side Encryption with Amazon Customer-Provided Encryption Keys for backups, this is optional - # 'encryption' must be set in order for this to have any effect. - # 'encryption_key' should be set to the 256-bit encryption key for Amazon S3 to use to encrypt or decrypt. - # To avoid storing the key on disk, the key can also be specified via the `GITLAB_BACKUP_ENCRYPTION_KEY` your data. - # encryption: 'AES256' - # encryption_key: '' - # - # - # Turns on AWS Server-Side Encryption with Amazon S3-Managed keys (optional) - # https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html - # For SSE-S3, set 'server_side_encryption' to 'AES256'. - # For SS3-KMS, set 'server_side_encryption' to 'aws:kms'. Set - # 'server_side_encryption_kms_key_id' to the ARN of customer master key. - # storage_options: - # server_side_encryption: 'aws:kms' - # server_side_encryption_kms_key_id: 'arn:aws:kms:YOUR-KEY-ID-HERE' - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect - -If you're uploading your backups to S3, you should create a new -IAM user with restricted access rights. To give the upload user access only for -uploading backups create the following IAM profile, replacing `my.s3.bucket` -with the name of your bucket: - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "Stmt1412062044000", - "Effect": "Allow", - "Action": [ - "s3:AbortMultipartUpload", - "s3:GetBucketAcl", - "s3:GetBucketLocation", - "s3:GetObject", - "s3:GetObjectAcl", - "s3:ListBucketMultipartUploads", - "s3:PutObject", - "s3:PutObjectAcl" - ], - "Resource": [ - "arn:aws:s3:::my.s3.bucket/*" - ] - }, - { - "Sid": "Stmt1412062097000", - "Effect": "Allow", - "Action": [ - "s3:GetBucketLocation", - "s3:ListAllMyBuckets" - ], - "Resource": [ - "*" - ] - }, - { - "Sid": "Stmt1412062128000", - "Effect": "Allow", - "Action": [ - "s3:ListBucket" - ], - "Resource": [ - "arn:aws:s3:::my.s3.bucket" - ] - } - ] -} -``` - -##### Using Google Cloud Storage - -To use Google Cloud Storage to save backups, you must first create an -access key from the Google console: - -1. Go to the [Google storage settings page](https://console.cloud.google.com/storage/settings). -1. Select **Interoperability**, and then create an access key. -1. Make note of the **Access Key** and **Secret** and replace them in the - following configurations. -1. In the buckets advanced settings ensure the Access Control option - **Set object-level and bucket-level permissions** is selected. -1. Ensure you have already created a bucket. - -For Omnibus GitLab packages: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_upload_connection'] = { - 'provider' => 'Google', - 'google_storage_access_key_id' => 'Access Key', - 'google_storage_secret_access_key' => 'Secret', - - ## If you have CNAME buckets (foo.example.com), you might run into SSL issues - ## when uploading backups ("hostname foo.example.com.storage.googleapis.com - ## does not match the server certificate"). In that case, uncomnent the following - ## setting. See: https://github.com/fog/fog/issues/2834 - #'path_style' => true - } - gitlab_rails['backup_upload_remote_directory'] = 'my.google.bucket' - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect - -For installations from source: - -1. Edit `home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - upload: - connection: - provider: 'Google' - google_storage_access_key_id: 'Access Key' - google_storage_secret_access_key: 'Secret' - remote_directory: 'my.google.bucket' - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect - -##### Using Azure Blob storage - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/25877) in GitLab 13.4. - -For Omnibus GitLab packages: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_upload_connection'] = { - 'provider' => 'AzureRM', - 'azure_storage_account_name' => '', - 'azure_storage_access_key' => '', - 'azure_storage_domain' => 'blob.core.windows.net', # Optional - } - gitlab_rails['backup_upload_remote_directory'] = '' - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect - -For installations from source: - -1. Edit `home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - upload: - connection: - provider: 'AzureRM' - azure_storage_account_name: '' - azure_storage_access_key: '' - remote_directory: '' - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect - -For more details, see the [table of Azure parameters](../administration/object_storage.md#azure-blob-storage). - -##### Specifying a custom directory for backups - -This option works only for remote storage. If you want to group your backups, -you can pass a `DIRECTORY` environment variable: - -```shell -sudo gitlab-backup create DIRECTORY=daily -sudo gitlab-backup create DIRECTORY=weekly -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -#### Skip uploading backups to remote storage - -If you have configured GitLab to [upload backups in a remote storage](#uploading-backups-to-a-remote-cloud-storage), -you can use the `SKIP=remote` option to skip uploading your backups to the remote storage. - -For Omnibus GitLab packages: - -```shell -sudo gitlab-backup create SKIP=remote -``` - -For installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:create SKIP=remote RAILS_ENV=production -``` - -#### Uploading to locally mounted shares - -You may also send backups to a mounted share (for example, `NFS`,`CIFS`, or -`SMB`) by using the Fog [`Local`](https://github.com/fog/fog-local#usage) -storage provider. The directory pointed to by the `local_root` key _must_ be -owned by the `git` user _when mounted_ (mounting with the `uid=` of the `git` -user for `CIFS` and `SMB`) or the user that you are executing the backup tasks -as (for Omnibus packages, this is the `git` user). - -The `backup_upload_remote_directory` _must_ be set in addition to the -`local_root` key. This is the sub directory inside the mounted directory that -backups are copied to, and is created if it does not exist. If the -directory that you want to copy the tarballs to is the root of your mounted -directory, use `.` instead. - -Because file system performance may affect overall GitLab performance, -[GitLab doesn't recommend using cloud-based file systems for storage](../administration/nfs.md#avoid-using-cloud-based-file-systems). - -For Omnibus GitLab packages: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_upload_connection'] = { - :provider => 'Local', - :local_root => '/mnt/backups' - } - - # The directory inside the mounted folder to copy backups to - # Use '.' to store them in the root directory - gitlab_rails['backup_upload_remote_directory'] = 'gitlab_backups' - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect. - -For installations from source: - -1. Edit `home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - upload: - # Fog storage connection settings, see https://fog.io/storage/ . - connection: - provider: Local - local_root: '/mnt/backups' - # The directory inside the mounted folder to copy backups to - # Use '.' to store them in the root directory - remote_directory: 'gitlab_backups' - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect. - -#### Backup archive permissions - -The backup archives created by GitLab (`1393513186_2014_02_27_gitlab_backup.tar`) -have the owner/group `git`/`git` and 0600 permissions by default. This is -meant to avoid other system users reading GitLab data. If you need the backup -archives to have different permissions, you can use the `archive_permissions` -setting. - -For Omnibus GitLab packages: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['backup_archive_permissions'] = 0644 # Makes the backup archives world-readable - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect. - -For installations from source: - -1. Edit `/home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - archive_permissions: 0644 # Makes the backup archives world-readable - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect. - -#### Configuring cron to make daily backups - -WARNING: -The following cron jobs do not [back up your GitLab configuration files](#storing-configuration-files) -or [SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079). - -You can schedule a cron job that backs up your repositories and GitLab metadata. - -For Omnibus GitLab packages: - -1. Edit the crontab for the `root` user: - - ```shell - sudo su - - crontab -e - ``` - -1. There, add the following line to schedule the backup for everyday at 2 AM: - - ```plaintext - 0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1 - ``` - - Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -For installations from source: - -1. Edit the crontab for the `git` user: - - ```shell - sudo -u git crontab -e - ``` - -1. Add the following lines at the bottom: - - ```plaintext - # Create a full backup of the GitLab repositories and SQL database every day at 2am - 0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production CRON=1 - ``` - -The `CRON=1` environment setting directs the backup script to hide all progress -output if there aren't any errors. This is recommended to reduce cron spam. -When troubleshooting backup problems, however, replace `CRON=1` with `--trace` to log verbosely. - -### Limit backup lifetime for local files (prune old backups) - -WARNING: -The process described in this section don't work if you used a [custom filename](#backup-filename) -for your backups. - -To prevent regular backups from using all your disk space, you may want to set a limited lifetime -for backups. The next time the backup task runs, backups older than the `backup_keep_time` are -pruned. - -This configuration option manages only local files. GitLab doesn't prune old -files stored in a third-party [object storage](#uploading-backups-to-a-remote-cloud-storage) -because the user may not have permission to list and delete files. It's -recommended that you configure the appropriate retention policy for your object -storage (for example, [AWS S3](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-lifecycle.html)). - -For Omnibus GitLab packages: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - ## Limit backup lifetime to 7 days - 604800 seconds - gitlab_rails['backup_keep_time'] = 604800 - ``` - -1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) - for the changes to take effect. - -For installations from source: - -1. Edit `/home/git/gitlab/config/gitlab.yml`: - - ```yaml - backup: - ## Limit backup lifetime to 7 days - 604800 seconds - keep_time: 604800 - ``` - -1. [Restart GitLab](../administration/restart_gitlab.md#installations-from-source) - for the changes to take effect. +For detailed information on backing up GitLab, see [Backup GitLab](backup_gitlab.md). ## Restore GitLab -GitLab provides a command line interface to restore your entire installation, -and is flexible enough to fit your needs. - -The [restore prerequisites section](#restore-prerequisites) includes crucial -information. Be sure to read and test the complete restore process at least -once before attempting to perform it in a production environment. - -You can restore a backup only to _the exact same version and type (CE/EE)_ of -GitLab that you created it on (for example CE 9.1.0). - -If your backup is a different version than the current installation, you must -[downgrade your GitLab installation](../update/package/downgrade.md) -before restoring the backup. - -### Restore prerequisites - -You need to have a working GitLab installation before you can perform a -restore. This is because the system user performing the restore actions (`git`) -is usually not allowed to create or delete the SQL database needed to import -data into (`gitlabhq_production`). All existing data is either erased -(SQL) or moved to a separate directory (such as repositories and uploads). - -To restore a backup, you must restore `/etc/gitlab/gitlab-secrets.json` -(for Omnibus packages) or `/home/git/gitlab/.secret` (for installations from -source). This file contains the database encryption key, -[CI/CD variables](../ci/variables/index.md), and -variables used for [two-factor authentication](../user/profile/account/two_factor_authentication.md). -If you fail to restore this encryption key file along with the application data -backup, users with two-factor authentication enabled and GitLab Runner -loses access to your GitLab server. - -You may also want to restore your previous `/etc/gitlab/gitlab.rb` (for Omnibus packages) -or `/home/git/gitlab/config/gitlab.yml` (for installations from source) and -any TLS keys, certificates (`/etc/gitlab/ssl`, `/etc/gitlab/trusted-certs`), or -[SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079). - -Starting with GitLab 12.9, if an untarred backup (like the ones made with -`SKIP=tar`) is found, and no backup is chosen with `BACKUP=`, the -untarred backup is used. - -Depending on your case, you might want to run the restore command with one or -more of the following options: - -- `BACKUP=timestamp_of_backup`: Required if more than one backup exists. - Read what the [backup timestamp is about](#backup-timestamp). -- `force=yes`: Doesn't ask if the `authorized_keys` file should get regenerated, - and assumes 'yes' for warning about database tables being removed, - enabling the `Write to authorized_keys file` setting, and updating LDAP - providers. - -If you're restoring into directories that are mount points, you must ensure these directories are -empty before attempting a restore. Otherwise, GitLab attempts to move these directories before -restoring the new data, which causes an error. - -Read more about [configuring NFS mounts](../administration/nfs.md) - -### Restore for Omnibus GitLab installations - -This procedure assumes that: - -- You have installed the **exact same version and type (CE/EE)** of GitLab - Omnibus with which the backup was created. -- You have run `sudo gitlab-ctl reconfigure` at least once. -- GitLab is running. If not, start it using `sudo gitlab-ctl start`. - -First ensure your backup tar file is in the backup directory described in the -`gitlab.rb` configuration `gitlab_rails['backup_path']`. The default is -`/var/opt/gitlab/backups`. The backup file needs to be owned by the `git` user. - -```shell -sudo cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/ -sudo chown git:git /var/opt/gitlab/backups/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar -``` - -Stop the processes that are connected to the database. Leave the rest of GitLab -running: - -```shell -sudo gitlab-ctl stop puma -sudo gitlab-ctl stop sidekiq -# Verify -sudo gitlab-ctl status -``` - -Next, restore the backup, specifying the timestamp of the backup you wish to -restore: - -```shell -# This command will overwrite the contents of your GitLab database! -sudo gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:restore` instead. -Some [known non-blocking error messages may appear](#restoring-database-backup-using-omnibus-packages-outputs-warnings). - -WARNING: -`gitlab-rake gitlab:backup:restore` doesn't set the correct file system -permissions on your Registry directory. This is a [known issue](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/62759). -In GitLab 12.2 or later, you can use `gitlab-backup restore` to avoid this -issue. - -If there's a GitLab version mismatch between your backup tar file and the -installed version of GitLab, the restore command aborts with an error -message. Install the [correct GitLab version](https://packages.gitlab.com/gitlab/), -and then try again. - -WARNING: -The restore command requires [additional parameters](#back-up-and-restore-for-installations-using-pgbouncer) when -your installation is using PgBouncer, for either performance reasons or when using it with a Patroni cluster. - -Next, restore `/etc/gitlab/gitlab-secrets.json` if necessary, -[as previously mentioned](#restore-prerequisites). - -Reconfigure, restart and [check](../administration/raketasks/maintenance.md#check-gitlab-configuration) GitLab: - -```shell -sudo gitlab-ctl reconfigure -sudo gitlab-ctl restart -sudo gitlab-rake gitlab:check SANITIZE=true -``` - -In GitLab 13.1 and later, check [database values can be decrypted](../administration/raketasks/check.md#verify-database-values-can-be-decrypted-using-the-current-secrets) -especially if `/etc/gitlab/gitlab-secrets.json` was restored, or if a different server is -the target for the restore. - -```shell -sudo gitlab-rake gitlab:doctor:secrets -``` - -For added assurance, you can perform [an integrity check on the uploaded files](../administration/raketasks/check.md#uploaded-files-integrity): - -```shell -sudo gitlab-rake gitlab:artifacts:check -sudo gitlab-rake gitlab:lfs:check -sudo gitlab-rake gitlab:uploads:check -``` - -### Restore for Docker image and GitLab Helm chart installations - -For GitLab installations using the Docker image or the GitLab Helm chart on a -Kubernetes cluster, the restore task expects the restore directories to be -empty. However, with Docker and Kubernetes volume mounts, some system level -directories may be created at the volume roots, such as the `lost+found` -directory found in Linux operating systems. These directories are usually owned -by `root`, which can cause access permission errors since the restore Rake task -runs as the `git` user. To restore a GitLab installation, users have to confirm -the restore target directories are empty. - -For both these installation types, the backup tarball has to be available in -the backup location (default location is `/var/opt/gitlab/backups`). - -For Docker installations, the restore task can be run from host: - -```shell -# Stop the processes that are connected to the database -docker exec -it gitlab-ctl stop puma -docker exec -it gitlab-ctl stop sidekiq - -# Verify that the processes are all down before continuing -docker exec -it gitlab-ctl status - -# Run the restore. NOTE: "_gitlab_backup.tar" is omitted from the name -docker exec -it gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce - -# Restart the GitLab container -docker restart - -# Check GitLab -docker exec -it gitlab-rake gitlab:check SANITIZE=true -``` - -Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. - -WARNING: -`gitlab-rake gitlab:backup:restore` doesn't set the correct file system -permissions on your Registry directory. This is a [known issue](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/62759). -In GitLab 12.2 or later, you can use `gitlab-backup restore` to avoid this -issue. - -The GitLab Helm chart uses a different process, documented in -[restoring a GitLab Helm chart installation](https://gitlab.com/gitlab-org/charts/gitlab/blob/master/doc/backup-restore/restore.md). - -### Restore for installation from source - -First, ensure your backup tar file is in the backup directory described in the -`gitlab.yml` configuration: - -```yaml -## Backup settings -backup: - path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) -``` - -The default is `/home/git/gitlab/tmp/backups`, and it needs to be owned by the `git` user. Now, you can begin the backup procedure: - -```shell -# Stop processes that are connected to the database -sudo service gitlab stop - -sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production -``` - -Example output: - -```plaintext -Unpacking backup... [DONE] -Restoring database tables: --- create_table("events", {:force=>true}) - -> 0.2231s -[...] -- Loading fixture events...[DONE] -- Loading fixture issues...[DONE] -- Loading fixture keys...[SKIPPING] -- Loading fixture merge_requests...[DONE] -- Loading fixture milestones...[DONE] -- Loading fixture namespaces...[DONE] -- Loading fixture notes...[DONE] -- Loading fixture projects...[DONE] -- Loading fixture protected_branches...[SKIPPING] -- Loading fixture schema_migrations...[DONE] -- Loading fixture services...[SKIPPING] -- Loading fixture snippets...[SKIPPING] -- Loading fixture taggings...[SKIPPING] -- Loading fixture tags...[SKIPPING] -- Loading fixture users...[DONE] -- Loading fixture users_projects...[DONE] -- Loading fixture web_hooks...[SKIPPING] -- Loading fixture wikis...[SKIPPING] -Restoring repositories: -- Restoring repository abcd... [DONE] -- Object pool 1 ... -Deleting tmp directories...[DONE] -``` - -Next, restore `/home/git/gitlab/.secret` if necessary, [as previously mentioned](#restore-prerequisites). - -Restart GitLab: - -```shell -sudo service gitlab restart -``` - -### Restoring only one or a few projects or groups from a backup - -Although the Rake task used to restore a GitLab instance doesn't support -restoring a single project or group, you can use a workaround by restoring -your backup to a separate, temporary GitLab instance, and then export your -project or group from there: - -1. [Install a new GitLab](../install/index.md) instance at the same version as - the backed-up instance from which you want to restore. -1. [Restore the backup](#restore-gitlab) into this new instance, then - export your [project](../user/project/settings/import_export.md) - or [group](../user/group/settings/import_export.md). Be sure to read the - **Important Notes** on either export feature's documentation to understand - what is and isn't exported. -1. After the export is complete, go to the old instance and then import it. -1. After importing the projects or groups that you wanted is complete, you may - delete the new, temporary GitLab instance. - -A feature request to provide direct restore of individual projects or groups -is being discussed in [issue #17517](https://gitlab.com/gitlab-org/gitlab/-/issues/17517). - -### Restore options - -The command line tool GitLab provides to restore from backup can accept more -options. - -#### Excluding tasks on restore - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/19347) in GitLab 14.10. - -You can exclude specific tasks on restore by adding the environment variable `SKIP`, whose values are a comma-separated list of the following options: - -- `db` (database) -- `uploads` (attachments) -- `builds` (CI job output logs) -- `artifacts` (CI job artifacts) -- `lfs` (LFS objects) -- `terraform_state` (Terraform states) -- `registry` (Container Registry images) -- `pages` (Pages content) -- `repositories` (Git repositories data) -- `packages` (Packages) - -For Omnibus GitLab packages: - -```shell -sudo gitlab-backup restore BACKUP=timestamp_of_backup SKIP=db,uploads -``` - -For installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup SKIP=db,uploads RAILS_ENV=production -``` - -#### Restore specific repository storages - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86896) in GitLab 15.0. - -When using [multiple repository storages](../administration/repository_storage_paths.md), -repositories from specific repository storages can be restored separately -using the `REPOSITORIES_STORAGES` option. The option accepts a comma-separated list of -storage names. - -For example, for Omnibus GitLab installations: - -```shell -sudo gitlab-backup restore BACKUP=timestamp_of_backup REPOSITORIES_STORAGES=storage1,storage2 -``` - -For example, for installations from source: - -```shell -sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup REPOSITORIES_STORAGES=storage1,storage2 -``` - -#### Restore specific repositories - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88094) in GitLab 15.1. - -You can restore specific repositories using the `REPOSITORIES_PATHS` option. -The option accepts a comma-separated list of project and group paths. If you -specify a group path, all repositories in all projects in the group and -descendent groups are included. The project and group repositories must exist -within the specified backup. - -For example, to restore all repositories for all projects in **Group A** (`group-a`), and the repository for **Project C** in **Group B** (`group-b/project-c`): - -- Omnibus GitLab installations: - - ```shell - sudo gitlab-backup restore BACKUP=timestamp_of_backup REPOSITORIES_PATHS=group-a,group-b/project-c - ``` - -- Installations from source: - - ```shell - sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup REPOSITORIES_PATHS=group-a,group-b/project-c - ``` +For detailed information on restoring GitLab, see [Restore GitLab](restore_gitlab.md). ## Alternative backup strategies @@ -1341,7 +84,7 @@ practical use. ### Back up repository data separately -First, ensure you back up existing GitLab data while [skipping repositories](#excluding-specific-directories-from-the-backup): +First, ensure you back up existing GitLab data while [skipping repositories](backup_gitlab.md#excluding-specific-directories-from-the-backup): ```shell # for Omnibus GitLab package installations @@ -1710,7 +453,7 @@ For more information, see: ### When the secrets file is lost -If you didn't [back up the secrets file](#storing-configuration-files), you +If you didn't [back up the secrets file](backup_gitlab.md#storing-configuration-files), you must complete several steps to get GitLab working properly again. The secrets file is responsible for storing the encryption key for the columns diff --git a/doc/raketasks/restore_gitlab.md b/doc/raketasks/restore_gitlab.md new file mode 100644 index 00000000000..9d9a4d7b8c8 --- /dev/null +++ b/doc/raketasks/restore_gitlab.md @@ -0,0 +1,367 @@ +--- +stage: Systems +group: Geo +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Restore GitLab + +GitLab provides a command line interface to restore your entire installation, +and is flexible enough to fit your needs. + +The [restore prerequisites section](#restore-prerequisites) includes crucial +information. Be sure to read and test the complete restore process at least +once before attempting to perform it in a production environment. + +You can restore a backup only to _the exact same version and type (CE/EE)_ of +GitLab that you created it on (for example CE 9.1.0). + +If your backup is a different version than the current installation, you must +[downgrade your GitLab installation](../update/package/downgrade.md) +before restoring the backup. + +## Restore prerequisites + +You need to have a working GitLab installation before you can perform a +restore. This is because the system user performing the restore actions (`git`) +is usually not allowed to create or delete the SQL database needed to import +data into (`gitlabhq_production`). All existing data is either erased +(SQL) or moved to a separate directory (such as repositories and uploads). + +To restore a backup, you must restore `/etc/gitlab/gitlab-secrets.json` +(for Omnibus packages) or `/home/git/gitlab/.secret` (for installations from +source). This file contains the database encryption key, +[CI/CD variables](../ci/variables/index.md), and +variables used for [two-factor authentication](../user/profile/account/two_factor_authentication.md). +If you fail to restore this encryption key file along with the application data +backup, users with two-factor authentication enabled and GitLab Runner +loses access to your GitLab server. + +You may also want to restore your previous `/etc/gitlab/gitlab.rb` (for Omnibus packages) +or `/home/git/gitlab/config/gitlab.yml` (for installations from source) and +any TLS keys, certificates (`/etc/gitlab/ssl`, `/etc/gitlab/trusted-certs`), or +[SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079). + +Starting with GitLab 12.9, if an untarred backup (like the ones made with +`SKIP=tar`) is found, and no backup is chosen with `BACKUP=`, the +untarred backup is used. + +Depending on your case, you might want to run the restore command with one or +more of the following options: + +- `BACKUP=timestamp_of_backup`: Required if more than one backup exists. + Read what the [backup timestamp is about](backup_restore.md#backup-timestamp). +- `force=yes`: Doesn't ask if the `authorized_keys` file should get regenerated, + and assumes 'yes' for warning about database tables being removed, + enabling the `Write to authorized_keys file` setting, and updating LDAP + providers. + +If you're restoring into directories that are mount points, you must ensure these directories are +empty before attempting a restore. Otherwise, GitLab attempts to move these directories before +restoring the new data, which causes an error. + +Read more about [configuring NFS mounts](../administration/nfs.md) + +## Restore for Omnibus GitLab installations + +This procedure assumes that: + +- You have installed the **exact same version and type (CE/EE)** of GitLab + Omnibus with which the backup was created. +- You have run `sudo gitlab-ctl reconfigure` at least once. +- GitLab is running. If not, start it using `sudo gitlab-ctl start`. + +First ensure your backup tar file is in the backup directory described in the +`gitlab.rb` configuration `gitlab_rails['backup_path']`. The default is +`/var/opt/gitlab/backups`. The backup file needs to be owned by the `git` user. + +```shell +sudo cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/ +sudo chown git:git /var/opt/gitlab/backups/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar +``` + +Stop the processes that are connected to the database. Leave the rest of GitLab +running: + +```shell +sudo gitlab-ctl stop puma +sudo gitlab-ctl stop sidekiq +# Verify +sudo gitlab-ctl status +``` + +Next, restore the backup, specifying the timestamp of the backup you wish to +restore: + +```shell +# This command will overwrite the contents of your GitLab database! +sudo gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:restore` instead. +Some [known non-blocking error messages may appear](backup_restore.md#restoring-database-backup-using-omnibus-packages-outputs-warnings). + +WARNING: +`gitlab-rake gitlab:backup:restore` doesn't set the correct file system +permissions on your Registry directory. This is a [known issue](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/62759). +In GitLab 12.2 or later, you can use `gitlab-backup restore` to avoid this +issue. + +If there's a GitLab version mismatch between your backup tar file and the +installed version of GitLab, the restore command aborts with an error +message. Install the [correct GitLab version](https://packages.gitlab.com/gitlab/), +and then try again. + +WARNING: +The restore command requires [additional parameters](backup_restore.md#back-up-and-restore-for-installations-using-pgbouncer) when +your installation is using PgBouncer, for either performance reasons or when using it with a Patroni cluster. + +Next, restore `/etc/gitlab/gitlab-secrets.json` if necessary, +[as previously mentioned](#restore-prerequisites). + +Reconfigure, restart and [check](../administration/raketasks/maintenance.md#check-gitlab-configuration) GitLab: + +```shell +sudo gitlab-ctl reconfigure +sudo gitlab-ctl restart +sudo gitlab-rake gitlab:check SANITIZE=true +``` + +In GitLab 13.1 and later, check [database values can be decrypted](../administration/raketasks/check.md#verify-database-values-can-be-decrypted-using-the-current-secrets) +especially if `/etc/gitlab/gitlab-secrets.json` was restored, or if a different server is +the target for the restore. + +```shell +sudo gitlab-rake gitlab:doctor:secrets +``` + +For added assurance, you can perform [an integrity check on the uploaded files](../administration/raketasks/check.md#uploaded-files-integrity): + +```shell +sudo gitlab-rake gitlab:artifacts:check +sudo gitlab-rake gitlab:lfs:check +sudo gitlab-rake gitlab:uploads:check +``` + +## Restore for Docker image and GitLab Helm chart installations + +For GitLab installations using the Docker image or the GitLab Helm chart on a +Kubernetes cluster, the restore task expects the restore directories to be +empty. However, with Docker and Kubernetes volume mounts, some system level +directories may be created at the volume roots, such as the `lost+found` +directory found in Linux operating systems. These directories are usually owned +by `root`, which can cause access permission errors since the restore Rake task +runs as the `git` user. To restore a GitLab installation, users have to confirm +the restore target directories are empty. + +For both these installation types, the backup tarball has to be available in +the backup location (default location is `/var/opt/gitlab/backups`). + +For Docker installations, the restore task can be run from host: + +```shell +# Stop the processes that are connected to the database +docker exec -it gitlab-ctl stop puma +docker exec -it gitlab-ctl stop sidekiq + +# Verify that the processes are all down before continuing +docker exec -it gitlab-ctl status + +# Run the restore. NOTE: "_gitlab_backup.tar" is omitted from the name +docker exec -it gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce + +# Restart the GitLab container +docker restart + +# Check GitLab +docker exec -it gitlab-rake gitlab:check SANITIZE=true +``` + +Users of GitLab 12.1 and earlier should use the command `gitlab-rake gitlab:backup:create` instead. + +WARNING: +`gitlab-rake gitlab:backup:restore` doesn't set the correct file system +permissions on your Registry directory. This is a [known issue](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/62759). +In GitLab 12.2 or later, you can use `gitlab-backup restore` to avoid this +issue. + +The GitLab Helm chart uses a different process, documented in +[restoring a GitLab Helm chart installation](https://gitlab.com/gitlab-org/charts/gitlab/blob/master/doc/backup-restore/restore.md). + +## Restore for installation from source + +First, ensure your backup tar file is in the backup directory described in the +`gitlab.yml` configuration: + +```yaml +## Backup settings +backup: + path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) +``` + +The default is `/home/git/gitlab/tmp/backups`, and it needs to be owned by the `git` user. Now, you can begin the backup procedure: + +```shell +# Stop processes that are connected to the database +sudo service gitlab stop + +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` + +Example output: + +```plaintext +Unpacking backup... [DONE] +Restoring database tables: +-- create_table("events", {:force=>true}) + -> 0.2231s +[...] +- Loading fixture events...[DONE] +- Loading fixture issues...[DONE] +- Loading fixture keys...[SKIPPING] +- Loading fixture merge_requests...[DONE] +- Loading fixture milestones...[DONE] +- Loading fixture namespaces...[DONE] +- Loading fixture notes...[DONE] +- Loading fixture projects...[DONE] +- Loading fixture protected_branches...[SKIPPING] +- Loading fixture schema_migrations...[DONE] +- Loading fixture services...[SKIPPING] +- Loading fixture snippets...[SKIPPING] +- Loading fixture taggings...[SKIPPING] +- Loading fixture tags...[SKIPPING] +- Loading fixture users...[DONE] +- Loading fixture users_projects...[DONE] +- Loading fixture web_hooks...[SKIPPING] +- Loading fixture wikis...[SKIPPING] +Restoring repositories: +- Restoring repository abcd... [DONE] +- Object pool 1 ... +Deleting tmp directories...[DONE] +``` + +Next, restore `/home/git/gitlab/.secret` if necessary, [as previously mentioned](#restore-prerequisites). + +Restart GitLab: + +```shell +sudo service gitlab restart +``` + +## Restoring only one or a few projects or groups from a backup + +Although the Rake task used to restore a GitLab instance doesn't support +restoring a single project or group, you can use a workaround by restoring +your backup to a separate, temporary GitLab instance, and then export your +project or group from there: + +1. [Install a new GitLab](../install/index.md) instance at the same version as + the backed-up instance from which you want to restore. +1. [Restore the backup](#restore-gitlab) into this new instance, then + export your [project](../user/project/settings/import_export.md) + or [group](../user/group/settings/import_export.md). Be sure to read the + **Important Notes** on either export feature's documentation to understand + what is and isn't exported. +1. After the export is complete, go to the old instance and then import it. +1. After importing the projects or groups that you wanted is complete, you may + delete the new, temporary GitLab instance. + +A feature request to provide direct restore of individual projects or groups +is being discussed in [issue #17517](https://gitlab.com/gitlab-org/gitlab/-/issues/17517). + +## Restore options + +The command line tool GitLab provides to restore from backup can accept more +options. + +### Disabling prompts during restore + +During a restore from backup, the restore script may ask for confirmation before +proceeding. If you wish to disable these prompts, you can set the `GITLAB_ASSUME_YES` +environment variable to `1`. + +For Omnibus GitLab packages: + +```shell +sudo GITLAB_ASSUME_YES=1 gitlab-backup restore +``` + +For installations from source: + +```shell +sudo -u git -H GITLAB_ASSUME_YES=1 bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` + +### Excluding tasks on restore + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/19347) in GitLab 14.10. + +You can exclude specific tasks on restore by adding the environment variable `SKIP`, whose values are a comma-separated list of the following options: + +- `db` (database) +- `uploads` (attachments) +- `builds` (CI job output logs) +- `artifacts` (CI job artifacts) +- `lfs` (LFS objects) +- `terraform_state` (Terraform states) +- `registry` (Container Registry images) +- `pages` (Pages content) +- `repositories` (Git repositories data) +- `packages` (Packages) + +For Omnibus GitLab packages: + +```shell +sudo gitlab-backup restore BACKUP=timestamp_of_backup SKIP=db,uploads +``` + +For installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup SKIP=db,uploads RAILS_ENV=production +``` + +### Restore specific repository storages + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86896) in GitLab 15.0. + +When using [multiple repository storages](../administration/repository_storage_paths.md), +repositories from specific repository storages can be restored separately +using the `REPOSITORIES_STORAGES` option. The option accepts a comma-separated list of +storage names. + +For example, for Omnibus GitLab installations: + +```shell +sudo gitlab-backup restore BACKUP=timestamp_of_backup REPOSITORIES_STORAGES=storage1,storage2 +``` + +For example, for installations from source: + +```shell +sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup REPOSITORIES_STORAGES=storage1,storage2 +``` + +### Restore specific repositories + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88094) in GitLab 15.1. + +You can restore specific repositories using the `REPOSITORIES_PATHS` option. +The option accepts a comma-separated list of project and group paths. If you +specify a group path, all repositories in all projects in the group and +descendent groups are included. The project and group repositories must exist +within the specified backup. + +For example, to restore all repositories for all projects in **Group A** (`group-a`), and the repository for **Project C** in **Group B** (`group-b/project-c`): + +- Omnibus GitLab installations: + + ```shell + sudo gitlab-backup restore BACKUP=timestamp_of_backup REPOSITORIES_PATHS=group-a,group-b/project-c + ``` + +- Installations from source: + + ```shell + sudo -u git -H bundle exec rake gitlab:backup:restore BACKUP=timestamp_of_backup REPOSITORIES_PATHS=group-a,group-b/project-c + ``` diff --git a/doc/update/package/downgrade.md b/doc/update/package/downgrade.md index 7b8b4da0383..f48ba31568f 100644 --- a/doc/update/package/downgrade.md +++ b/doc/update/package/downgrade.md @@ -79,5 +79,5 @@ Steps: sudo gitlab-ctl reconfigure ``` -1. [Restore GitLab](../../raketasks/backup_restore.md#restore-for-omnibus-gitlab-installations) +1. [Restore GitLab](../../raketasks/restore_gitlab.md#restore-for-omnibus-gitlab-installations) to complete the downgrade. diff --git a/doc/update/plan_your_upgrade.md b/doc/update/plan_your_upgrade.md index cdc3ec39f9a..2374856ff0c 100644 --- a/doc/update/plan_your_upgrade.md +++ b/doc/update/plan_your_upgrade.md @@ -87,7 +87,7 @@ to roll back GitLab to a working state if there's a problem with the upgrade: - Create a [GitLab backup](../raketasks/backup_restore.md). Make sure to follow the instructions based on your installation method. - Don't forget to back up the [secrets and configuration files](../raketasks/backup_restore.md#storing-configuration-files). + Don't forget to back up the [secrets and configuration files](../raketasks/backup_gitlab.md#storing-configuration-files). - Alternatively, create a snapshot of your instance. If this is a multi-node installation, you must snapshot every node. **This process is out of scope for GitLab Support.** @@ -103,7 +103,7 @@ To restore your GitLab backup: the versions of the backed up and the new GitLab instance must be the same. - [Restore GitLab](../raketasks/backup_restore.md#restore-gitlab). Make sure to follow the instructions based on your installation method. - Confirm that the [secrets and configuration files](../raketasks/backup_restore.md#storing-configuration-files) are also restored. + Confirm that the [secrets and configuration files](../raketasks/backup_gitlab.md#storing-configuration-files) are also restored. - If restoring from a snapshot, know the steps to do this. **This process is out of scope for GitLab Support.** diff --git a/doc/user/admin_area/settings/incident_management_rate_limits.md b/doc/user/admin_area/settings/incident_management_rate_limits.md index 6226ec23be7..ed2d707af0a 100644 --- a/doc/user/admin_area/settings/incident_management_rate_limits.md +++ b/doc/user/admin_area/settings/incident_management_rate_limits.md @@ -12,9 +12,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w You can limit the number of inbound alerts for [incidents](../../../operations/incident_management/incidents.md) that can be created in a period of time. The inbound [incident management](../../../operations/incident_management/index.md) alert limit can help prevent overloading your incident responders by reducing the -number of alerts or duplicate issues. +number of alerts or duplicate issues. -As an example, if you set a limit of `10` requests every `60` seconds, +As an example, if you set a limit of `10` requests every `60` seconds, and `11` requests are sent to an [alert integration endpoint](../../../operations/incident_management/integrations.md) within one minute, the eleventh request is blocked. Access to the endpoint is allowed again after one minute. diff --git a/doc/user/analytics/index.md b/doc/user/analytics/index.md index 61e652496e5..b8c0e9af745 100644 --- a/doc/user/analytics/index.md +++ b/doc/user/analytics/index.md @@ -76,6 +76,8 @@ Deployment frequency displays in several charts: - [Project-level value stream analytics](value_stream_analytics.md) - [CI/CD analytics](ci_cd_analytics.md) +To retrieve metrics for deployment frequency, use the [GraphQL](../../api/graphql/reference/index.md) or the [REST](../../api/dora/metrics.md) APIs. + ### Lead time for changes Lead time for changes measures the time to deliver a feature once it has been developed, @@ -87,6 +89,8 @@ Lead time for changes displays in several charts: - [Project-level value stream analytics](value_stream_analytics.md) - [CI/CD analytics](ci_cd_analytics.md) +To retrieve metrics for lead time for changes, use the [GraphQL](../../api/graphql/reference/index.md) or the [REST](../../api/dora/metrics.md) APIs. + ### Time to restore service Time to restore service measures how long it takes an organization to recover from a failure in production. @@ -126,7 +130,7 @@ To retrieve metrics for change failure rate, use the [GraphQL](../../api/graphql | `deployment_frequency` | Group | [GitLab 13.10 and later](../../api/dora/metrics.md) | GitLab 13.12 and later | | | `lead_time_for_changes` | Project | [GitLab 13.10 and later](../../api/dora/metrics.md) | GitLab 13.11 and later | Unit in seconds. Aggregation method is median. | | `lead_time_for_changes` | Group | [GitLab 13.10 and later](../../api/dora/metrics.md) | GitLab 14.0 and later | Unit in seconds. Aggregation method is median. | -| `time_to_restore_service` | Project and group | [GitLab 14.9 and later](../../api/dora/metrics.md) | Not supported | | +| `time_to_restore_service` | Project and group | [GitLab 14.9 and later](../../api/dora/metrics.md) | GitLab 15.1 and later | Unit in days. Aggregation method is median. | | `change_failure_rate` | Project and group | [GitLab 14.10 and later](../../api/dora/metrics.md) | Not supported | | ## Definitions diff --git a/doc/user/application_security/index.md b/doc/user/application_security/index.md index b5f9ba2ca3b..90893a01462 100644 --- a/doc/user/application_security/index.md +++ b/doc/user/application_security/index.md @@ -421,7 +421,7 @@ You can always find supported and deprecated schema versions in the [source code This feature was [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/354928) in GitLab 14.9 and [removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/85400) in GitLab 15.0. - + ## Interact with findings and vulnerabilities diff --git a/doc/user/group/value_stream_analytics/index.md b/doc/user/group/value_stream_analytics/index.md index e2a49df616a..960552cc10f 100644 --- a/doc/user/group/value_stream_analytics/index.md +++ b/doc/user/group/value_stream_analytics/index.md @@ -66,7 +66,7 @@ The table shows a list of related workflow items for the selected stage. Based o > - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/323982) in GitLab 13.12. The **Overview** dashboard in value stream analytics shows key metrics and DORA metrics of group performance. Based on the filter you select, -the dashboard automatically aggregates DORA metrics and displays the current status of the value stream. +the dashboard automatically aggregates DORA metrics and displays the current status of the value stream. Select a DORA metric to view its chart. To view deployment metrics, you must have a [production environment configured](../../../ci/environments/index.md#deployment-tier-of-environments). diff --git a/doc/user/project/merge_requests/img/attention_request_list_v14_10.png b/doc/user/project/merge_requests/img/attention_request_list_v14_10.png deleted file mode 100644 index 00427a0aa40dc9ef5df019f01c4914ba56b427d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11932 zcmb8VbyOVD^Ct>P@IcT&aCZqhIKkbWL6YD$*x*iZcemh9(7_4r?l6P9yUXUgd*0di z_U)eY+xq98uFtKmy4}_H)3;8AsVGUKqY|RR!NH-+%1Efe!My{)!NCV3zyGJX342lh zr)W@7(2#t4ds|sq`4l8m{sXSFv-AA?{P6Jb@$u2j%+n3iT%ep9kfB&qk ztnu-2isiI|f&v{KogdX9Ek10rva%cJ`~3X;zkdBPG&Bqk54YH&UA#Yzi;JsY>dzXh z#}1ZVxa*&}J1i|N?eFhjUth1Ps`?V9l$n`1ecOQ>qJX^^KXAPh5)!g|b^P>tpOTUi zA0K~kaA0g~Jb8BjyFa6g(|dS%Vo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qqGD7I0d4 z?$fD3P$y!GAlG5&!`TUru!ng1u|Qb1`+i_BKML0s;x}{R6XP`aT>CREDI$9&2Iat! zOp=Jb+Yi9`XtU_vRLMGrX$>L|_LTBQKm*K(43j=&uOB-8HX`UP*O+JnMDhT^AH>b< z;r9Y-YDTa8cIRg0r{;Kb?woP9@;p{-ZeUVefa60(#(9u^fCLy!VfVK7zpQTpg3hc&i@YE_B>U` z>-9d7mzC-8@kM*$LpPr9G15`mBc3M{+l$Jd*oC+9SCyq&$*;0jZ5dB9TZW5{X12 zkw_#Gi9{liNF)-8L?V$$Boc{4B9TZW5{X12kw_$x2cHd+{~b~v$%CPfL?V$$Bo7LI Y1K*{4W5wY^EC2ui07*qoM6N<$g5 [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/343528) in GitLab 14.10 [with a flag](../../../administration/feature_flags.md) named `mr_attention_requests`. Disabled by default. - -FLAG: -On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../../administration/feature_flags.md) named `mr_attention_requests`. -On GitLab.com, this feature is dependent on the enablement status of the feature flag. Refer to the [enablement issue](https://gitlab.com/gitlab-org/gitlab/-/issues/343528) for details. - -To tell a merge request's assignee or reviewer that their attention is -needed on a merge request, you can request their attention. If an assignee or a -reviewer has their attention requested on a merge request, the **Attention request** -icon (**{attention}**) is displayed as a solid icon (**{attention-solid}**) on -the merge request list page: - -![Attention request icon](img/attention_request_list_v14_10.png) - -To view a list of merge requests that need your attention: - -1. On the top bar, select **Merge requests** (**{merge-request}**). -1. Select **Attention requests**. - -To request attention from another user, use the `/attention @user` -[quick action](../quick_actions.md) or: - -1. Go to the merge request. -1. On the right sidebar, identify the user you want to request attention from. -1. Next to the user's name, select **Request attention** (**{attention}**), and the appearance - of the icon changes: - - ![Attention request toggle](img/attention_request_sidebar_v14_10.png) - -### Remove an attention request - -If your attention was requested as an assignee or reviewer, it's removed when you: - -- Manually remove the attention request by selecting **Remove attention request** (**{attention-solid}**). -- Approve the merge request. -- Add a new user as an assignee or reviewer. -- Request the attention of a different assignee or reviewer. -- Remove yourself (or are removed by someone else) as an assignee or reviewer. -- Merge or close the merge request. - -If you are both the assignee and a reviewer on a merge request, you receive -only one attention request, which is synced across both duties. If the -attention request is removed from you, either as an assignee or a reviewer, -it is removed from both your duties. - ## Merge request workflows For a software developer working in a team: diff --git a/doc/user/project/merge_requests/reviews/index.md b/doc/user/project/merge_requests/reviews/index.md index 8f77ce90436..c382a844fc0 100644 --- a/doc/user/project/merge_requests/reviews/index.md +++ b/doc/user/project/merge_requests/reviews/index.md @@ -113,12 +113,6 @@ This example shows reviewers and approval rules in a merge request sidebar: ### Request a new review > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/293933) in GitLab 13.9. -> - [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/357271) in GitLab 14.10. - -WARNING: -This feature is in its end-of-life process. It is [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/357271) -in GitLab 14.10, and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/357271) in GitLab 15.0. -Use [attention requests](../index.md#request-attention-to-a-merge-request) instead. After a reviewer completes their [merge request reviews](../../../discussions/index.md), the author of the merge request can request a new review from the reviewer: diff --git a/doc/user/project/quick_actions.md b/doc/user/project/quick_actions.md index d5a7058d3d2..96e51b061ee 100644 --- a/doc/user/project/quick_actions.md +++ b/doc/user/project/quick_actions.md @@ -55,7 +55,6 @@ threads. Some quick actions might not be available to all subscription tiers. | `/assign me` | **{check-circle}** Yes | **{check-circle}** Yes | **{dotted-circle}** No | Assign yourself. | | `/assign_reviewer @user1 @user2` or `/reviewer @user1 @user2` or `/request_review @user1 @user2` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Assign one or more users as reviewers. | | `/assign_reviewer me` or `/reviewer me` or `/request_review me` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Assign yourself as a reviewer. | -| `/attention @user1` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | [Request attention](merge_requests/index.md#request-attention-to-a-merge-request) to a merge request from a user. | | `/award :emoji:` | **{check-circle}** Yes | **{check-circle}** Yes | **{check-circle}** Yes | Toggle emoji award. | | `/child_epic ` | **{dotted-circle}** No | **{dotted-circle}** No | **{check-circle}** Yes | Add child epic to ``. The `` value should be in the format of `&epic`, `group&epic`, or a URL to an epic ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/7330) in GitLab 12.0). | | `/clear_health_status` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Clear [health status](issues/managing_issues.md#health-status) ([introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/213814) in GitLab 14.7). | diff --git a/lefthook.yml b/lefthook.yml index 161ce0b5155..8a3a0d8c2cb 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -59,6 +59,11 @@ pre-push: files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD glob: 'doc/*.md' run: scripts/lint-docs-metadata.sh {files} + docs-trailing_spaces: # Not enforced in CI/CD pipelines, but reduces the amount of required cleanup: https://gitlab.com/gitlab-org/technical-writing/-/blob/main/.gitlab/issue_templates/tw-monthly-tasks.md#remote-tasks + tags: documentation style + files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD + glob: 'doc/*.md' + run: yarn markdownlint:no-trailing-spaces {files} docs-deprecations: tags: documentation files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD @@ -67,5 +72,5 @@ pre-push: docs-removals: tags: documentation files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD - glob: 'data/removals/**/*.yml' + glob: 'data/removals/*.yml' run: echo "Changes to removals files detected. Checking removals..\n"; bundle exec rake gitlab:docs:check_removals diff --git a/lib/api/commits.rb b/lib/api/commits.rb index dedda82091f..5fd9a8e3278 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -139,7 +139,7 @@ module API if find_user_from_warden Gitlab::UsageDataCounters::WebIdeCounter.increment_commits_count - Gitlab::UsageDataCounters::EditorUniqueCounter.track_web_ide_edit_action(author: current_user) + Gitlab::UsageDataCounters::EditorUniqueCounter.track_web_ide_edit_action(author: current_user, project: user_project) end present commit_detail, with: Entities::CommitDetail, stats: params[:stats] diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index fd54375bf51..0c52ce8aba4 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -37,6 +37,7 @@ module Gitlab users_get_by_id: { threshold: -> { application_settings.users_get_by_id_limit }, interval: 10.minutes }, username_exists: { threshold: 20, interval: 1.minute }, user_sign_up: { threshold: 20, interval: 1.minute }, + user_sign_in: { threshold: 5, interval: 10.minutes }, profile_resend_email_confirmation: { threshold: 5, interval: 1.minute }, profile_update_username: { threshold: 10, interval: 1.minute }, update_environment_canary_ingress: { threshold: 1, interval: 1.minute }, @@ -46,7 +47,9 @@ module Gitlab gitlab_shell_operation: { threshold: 600, interval: 1.minute }, pipelines_create: { threshold: -> { application_settings.pipeline_limit_per_project_user_sha }, interval: 1.minute }, temporary_email_failure: { threshold: 50, interval: 1.day }, - project_testing_integration: { threshold: 5, interval: 1.minute } + project_testing_integration: { threshold: 5, interval: 1.minute }, + email_verification: { threshold: 10, interval: 10.minutes }, + email_verification_code_send: { threshold: 10, interval: 1.hour } }.freeze end diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 15ebd506055..59acfa80258 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -16,6 +16,14 @@ module Gitlab end def execute + Gitlab::Ci::YamlProcessor::FeatureFlags.with_actor(project) do + parse_config + end + end + + private + + def parse_config if @config_content.blank? return Result.new(errors: ['Please provide content of .gitlab-ci.yml']) end @@ -35,7 +43,9 @@ module Gitlab Result.new(ci_config: @ci_config, errors: [e.message], warnings: @ci_config&.warnings) end - private + def project + @opts[:project] + end def run_logical_validations! @stages = @ci_config.stages diff --git a/lib/gitlab/ci/yaml_processor/feature_flags.rb b/lib/gitlab/ci/yaml_processor/feature_flags.rb new file mode 100644 index 00000000000..f03db9d0e6b --- /dev/null +++ b/lib/gitlab/ci/yaml_processor/feature_flags.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Gitlab + module Ci + class YamlProcessor + module FeatureFlags + ACTOR_KEY = 'ci_yaml_processor_feature_flag_actor' + NO_ACTOR_VALUE = :no_actor + + NoActorError = Class.new(StandardError) + NO_ACTOR_MESSAGE = "Actor not set. Ensure to call `enabled?` inside `with_actor` block" + + class << self + # Cache a feature flag actor as thread local variable so + # we can have it available later with #enabled? + def with_actor(actor) + previous = Thread.current[ACTOR_KEY] + + # When actor is `nil` the method `Thread.current[]=` does not + # create the ACTOR_KEY. Instead, we want to still save an explicit + # value to know that we are within the `with_actor` block. + Thread.current[ACTOR_KEY] = actor || NO_ACTOR_VALUE + + yield + ensure + Thread.current[ACTOR_KEY] = previous + end + + # Use this to check if a feature flag is enabled + def enabled?(feature_flag) + ::Feature.enabled?(feature_flag, current_actor) + end + + private + + def current_actor + value = Thread.current[ACTOR_KEY] || (raise NoActorError, NO_ACTOR_MESSAGE) + return if value == NO_ACTOR_VALUE + + value + rescue NoActorError => e + Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e) + + nil + end + end + end + end + end +end diff --git a/lib/gitlab/usage_data_counters/editor_unique_counter.rb b/lib/gitlab/usage_data_counters/editor_unique_counter.rb index 8feb24e49ac..5ede840661a 100644 --- a/lib/gitlab/usage_data_counters/editor_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/editor_unique_counter.rb @@ -10,24 +10,24 @@ module Gitlab EDIT_BY_LIVE_PREVIEW = 'g_edit_by_live_preview' class << self - def track_web_ide_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_WEB_IDE, author, time) + def track_web_ide_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_WEB_IDE, author, time, project) end def count_web_ide_edit_actions(date_from:, date_to:) count_unique(EDIT_BY_WEB_IDE, date_from, date_to) end - def track_sfe_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_SFE, author, time) + def track_sfe_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_SFE, author, time, project) end def count_sfe_edit_actions(date_from:, date_to:) count_unique(EDIT_BY_SFE, date_from, date_to) end - def track_snippet_editor_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_SNIPPET_EDITOR, author, time) + def track_snippet_editor_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_SNIPPET_EDITOR, author, time, project) end def count_snippet_editor_edit_actions(date_from:, date_to:) @@ -39,15 +39,25 @@ module Gitlab count_unique(events, date_from, date_to) end - def track_live_preview_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_LIVE_PREVIEW, author, time) + def track_live_preview_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_LIVE_PREVIEW, author, time, project) end private - def track_unique_action(action, author, time) + def track_unique_action(action, author, time, project = nil) return unless author + if Feature.enabled?(:route_hll_to_snowplow_phase2) + Gitlab::Tracking.event( + 'ide_edit', + action.to_s, + project: project, + namespace: project&.namespace, + user: author + ) + end + Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id, time: time) end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 0f2969593c2..3a9923bae68 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -19347,15 +19347,66 @@ msgstr "" msgid "IdentityVerification|Before you create your group, we need you to verify your identity with a valid payment method. You will not be charged during this step. If we ever need to charge you, we will let you know." msgstr "" +msgid "IdentityVerification|Before you sign in, we need to verify your identity. Enter the following code on the sign-in page." +msgstr "" + msgid "IdentityVerification|Create a project" msgstr "" +msgid "IdentityVerification|For added security, you'll need to verify your identity. We've sent a verification code to %{email}" +msgstr "" + +msgid "IdentityVerification|Help us protect your account" +msgstr "" + +msgid "IdentityVerification|If you have not recently tried to sign into GitLab, we recommend %{password_link_start}changing your password%{link_end} and %{two_fa_link_start}setting up Two-Factor Authentication%{link_end} to keep your account safe. Your verification code expires after %{expires_in_minutes} minutes." +msgstr "" + +msgid "IdentityVerification|If you have not recently tried to sign into GitLab, we recommend changing your password (%{password_link}) and setting up Two-Factor Authentication (%{two_fa_link}) to keep your account safe." +msgstr "" + +msgid "IdentityVerification|If you've lost access to the email associated to this account or having trouble with the code, %{link_start}here are some other steps you can take.%{link_end}" +msgstr "" + +msgid "IdentityVerification|Maximum login attempts exceeded. Wait %{interval} and try again." +msgstr "" + +msgid "IdentityVerification|Please enter a valid code" +msgstr "" + +msgid "IdentityVerification|Resend code" +msgstr "" + +msgid "IdentityVerification|The code has expired. Resend a new code and try again." +msgstr "" + +msgid "IdentityVerification|The code is incorrect. Enter it again, or resend a new code." +msgstr "" + +msgid "IdentityVerification|Verification code" +msgstr "" + +msgid "IdentityVerification|Verification successful" +msgstr "" + +msgid "IdentityVerification|Verify code" +msgstr "" + msgid "IdentityVerification|Verify your identity" msgstr "" msgid "IdentityVerification|You can always verify your account at a later time to create a group." msgstr "" +msgid "IdentityVerification|You've reached the maximum amount of tries. Wait %{interval} or resend a new code and try again." +msgstr "" + +msgid "IdentityVerification|Your account has been successfully verified. You'll be redirected to your account in just a moment or %{redirect_url_start}click here%{redirect_url_end} to refresh." +msgstr "" + +msgid "IdentityVerification|Your verification code expires after %{expires_in_minutes} minutes." +msgstr "" + msgid "If any indexed field exceeds this limit, it is truncated to this number of characters. The rest of the content is neither indexed nor searchable. This does not apply to repository and wiki indexing. For unlimited characters, set this to 0." msgstr "" @@ -23448,9 +23499,6 @@ msgstr "" msgid "Logs" msgstr "" -msgid "Logs|To see the logs, deploy your code to an environment." -msgstr "" - msgid "Looks like you've reached your %{free_limit} member limit for %{strong_start}%{namespace_name}%{strong_end}" msgstr "" diff --git a/package.json b/package.json index 4e2e894d2a2..d35dd8157af 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "file-coverage": "scripts/frontend/file_test_coverage.js", "lint-docs": "scripts/lint-doc.sh", "internal:eslint": "eslint --cache --max-warnings 0 --report-unused-disable-directives --ext .js,.vue,.graphql", - "internal:stylelint": "stylelint -q '{ee/,}app/assets/stylesheets/**/*.{css,scss}'", + "internal:stylelint": "stylelint -q --rd '{ee/,}app/assets/stylesheets/**/*.{css,scss}'", "prejest": "yarn check-dependencies", "jest": "jest --config jest.config.js", "jest-debug": "node --inspect-brk node_modules/.bin/jest --runInBand", @@ -41,7 +41,6 @@ "storybook:install": "yarn --cwd ./storybook install", "storybook:build": "yarn --cwd ./storybook build", "storybook:start": "./scripts/frontend/start_storybook.sh", - "stylelint-create-utility-map": "node scripts/frontend/stylelint/stylelint_utility_map.js", "webpack": "NODE_OPTIONS=\"--max-old-space-size=3584\" webpack --config config/webpack.config.js", "webpack-vendor": "NODE_OPTIONS=\"--max-old-space-size=3584\" webpack --config config/webpack.vendor.config.js", "webpack-prod": "NODE_OPTIONS=\"--max-old-space-size=3584\" NODE_ENV=production webpack --config config/webpack.config.js" diff --git a/qa/qa/page/mattermost/login.rb b/qa/qa/page/mattermost/login.rb index 38a88b42992..ab711746459 100644 --- a/qa/qa/page/mattermost/login.rb +++ b/qa/qa/page/mattermost/login.rb @@ -12,7 +12,7 @@ module QA view 'app/views/projects/mattermosts/new.html.haml' def sign_in_using_oauth - click_link class: 'btn btn-custom-login gitlab' + click_link 'gitlab' if page.has_content?('Authorize GitLab Mattermost to use your account?') click_button 'Authorize' diff --git a/scripts/frontend/stylelint/stylelint_duplicate_selectors.js b/scripts/frontend/stylelint/stylelint_duplicate_selectors.js deleted file mode 100644 index 77c1f1292b7..00000000000 --- a/scripts/frontend/stylelint/stylelint_duplicate_selectors.js +++ /dev/null @@ -1,25 +0,0 @@ -const stylelint = require('stylelint'); -const utils = require('./stylelint_utils'); - -const ruleName = 'stylelint-gitlab/duplicate-selectors'; - -const messages = stylelint.utils.ruleMessages(ruleName, { - expected: (selector1, selector2) => { - return `"${selector1}" and "${selector2}" have the same properties.`; - }, -}); - -module.exports = stylelint.createPlugin(ruleName, (enabled) => { - if (!enabled) { - return; - } - - // eslint-disable-next-line consistent-return - return (root, result) => { - const selectorGroups = {}; - utils.createPropertiesHashmap(root, result, ruleName, messages, selectorGroups, true); - }; -}); - -module.exports.ruleName = ruleName; -module.exports.messages = messages; diff --git a/scripts/frontend/stylelint/stylelint_utility_classes.js b/scripts/frontend/stylelint/stylelint_utility_classes.js deleted file mode 100644 index ad2b2ddbb20..00000000000 --- a/scripts/frontend/stylelint/stylelint_utility_classes.js +++ /dev/null @@ -1,25 +0,0 @@ -const stylelint = require('stylelint'); -const utils = require('./stylelint_utils'); -const utilityClasses = require('./utility_classes_map'); - -const ruleName = 'stylelint-gitlab/utility-classes'; - -const messages = stylelint.utils.ruleMessages(ruleName, { - expected: (selector1, selector2) => { - return `"${selector1}" has the same properties as our BS4 utility class "${selector2}" so please use that instead.`; - }, -}); - -module.exports = stylelint.createPlugin(ruleName, (enabled) => { - if (!enabled) { - return; - } - - // eslint-disable-next-line consistent-return - return (root, result) => { - utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false); - }; -}); - -module.exports.ruleName = ruleName; -module.exports.messages = messages; diff --git a/scripts/frontend/stylelint/stylelint_utility_map.js b/scripts/frontend/stylelint/stylelint_utility_map.js deleted file mode 100644 index 187b2065823..00000000000 --- a/scripts/frontend/stylelint/stylelint_utility_map.js +++ /dev/null @@ -1,64 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const postcss = require('postcss'); -const prettier = require('prettier'); -const sass = require('sass'); - -const utils = require('./stylelint_utils'); - -const ROOT_PATH = path.resolve(__dirname, '../../..'); -const hashMapPath = path.resolve(__dirname, './utility_classes_map.js'); - -// -// This creates a JS based hash map (saved in utility_classes_map.js) of the different values in the utility classes -// -sass.render( - { - data: ` - @import './functions'; - @import './variables'; - @import './mixins'; - @import './utilities'; - `, - includePaths: [path.resolve(ROOT_PATH, 'node_modules/bootstrap/scss')], - }, - (err, result) => { - if (err) { - return console.error('Error ', err); - } - - const cssResult = result.css.toString(); - - // We just use postcss to create a CSS tree - return postcss([]) - .process(cssResult, { - // This suppresses a postcss warning - from: undefined, - }) - .then((processedResult) => { - const selectorGroups = {}; - utils.createPropertiesHashmap( - processedResult.root, - processedResult, - null, - null, - selectorGroups, - true, - ); - - const prettierOptions = prettier.resolveConfig.sync(hashMapPath); - const prettyHashmap = prettier.format( - `module.exports = ${JSON.stringify(selectorGroups)};`, - prettierOptions, - ); - - fs.writeFile(hashMapPath, prettyHashmap, (e) => { - if (e) { - return console.log(e); - } - - return console.log('The file was saved!'); - }); - }); - }, -); diff --git a/scripts/frontend/stylelint/stylelint_utils.js b/scripts/frontend/stylelint/stylelint_utils.js deleted file mode 100644 index c9d9c7d9aad..00000000000 --- a/scripts/frontend/stylelint/stylelint_utils.js +++ /dev/null @@ -1,78 +0,0 @@ -const md5 = require('md5'); -const stylelint = require('stylelint'); - -module.exports.createPropertiesHashmap = ( - ruleRoot, - result, - ruleName, - messages, - selectorGroups, - addSelectors, -) => { - ruleRoot.walkRules((rule) => { - const selector = rule.selector.replace(/(?:\r\n|\r|\n)/g, ' '); - - if ( - rule && - rule.parent && - rule.parent.type !== 'atrule' && - !( - selector.includes('-webkit-') || - selector.includes('-moz-') || - selector.includes('-o-') || - selector.includes('-ms-') || - selector.includes(':') - ) - ) { - let cssArray = []; - rule.nodes.forEach((property) => { - const { prop, value } = property; - if (property && value) { - const propval = `${prop}${value}${property.important ? '!important' : ''}`; - cssArray.push(propval); - } - }); - - cssArray = cssArray.sort(); - const cssContent = cssArray.toString(); - - if (cssContent) { - const hashValue = md5(cssContent); - const selObj = selectorGroups[hashValue]; - - const selectorLine = `${selector} (${ - rule.source.input.file ? `${rule.source.input.file} -` : '' - }${rule.source.start.line}:${rule.source.start.column})`; - - if (selObj) { - if (selectorGroups[hashValue].selectors.indexOf(selector) === -1) { - let lastSelector = - selectorGroups[hashValue].selectors[selectorGroups[hashValue].selectors.length - 1]; - - // So we have nicer formatting if it is the same file, we remove the filename - lastSelector = lastSelector.replace(`${rule.source.input.file} - `, ''); - - if (messages) { - stylelint.utils.report({ - result, - ruleName, - message: messages.expected(selector, lastSelector), - node: rule, - word: rule.node, - }); - } - - if (addSelectors) { - selectorGroups[hashValue].selectors.push(selectorLine); - } - } - } else if (addSelectors) { - // eslint-disable-next-line no-param-reassign - selectorGroups[hashValue] = { - selectors: [selectorLine], - }; - } - } - } - }); -}; diff --git a/scripts/frontend/stylelint/utility_classes_map.js b/scripts/frontend/stylelint/utility_classes_map.js deleted file mode 100644 index a174812ff93..00000000000 --- a/scripts/frontend/stylelint/utility_classes_map.js +++ /dev/null @@ -1,259 +0,0 @@ -module.exports = { - '99097f29a9473b56eacdb9ff0681c366': { selectors: ['.align-baseline (1:1)'] }, - d969b318bb994e104e8c965006d71cb7: { selectors: ['.align-top (5:1)'] }, - '8cd54ab97b9cc43cb9d13d2ea7c601c7': { selectors: ['.align-middle (9:1)'] }, - dd06eb6c49e979b7a9fdaa7119aa0a0b: { selectors: ['.align-bottom (13:1)'] }, - '0af1e90cbc468615e299ec9f49e97c4a': { selectors: ['.align-text-bottom (17:1)'] }, - '50af706df238cf59bdc634fc684ba0c9': { selectors: ['.align-text-top (21:1)'] }, - c968922e6e47445362129a684b5913c0: { selectors: ['.bg-primary (25:1)'] }, - '3c397f9786c24cff4779a11cf5b3d7e7': { selectors: ['.bg-secondary (35:1)'] }, - '659677469a4477267fabc1788f7cad4e': { selectors: ['.bg-success (45:1)'] }, - '56d246d5b6a708a4c6f78dbd2444106c': { selectors: ['.bg-info (55:1)'] }, - '6bec0a33df3a6380c30103db5c273455': { selectors: ['.bg-warning (65:1)'] }, - '0ce5d074c8667ce6c32360658f428d5d': { selectors: ['.bg-danger (75:1)'] }, - '0d0269c62a01e97caa9039d227a25d12': { selectors: ['.bg-light (85:1)'] }, - '3a56309ad8c5b46ebcc3b13fe1987ac1': { selectors: ['.bg-dark (95:1)'] }, - '0e252f8dd392a33343d3d5efc1e3194a': { selectors: ['.bg-white (105:1)'] }, - '3af6f52f0ed4f98e797d5f10a35ca6bc': { selectors: ['.bg-transparent (109:1)'] }, - '16da7fdce74577ceab356509db565612': { selectors: ['.border (113:1)'] }, - '929622517ca05efde3b51e5f1a57064e': { selectors: ['.border-top (117:1)'] }, - '7283090353df54f1d515a6ceddfb9693': { selectors: ['.border-right (121:1)'] }, - bd5670d71332c652b46db82949042e31: { selectors: ['.border-bottom (125:1)'] }, - fa71e003d04734a898a85cc5285e3cbb: { selectors: ['.border-left (129:1)'] }, - ed482cea071e316f29d78fd93c3f3644: { selectors: ['.border-0 (133:1)'] }, - '90cb661baf21e10be6e479cb0544b1a7': { selectors: ['.border-top-0 (137:1)'] }, - '8a32707eaa09fc998bf8cc915710b60c': { selectors: ['.border-right-0 (141:1)'] }, - a6f01957e142a000e7742b31ac6c2331: { selectors: ['.border-bottom-0 (145:1)'] }, - c740fe952cc1985ee14f7d1c7a359a29: { selectors: ['.border-left-0 (149:1)'] }, - af9dd93e9780306ffa4bb25a6384902f: { selectors: ['.border-primary (153:1)'] }, - afa290dfe58cca06be5924ceae1b019b: { selectors: ['.border-secondary (157:1)'] }, - '9b1ac460bdddf1e0164d7bf988cc2da8': { selectors: ['.border-success (161:1)'] }, - '091cbf41d6be12061382fa571ee1ce82': { selectors: ['.border-info (165:1)'] }, - '3ada321d4a387901dad6d80e1b6be3fd': { selectors: ['.border-warning (169:1)'] }, - '13b4713dd52c1e359d1b43dd658cb249': { selectors: ['.border-danger (173:1)'] }, - '0048e110875ea22b04104d55e764a367': { selectors: ['.border-light (177:1)'] }, - a900b6b567c9a911326cdd0e19f40f8e: { selectors: ['.border-dark (181:1)'] }, - '78bcd867ac9677c743c2bc33b872f27b': { selectors: ['.border-white (185:1)'] }, - '35ef133b860874a5879e9451c491bc1c': { selectors: ['.rounded-sm (189:1)'] }, - e0fc10c49c7b7f4d1924336d21a4f64e: { selectors: ['.rounded (193:1)'] }, - '1b74b9d0a7d6a59281b5b5cae43c859a': { selectors: ['.rounded-top (197:1)'] }, - '20b75f55f39e662e038d51a6442c03df': { selectors: ['.rounded-right (202:1)'] }, - '83ea6db794873239c21f44af25618677': { selectors: ['.rounded-bottom (207:1)'] }, - '8464e9e8001e65dfc06397436a5eebd7': { selectors: ['.rounded-left (212:1)'] }, - a1148f40e8c509b2bcc829e2181c7582: { selectors: ['.rounded-lg (217:1)'] }, - '59c2f788287fa43caf5891adfc5c796e': { selectors: ['.rounded-circle (221:1)'] }, - '7f35b0a4b74ee7174b13cb841df0bdb3': { selectors: ['.rounded-pill (225:1)'] }, - '31a632ba94f8c41558bd6044458f1459': { selectors: ['.rounded-0 (229:1)'] }, - '16aaf53ab29d6b248b0257f2fa413914': { selectors: ['.d-none (239:1)'] }, - '4f42736ac9217039ed791b4306e60aeb': { selectors: ['.d-inline (243:1)'] }, - '067efa04b76649e8afcdceb9f5f7e870': { selectors: ['.d-inline-block (247:1)'] }, - de54f49149fb9b512aa79ad9ada838f2: { selectors: ['.d-block (251:1)'] }, - '80fc32acbc0c28ee890a160c23529d26': { selectors: ['.d-table (255:1)'] }, - '6a87b1db48298ca94cbe5dee79a6eed1': { selectors: ['.d-table-row (259:1)'] }, - b9896f0d94760bf5920f47904e9f7512: { selectors: ['.d-table-cell (263:1)'] }, - d25c51f38c4d057209b96c664de68c44: { selectors: ['.d-flex (267:1)'] }, - e72d46b636d5b8e17e771daa95793f33: { selectors: ['.d-inline-flex (271:1)'] }, - '2c433b7c14a5ae32cfa8ec7867ee8526': { selectors: ['.embed-responsive (460:1)'] }, - '56b318b8d8eb845b769d60cefcd131bb': { - selectors: [ - '.embed-responsive .embed-responsive-item, .embed-responsive iframe, .embed-responsive embed, .embed-responsive object, .embed-responsive video (471:1)', - ], - }, - c5009af89633c4d2f71a0a9fa333630d: { selectors: ['.flex-row (501:1)'] }, - '7b06a3d956579cd64b6f5b1a57255369': { selectors: ['.flex-column (505:1)'] }, - '21744a8c4dc6ed1519903b4236b00af4': { selectors: ['.flex-row-reverse (509:1)'] }, - '18d903735f9c71070b6d8166aa1112f1': { selectors: ['.flex-column-reverse (513:1)'] }, - e2a57aa8196347d4da84f33a4f551325: { selectors: ['.flex-wrap (517:1)'] }, - b6b29f75b174b5609f9e7d5eef457b70: { selectors: ['.flex-nowrap (521:1)'] }, - '839230fc7c0abacb6418b49d8f10b27f': { selectors: ['.flex-wrap-reverse (525:1)'] }, - '924d9b261944a8e8ff684d5b519062bb': { selectors: ['.flex-fill (529:1)'] }, - '5ed396aeb08464b7df8fc37d29455319': { selectors: ['.flex-grow-0 (533:1)'] }, - '94251dc4d012339a3e37df6196fc79bb': { selectors: ['.flex-grow-1 (537:1)'] }, - '0eeed7dabca0452a46574776a4485e6e': { selectors: ['.flex-shrink-0 (541:1)'] }, - c69e60d5e51a1b74d22b172ab98ef9d5: { selectors: ['.flex-shrink-1 (545:1)'] }, - '03401c1a81eb6d4639f020f76dd60176': { selectors: ['.justify-content-start (549:1)'] }, - '39e3d2c344e78869c98ef099249e717d': { selectors: ['.justify-content-end (553:1)'] }, - '3b2d00c0bea857ab78a71b0872842980': { selectors: ['.justify-content-center (557:1)'] }, - b1c3c9edd20ed7c08b43863d38ebee40: { selectors: ['.justify-content-between (561:1)'] }, - a11b4b1d983c5fa75777f273e998f73e: { selectors: ['.justify-content-around (565:1)'] }, - '50e33f29f65bfffa6a3591fcb6045ca9': { selectors: ['.align-items-start (569:1)'] }, - e44b276e47415ec19b74cc16740ada1d: { selectors: ['.align-items-end (573:1)'] }, - '4a9d2716bca651758564059dceed1271': { selectors: ['.align-items-center (577:1)'] }, - fd970b017f7f558f30cb273bf71ede7d: { selectors: ['.align-items-baseline (581:1)'] }, - '7204b6b00b69f8af1e4a24c9b6e7f7f9': { selectors: ['.align-items-stretch (585:1)'] }, - '350fbb74eb70bd05f9438067c3990e9f': { selectors: ['.align-content-start (589:1)'] }, - '74d61397b4fcbf608f3dba39ab3b2a1b': { selectors: ['.align-content-end (593:1)'] }, - eed1ab4ee9e5b327a434512176741548: { selectors: ['.align-content-center (597:1)'] }, - '19878ab832978ef7e1746ac2fe4084b2': { selectors: ['.align-content-between (601:1)'] }, - dded333d0522692809517039f5a727c1: { selectors: ['.align-content-around (605:1)'] }, - '5cbb83ea2af7e9db8ef13f4c7d6db875': { selectors: ['.align-content-stretch (609:1)'] }, - dc3df46d3c023184d375a63a71916646: { selectors: ['.align-self-auto (613:1)'] }, - '0c6d2d8c9732c571f9cf61a4b1d2877f': { selectors: ['.align-self-start (617:1)'] }, - fe7c6071e3e17214df1bdd38850d9ff0: { selectors: ['.align-self-end (621:1)'] }, - '9611bbad74d72d50cf238088576a5089': { selectors: ['.align-self-center (625:1)'] }, - '4bc5edddf5981866946175bfedb7247f': { selectors: ['.align-self-baseline (629:1)'] }, - '4fffdd27ec60120ec9ed16fd7feef801': { selectors: ['.align-self-stretch (633:1)'] }, - '39e658501f5502b35919f02fa9591360': { selectors: ['.float-left (1185:1)'] }, - b51436c537ffc4269b1533e44d7c3467: { selectors: ['.float-right (1189:1)'] }, - c4597a87d2c793a6d696cfe06f6c95ce: { selectors: ['.float-none (1193:1)'] }, - '16b2e7e5b666b69b9581be6a44947d6f': { selectors: ['.user-select-all (1249:1)'] }, - f5c4d8f25b8338031e719edc77659558: { selectors: ['.user-select-auto (1253:1)'] }, - '71ba65d43dcc2b1c3f47ac2578983e83': { selectors: ['.user-select-none (1257:1)'] }, - '5902adc842d83ad70b89ece99b82a7a9': { selectors: ['.overflow-auto (1261:1)'] }, - bfb19f18b91fa46f0502e32153287cc4: { selectors: ['.overflow-hidden (1265:1)'] }, - aaf8dc6e0768e59f3098a98a5c144d66: { selectors: ['.position-static (1269:1)'] }, - '79592de2383045d15ab57d35aa1dab95': { selectors: ['.position-relative (1273:1)'] }, - a7c272f53d0368730bde4c2740ffb5c3: { selectors: ['.position-absolute (1277:1)'] }, - dad0bb92d53f17cf8affc10f77824b7f: { selectors: ['.position-fixed (1281:1)'] }, - '6da0f6a7354a75fe6c95b08a4cabc06f': { selectors: ['.position-sticky (1285:1)'] }, - '66602e21eea7b673883155c8f42b9590': { selectors: ['.fixed-top (1289:1)'] }, - '33ea70eb6db7f6ab3469680f182abb19': { selectors: ['.fixed-bottom (1297:1)'] }, - '947009e63b4547795ef7cc873f4e4ae9': { selectors: ['.sr-only (1313:1)'] }, - '9220ad156a70c2586b15fe2b9b6108b2': { selectors: ['.shadow-sm (1334:1)'] }, - b1b8c0ff70767ca2160811a026766982: { selectors: ['.shadow (1338:1)'] }, - da0792abe99964acb6692a03c61d6dd8: { selectors: ['.shadow-lg (1342:1)'] }, - bb2173057af1cf20e687469b2d9cbb3c: { selectors: ['.shadow-none (1346:1)'] }, - '6d8abb6519a186483b25429ab8b9765e': { selectors: ['.w-25 (1350:1)'] }, - a087c1ffdf8ead76cdd37445b414d63e: { selectors: ['.w-50 (1354:1)'] }, - '28180742013a90275be5633e6ec0dd51': { selectors: ['.w-75 (1358:1)'] }, - '195a03bc95a0af0ba6c8824db97a0b2f': { selectors: ['.w-100 (1362:1)'] }, - e67c74b650d6236b03be9dfc10c78e32: { selectors: ['.w-auto (1366:1)'] }, - c1b6262b3ee069addc1fbe46f64aac4e: { selectors: ['.h-25 (1370:1)'] }, - a520396ae349bef86145e0761aa0699e: { selectors: ['.h-50 (1374:1)'] }, - '7c53b57d54beb087fd7ab8b669c5fe60': { selectors: ['.h-75 (1378:1)'] }, - ad74f1972cb745b7a78b03e16a387f21: { selectors: ['.h-100 (1382:1)'] }, - '2cd49c3d63d260ba4f0b23c559ad05e0': { selectors: ['.h-auto (1386:1)'] }, - '0b43071a67efc45ee1735fdc2491313c': { selectors: ['.mw-100 (1390:1)'] }, - eac31a6f08e5c935e24b97df0fdad579: { selectors: ['.mh-100 (1394:1)'] }, - bd5f5d687d100d127abeb044fc78a3fd: { selectors: ['.min-vw-100 (1398:1)'] }, - '8dec7662784b943d3ca0615df59d7970': { selectors: ['.min-vh-100 (1402:1)'] }, - eacc17f16197f6c0291ced3e7cfc067e: { selectors: ['.vw-100 (1406:1)'] }, - '1a2ec1c9ad7db8d4156ca76a81416c49': { selectors: ['.vh-100 (1410:1)'] }, - cfdb4f497b16074959bfd3deb7ea9c42: { selectors: ['.m-0 (1414:1)'] }, - '4d666c270ba50524312d97c4b937d153': { selectors: ['.mt-0, .my-0 (1418:1)'] }, - eccf47ccd76ceffb4b139cb6c080b5ac: { selectors: ['.mr-0, .mx-0 (1423:1)'] }, - '9bc513e73c0bdc6efdf170cb31de16d1': { selectors: ['.mb-0, .my-0 (1428:1)'] }, - e99cfc55b03f0e67f11628b19889ad7b: { selectors: ['.ml-0, .mx-0 (1433:1)'] }, - e1c39484d90d2acaa00973531f47f738: { selectors: ['.m-1 (1438:1)'] }, - '63791bc02eccfdfa2c01621a801e565f': { selectors: ['.mt-1, .my-1 (1442:1)'] }, - bcb27ab9d7dcfdd0d7cacad02709966c: { selectors: ['.mr-1, .mx-1 (1447:1)'] }, - cb5d1c4328e25b5bc93be9a252973690: { selectors: ['.mb-1, .my-1 (1452:1)'] }, - b80b1010c7dcfbb30bed9015c4f2e969: { selectors: ['.ml-1, .mx-1 (1457:1)'] }, - ecab1c9cdf8a562e3c0f70307aeafa89: { selectors: ['.m-2 (1462:1)'] }, - '6505fe17fbbd88b1884113a754aa82ab': { selectors: ['.mt-2, .my-2 (1466:1)'] }, - '6f0c7d09d1e729f332c4671ccc2b48c0': { selectors: ['.mr-2, .mx-2 (1471:1)'] }, - '70ef7b668b382b3c747b2d73e08cdbed': { selectors: ['.mb-2, .my-2 (1476:1)'] }, - '2d7f277cc78ed324a8fc1f71ab281e1f': { selectors: ['.ml-2, .mx-2 (1481:1)'] }, - '8ebcfe52fd4024861082ffb1735747a7': { selectors: ['.m-3 (1486:1)'] }, - '9965fb516bdb72b87023a533123a8035': { selectors: ['.mt-3, .my-3 (1490:1)'] }, - b1fcbbb1dc6226f6da6000830088e051: { selectors: ['.mr-3, .mx-3 (1495:1)'] }, - '02204826cfbe3da98535c0d802870940': { selectors: ['.mb-3, .my-3 (1500:1)'] }, - '0259859060250ae6b730218733e7a437': { selectors: ['.ml-3, .mx-3 (1505:1)'] }, - '8cf300dab2a4994a105eeddda826f2e6': { selectors: ['.m-4 (1510:1)'] }, - '1ba62fdddd3349f52a452050688905c7': { selectors: ['.mt-4, .my-4 (1514:1)'] }, - '66a104129fa13db5a0829567fba6ee41': { selectors: ['.mr-4, .mx-4 (1519:1)'] }, - eefcc4c10b79e70e8e8a5a66fb2b7aa1: { selectors: ['.mb-4, .my-4 (1524:1)'] }, - eb1503656dc920d15a31116956fdffa4: { selectors: ['.ml-4, .mx-4 (1529:1)'] }, - '79cbb6e5c9b73fd0be29d4fc5733a099': { selectors: ['.m-5 (1534:1)'] }, - '67d8671699df706a428e7da42a7141cb': { selectors: ['.mt-5, .my-5 (1538:1)'] }, - e9cb4a0a8a60ff018c87a0b7efa9de29: { selectors: ['.mr-5, .mx-5 (1543:1)'] }, - '93f579214354dbd8cb60209c068f0086': { selectors: ['.mb-5, .my-5 (1548:1)'] }, - '2a789d4af97d2b87fd0bf2b4626120cd': { selectors: ['.ml-5, .mx-5 (1553:1)'] }, - '64a89d28e8287c1a0ac153001082644c': { selectors: ['.p-0 (1558:1)'] }, - b03aa6db5ddf110bbdbefbbec43fda30: { selectors: ['.pt-0, .py-0 (1562:1)'] }, - e38192ca32a98888d4c4876880f4fece: { selectors: ['.pr-0, .px-0 (1567:1)'] }, - '70fe8ef50e999ddd29506f672c107069': { selectors: ['.pb-0, .py-0 (1572:1)'] }, - '9355e8cd9109049726475ba356661bcf': { selectors: ['.pl-0, .px-0 (1577:1)'] }, - '0d4c53468c2658c5324b9ec7a8ca6de2': { selectors: ['.p-1 (1582:1)'] }, - d74e430b2a56b3a4e20065c972b7fa3f: { selectors: ['.pt-1, .py-1 (1586:1)'] }, - '21e4644967aedd19888b6f4a700b629b': { selectors: ['.pr-1, .px-1 (1591:1)'] }, - e315a7b9b7a1d0df3ea7d95af5203a0b: { selectors: ['.pb-1, .py-1 (1596:1)'] }, - '14630ca122e1d9830a9ef5591c4097d0': { selectors: ['.pl-1, .px-1 (1601:1)'] }, - '5b1c65e5139e86e5f4755824f8b77d13': { selectors: ['.p-2 (1606:1)'] }, - '244af70950a1e200d3849f75ce51d707': { selectors: ['.pt-2, .py-2 (1610:1)'] }, - b583832738cad724c7c23e5c14ac9bfb: { selectors: ['.pr-2, .px-2 (1615:1)'] }, - e1e633c4f1375e8276154192d8899e39: { selectors: ['.pb-2, .py-2 (1620:1)'] }, - '676b01e25f0dbb3f7d2f2529231cda08': { selectors: ['.pl-2, .px-2 (1625:1)'] }, - '9b5165e3333b22801f2287f7983d7516': { selectors: ['.p-3 (1630:1)'] }, - '5bcaa9df87a507f6cd14659ea176bdc5': { selectors: ['.pt-3, .py-3 (1634:1)'] }, - f706637180776c5589385599705a2409: { selectors: ['.pr-3, .px-3 (1639:1)'] }, - '41157cfbcf47990b383b5b0379386ab2': { selectors: ['.pb-3, .py-3 (1644:1)'] }, - cac1e7a204bb6a1f42707b684ad46238: { selectors: ['.pl-3, .px-3 (1649:1)'] }, - '43e0671cd41a4b7590284888b607a134': { selectors: ['.p-4 (1654:1)'] }, - '116b0f95ebde1ff8907e488413a88854': { selectors: ['.pt-4, .py-4 (1658:1)'] }, - ecb06765fe691d892df000eebbb23dcc: { selectors: ['.pr-4, .px-4 (1663:1)'] }, - '1331503a48d36025c861e660bc615048': { selectors: ['.pb-4, .py-4 (1668:1)'] }, - f8665f7e547e499abd7ac63813b274f5: { selectors: ['.pl-4, .px-4 (1673:1)'] }, - '4160a315459f1b5a98255863f42136fe': { selectors: ['.p-5 (1678:1)'] }, - f55a6b2de6a434ec7b4375f06f4fad75: { selectors: ['.pt-5, .py-5 (1682:1)'] }, - '19391dc45c8d7730a86d521c28f52c3f': { selectors: ['.pr-5, .px-5 (1687:1)'] }, - '15898bcb7ff74a60006f9931422b4ad3': { selectors: ['.pb-5, .py-5 (1692:1)'] }, - '6290bdc6355aed1e9b27379003aa4828': { selectors: ['.pl-5, .px-5 (1697:1)'] }, - '04a144abd49b1402e3588fb4ec237ec0': { selectors: ['.m-n1 (1702:1)'] }, - b81793fb475f7cc3a0698aa92ae41777: { selectors: ['.mt-n1, .my-n1 (1706:1)'] }, - '3c39187fca578a65e7aa2d704208cde8': { selectors: ['.mr-n1, .mx-n1 (1711:1)'] }, - c6c24440dd9edef71c7bc7da951dccd5: { selectors: ['.mb-n1, .my-n1 (1716:1)'] }, - '8b528f327ea3e562fc61d13c9f3901d8': { selectors: ['.ml-n1, .mx-n1 (1721:1)'] }, - '4a1926d211f81e5c96d4c9c4f2097774': { selectors: ['.m-n2 (1726:1)'] }, - f78f1986440a943aeb5553cb11b2f23c: { selectors: ['.mt-n2, .my-n2 (1730:1)'] }, - '941a9ea73cc97224a3f55ef65ab727c9': { selectors: ['.mr-n2, .mx-n2 (1735:1)'] }, - '074441007089a0c89cda9bfcb31c763a': { selectors: ['.mb-n2, .my-n2 (1740:1)'] }, - '7f9e45f6286b38eec32d471b7c1b28b6': { selectors: ['.ml-n2, .mx-n2 (1745:1)'] }, - c322ab87c4e181d835e6c17a1ca179ad: { selectors: ['.m-n3 (1750:1)'] }, - dee7caca54972db68f956a7cfd5d372b: { selectors: ['.mt-n3, .my-n3 (1754:1)'] }, - '60c8b6aa0702bbc3eed911f7483876ce': { selectors: ['.mr-n3, .mx-n3 (1759:1)'] }, - '595290cc6428614c03bac4631fe3fc12': { selectors: ['.mb-n3, .my-n3 (1764:1)'] }, - '7b968bc3150d9768117e099261cf23df': { selectors: ['.ml-n3, .mx-n3 (1769:1)'] }, - '90ca4942944fbc4dd543a821244daa31': { selectors: ['.m-n4 (1774:1)'] }, - '1716842c880f907fc62889f928273e0c': { selectors: ['.mt-n4, .my-n4 (1778:1)'] }, - '087ab1596162227935a974af5e856174': { selectors: ['.mr-n4, .mx-n4 (1783:1)'] }, - f53133714696eaf034f3efe057ac82fe: { selectors: ['.mb-n4, .my-n4 (1788:1)'] }, - ce56811b70ca493d65e3f63acfa2d9df: { selectors: ['.ml-n4, .mx-n4 (1793:1)'] }, - '7f52135983abe2eccfbb72e5d16a6a20': { selectors: ['.m-n5 (1798:1)'] }, - de8fc351c8c23bd867cf10a14642899a: { selectors: ['.mt-n5, .my-n5 (1802:1)'] }, - b134cecaa2883916d516ae6a2b1a3891: { selectors: ['.mr-n5, .mx-n5 (1807:1)'] }, - '124ccc6a210fadb889b2742eb0f9b540': { selectors: ['.mb-n5, .my-n5 (1812:1)'] }, - c3948b63b7b0c864f4f78faf640fd9a0: { selectors: ['.ml-n5, .mx-n5 (1817:1)'] }, - e57ec4fe9e8ed36e38f1c50041fc9f47: { selectors: ['.m-auto (1822:1)'] }, - f10380665932186d1effe0674a74ba12: { selectors: ['.mt-auto, .my-auto (1826:1)'] }, - '2ce71a27023eb50a47c24a99399faa28': { selectors: ['.mr-auto, .mx-auto (1831:1)'] }, - '196c77d357d314678cd3a99cfacbea96': { selectors: ['.mb-auto, .my-auto (1836:1)'] }, - ca007ce268b463a6bf42145cf5ce3685: { selectors: ['.ml-auto, .mx-auto (1841:1)'] }, - '695821b1faf108a559486730b246876a': { selectors: ['.text-monospace (3590:1)'] }, - a8fc5ca823f51d72673577064387a029: { selectors: ['.text-justify (3594:1)'] }, - '04e83ef005e9c653fb368008f8ae8a33': { selectors: ['.text-wrap (3598:1)'] }, - '0bb94dfab7ca2c9892ebbd993b2baf0f': { selectors: ['.text-nowrap (3602:1)'] }, - aea4958ce85ddc0cbffca1015c3a7eba: { selectors: ['.text-truncate (3606:1)'] }, - '52b9443947b6b94a5c7e1b837da115e2': { selectors: ['.text-left (3612:1)'] }, - baaf5136fc6e1c54ba29b6040f166d5f: { selectors: ['.text-right (3616:1)'] }, - '282aa4319bee75af06cc2632b7124e26': { selectors: ['.text-center (3620:1)'] }, - '1cb1c8ad9b560eca25ebcefe95c1b7fa': { selectors: ['.text-lowercase (3676:1)'] }, - '45234533eac658ba2857e9c4d3bc78a5': { selectors: ['.text-uppercase (3680:1)'] }, - f9e3f64237f2e81b6aed84223a0ceb1d: { selectors: ['.text-capitalize (3684:1)'] }, - '09caca3d36aa9f3ef815e0da7e1a16b4': { selectors: ['.font-weight-light (3688:1)'] }, - '23544682bb214a76e383e032d4056be4': { selectors: ['.font-weight-lighter (3692:1)'] }, - '25189f4fad18eaeef19e349c6680834c': { selectors: ['.font-weight-normal (3696:1)'] }, - b2a9507678ec557603eb8ec077f0eb1f: { selectors: ['.font-weight-bold (3700:1)'] }, - '9d05a94a577558235edce4c8fd9ab639': { selectors: ['.font-weight-bolder (3704:1)'] }, - '7d2da06b621a98a8599e5ec82e39eac8': { selectors: ['.font-italic (3708:1)'] }, - '0020d10e4fce033b418aace7c3143b82': { selectors: ['.text-white (3712:1)'] }, - '34ad81e372a038e6f78ae4f22bd4813d': { selectors: ['.text-primary (3716:1)'] }, - '9fde9a179d24755438ace2a874dda817': { - selectors: ['.text-secondary (3724:1)', '.text-muted (3784:1)'], - }, - '9ffcb1532b3fb397c0e818850683da29': { selectors: ['.text-success (3732:1)'] }, - f28fd089809bcd15d5684b158a0af98d: { selectors: ['.text-info (3740:1)'] }, - '6cac1cb5ee5149e91e45d15d0bdae310': { selectors: ['.text-warning (3748:1)'] }, - '2faab1e0abf22b20fdf05b9b01fff29b': { selectors: ['.text-danger (3756:1)'] }, - '46b52fea531aaaf29b63c40be2356849': { selectors: ['.text-light (3764:1)'] }, - '78f31d1ab6529decf28e0366a8ee81aa': { selectors: ['.text-dark (3772:1)'] }, - '45330b41b77e8880ad7680c51e0f61c4': { selectors: ['.text-body (3780:1)'] }, - '60d93588f62b5e85eb4f11dfd3461897': { selectors: ['.text-black-50 (3788:1)'] }, - '7dea35658553032ff7b7cc0287613b7c': { selectors: ['.text-white-50 (3792:1)'] }, - '61bf92980cac3d51d0cf1ba24c948fa1': { selectors: ['.text-hide (3796:1)'] }, - '187bfde85cb4d8bdaa41735f54f5c4f8': { selectors: ['.text-decoration-none (3804:1)'] }, - fd57878967b8dce947091cdc114efd83: { selectors: ['.text-break (3808:1)'] }, - '43b8d67240c3b09505d94522a62a977c': { selectors: ['.text-reset (3813:1)'] }, - '7dcad258820769677bc60871fafe9b93': { selectors: ['.visible (3817:1)'] }, - '0f8833af4e2f4a6fc785bd7edc1e75b3': { selectors: ['.invisible (3821:1)'] }, -}; diff --git a/spec/controllers/projects/service_ping_controller_spec.rb b/spec/controllers/projects/service_ping_controller_spec.rb index fa92efee079..22fb18edc80 100644 --- a/spec/controllers/projects/service_ping_controller_spec.rb +++ b/spec/controllers/projects/service_ping_controller_spec.rb @@ -80,16 +80,24 @@ RSpec.describe Projects::ServicePingController do it_behaves_like 'counter is not increased' it_behaves_like 'counter is increased', 'WEB_IDE_PREVIEWS_SUCCESS_COUNT' - context 'when the user has access to the project' do + context 'when the user has access to the project', :snowplow do let(:user) { project.owner } it 'increases the live preview view counter' do - expect(Gitlab::UsageDataCounters::EditorUniqueCounter).to receive(:track_live_preview_edit_action).with(author: user) + expect(Gitlab::UsageDataCounters::EditorUniqueCounter).to receive(:track_live_preview_edit_action).with(author: user, project: project) subject expect(response).to have_gitlab_http_status(:ok) end + + it_behaves_like 'Snowplow event tracking' do + let(:project) { create(:project) } + let(:category) { 'ide_edit' } + let(:action) { 'g_edit_by_live_preview' } + let(:namespace) { project.namespace } + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + end end end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index 66248b1194e..e4a7a2fc410 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -258,12 +258,13 @@ RSpec.describe SearchController do end it_behaves_like 'Snowplow event tracking' do + subject { get :show, params: { group_id: namespace.id, scope: 'blobs', search: 'term' } } + + let(:project) { nil } let(:category) { described_class.to_s } let(:action) { 'i_search_total' } let(:namespace) { create(:group) } let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } - - subject { get :show, params: { group_id: namespace.id, scope: 'blobs', search: 'term' } } end context 'on restricted projects' do diff --git a/spec/features/users/email_verification_on_login_spec.rb b/spec/features/users/email_verification_on_login_spec.rb new file mode 100644 index 00000000000..54eb11ca857 --- /dev/null +++ b/spec/features/users/email_verification_on_login_spec.rb @@ -0,0 +1,357 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting do + include EmailHelpers + + let_it_be(:user) { create(:user) } + + let(:require_email_verification_enabled) { true } + + before do + stub_feature_flags(require_email_verification: require_email_verification_enabled) + end + + shared_examples 'email verification required' do + before do + allow(Gitlab::AppLogger).to receive(:info) + end + + it 'requires email verification before being able to access GitLab' do + perform_enqueued_jobs do + # When logging in + gitlab_sign_in(user) + expect_log_message(message: "Account Locked: username=#{user.username}") + expect_log_message('Instructions Sent') + + # Expect the user to be locked and the unlock_token to be set + user.reload + expect(user.locked_at).not_to be_nil + expect(user.unlock_token).not_to be_nil + + # Expect to see the verification form on the login page + expect(page).to have_current_path(new_user_session_path) + expect(page).to have_content('Help us protect your account') + + # Expect an instructions email to be sent with a code + code = expect_instructions_email_and_extract_code + + # Signing in again prompts for the code and doesn't send a new one + gitlab_sign_in(user) + expect(page).to have_current_path(new_user_session_path) + expect(page).to have_content('Help us protect your account') + + # Verify the code + verify_code(code) + expect_log_message('Successful') + expect_log_message(message: "Successful Login: username=#{user.username} "\ + "ip=127.0.0.1 method=standard admin=false") + + # Expect the user to be unlocked + expect_user_to_be_unlocked + + # Expect a confirmation page with a meta refresh tag for 3 seconds to the root + expect(page).to have_current_path(users_successful_verification_path) + expect(page).to have_content('Verification successful') + expect(page).to have_selector("meta[http-equiv='refresh'][content='3; url=#{root_path}']", visible: false) + end + end + + describe 'resending a new code' do + it 'resends a new code' do + perform_enqueued_jobs do + # When logging in + gitlab_sign_in(user) + + # Expect an instructions email to be sent with a code + code = expect_instructions_email_and_extract_code + + # Request a new code + click_link 'Resend code' + expect_log_message('Instructions Sent', 2) + new_code = expect_instructions_email_and_extract_code + + # Verify the old code is different from the new code + expect(code).not_to eq(new_code) + end + end + + it 'rate limits resends' do + # When logging in + gitlab_sign_in(user) + + # It shows a resend button + expect(page).to have_link 'Resend code' + + # Resend more than the rate limited amount of times + 10.times do + click_link 'Resend code' + end + + # Expect the link to be gone + expect(page).not_to have_link 'Resend code' + + # Wait for 1 hour + travel 1.hour + + # Now it's visible again + gitlab_sign_in(user) + expect(page).to have_link 'Resend code' + end + end + + describe 'verification errors' do + it 'rate limits verifications' do + perform_enqueued_jobs do + # When logging in + gitlab_sign_in(user) + + # Expect an instructions email to be sent with a code + code = expect_instructions_email_and_extract_code + + # Verify an invalid token more than the rate limited amount of times + 11.times do + verify_code('123456') + end + + # Expect an error message + expect_log_message('Failed Attempt', reason: 'rate_limited') + expect(page).to have_content("You've reached the maximum amount of tries. "\ + 'Wait 10 minutes or resend a new code and try again.') + + # Wait for 10 minutes + travel 10.minutes + + # Now it works again + verify_code(code) + expect_log_message('Successful') + end + end + + it 'verifies invalid codes' do + # When logging in + gitlab_sign_in(user) + + # Verify an invalid code + verify_code('123456') + + # Expect an error message + expect_log_message('Failed Attempt', reason: 'invalid') + expect(page).to have_content('The code is incorrect. Enter it again, or resend a new code.') + end + + it 'verifies expired codes' do + perform_enqueued_jobs do + # When logging in + gitlab_sign_in(user) + + # Expect an instructions email to be sent with a code + code = expect_instructions_email_and_extract_code + + # Wait for the code to expire before verifying + travel VerifiesWithEmail::TOKEN_VALID_FOR_MINUTES.minutes + 1.second + verify_code(code) + + # Expect an error message + expect_log_message('Failed Attempt', reason: 'expired') + expect(page).to have_content('The code has expired. Resend a new code and try again.') + end + end + end + end + + shared_examples 'no email verification required' do |**login_args| + it 'does not lock the user and redirects to the root page after logging in' do + gitlab_sign_in(user, **login_args) + + expect_user_to_be_unlocked + + expect(page).to have_current_path(root_path) + end + end + + shared_examples 'no email verification required when 2fa enabled or ff disabled' do + context 'when 2FA is enabled' do + let_it_be(:user) { create(:user, :two_factor) } + + it_behaves_like 'no email verification required', two_factor_auth: true + end + + context 'when the feature flag is disabled' do + let(:require_email_verification_enabled) { false } + + it_behaves_like 'no email verification required' + end + end + + describe 'when failing to login the maximum allowed number of times' do + before do + # See comment in RequireEmailVerification::MAXIMUM_ATTEMPTS on why this is divided by 2 + (RequireEmailVerification::MAXIMUM_ATTEMPTS / 2).times do + gitlab_sign_in(user, password: 'wrong_password') + end + end + + it 'locks the user, but does not set the unlock token', :aggregate_failures do + user.reload + expect(user.locked_at).not_to be_nil + expect(user.unlock_token).to be_nil # The unlock token is only set after logging in with valid credentials + expect(user.failed_attempts).to eq(RequireEmailVerification::MAXIMUM_ATTEMPTS) + end + + it_behaves_like 'email verification required' + it_behaves_like 'no email verification required when 2fa enabled or ff disabled' + + describe 'when waiting for the auto unlock time' do + before do + travel User::UNLOCK_IN + 1.second + end + + it_behaves_like 'no email verification required' + end + end + + describe 'when no previous authentication event exists' do + it_behaves_like 'no email verification required' + end + + describe 'when a previous authentication event exists for another ip address' do + before do + create(:authentication_event, :successful, user: user, ip_address: '1.2.3.4') + end + + it_behaves_like 'email verification required' + it_behaves_like 'no email verification required when 2fa enabled or ff disabled' + end + + describe 'when a previous authentication event exists for the same ip address' do + before do + create(:authentication_event, :successful, user: user) + end + + it_behaves_like 'no email verification required' + end + + describe 'rate limiting password guessing' do + before do + 5.times { gitlab_sign_in(user, password: 'wrong_password') } + gitlab_sign_in(user) + end + + it 'shows an error message on on the login page' do + expect(page).to have_current_path(new_user_session_path) + expect(page).to have_content('Maximum login attempts exceeded. Wait 10 minutes and try again.') + end + end + + describe 'inconsistent states' do + context 'when the feature flag is toggled off after being prompted for a verification token' do + before do + create(:authentication_event, :successful, user: user, ip_address: '1.2.3.4') + end + + it 'still accepts the token' do + perform_enqueued_jobs do + # The user is prompted for a verification code + gitlab_sign_in(user) + expect(page).to have_content('Help us protect your account') + code = expect_instructions_email_and_extract_code + + # We toggle the feature flag off + stub_feature_flags(require_email_verification: false) + + # Resending and veryfying the code work as expected + click_link 'Resend code' + new_code = expect_instructions_email_and_extract_code + + verify_code(code) + expect(page).to have_content('The code is incorrect. Enter it again, or resend a new code.') + + travel VerifiesWithEmail::TOKEN_VALID_FOR_MINUTES.minutes + 1.second + + verify_code(new_code) + expect(page).to have_content('The code has expired. Resend a new code and try again.') + + click_link 'Resend code' + another_code = expect_instructions_email_and_extract_code + + verify_code(another_code) + expect_user_to_be_unlocked + expect(page).to have_current_path(users_successful_verification_path) + end + end + end + + context 'when the feature flag is toggled on after Devise sent unlock instructions' do + let(:require_email_verification_enabled) { false } + + before do + perform_enqueued_jobs do + (User.maximum_attempts / 2).times do + gitlab_sign_in(user, password: 'wrong_password') + end + end + end + + it 'the unlock link still works' do + # The user is locked and unlock instructions are sent + expect(page).to have_content('Invalid login or password.') + user.reload + expect(user.locked_at).not_to be_nil + expect(user.unlock_token).not_to be_nil + mail = find_email_for(user) + + expect(mail.to).to match_array([user.email]) + expect(mail.subject).to eq('Unlock instructions') + unlock_url = mail.body.parts.first.to_s[/http.*/] + + # We toggle the feature flag on + stub_feature_flags(require_email_verification: true) + + # Unlocking works as expected + visit unlock_url + expect_user_to_be_unlocked + expect(page).to have_current_path(new_user_session_path) + expect(page).to have_content('Your account has been unlocked successfully') + + gitlab_sign_in(user) + expect(page).to have_current_path(root_path) + end + end + end + + def expect_user_to_be_unlocked + user.reload + + aggregate_failures do + expect(user.locked_at).to be_nil + expect(user.unlock_token).to be_nil + expect(user.failed_attempts).to eq(0) + end + end + + def expect_instructions_email_and_extract_code + mail = find_email_for(user) + expect(mail.to).to match_array([user.email]) + expect(mail.subject).to eq('Verify your identity') + code = mail.body.parts.first.to_s[/\d{#{VerifiesWithEmail::TOKEN_LENGTH}}/] + reset_delivered_emails! + code + end + + def verify_code(code) + fill_in 'Verification code', with: code + click_button 'Verify code' + end + + def expect_log_message(event = nil, times = 1, reason: '', message: nil) + expect(Gitlab::AppLogger).to have_received(:info) + .exactly(times).times + .with(message || hash_including(message: 'Email Verification', + event: event, + username: user.username, + ip: '127.0.0.1', + reason: reason)) + end +end diff --git a/spec/frontend/issues/show/components/incidents/utils_spec.js b/spec/frontend/issues/show/components/incidents/utils_spec.js index e6f7082d280..ff148702696 100644 --- a/spec/frontend/issues/show/components/incidents/utils_spec.js +++ b/spec/frontend/issues/show/components/incidents/utils_spec.js @@ -19,9 +19,9 @@ describe('incident utils', () => { describe('get event icon', () => { it('should display a matching event icon name', () => { - const name = 'comment'; - - expect(getEventIcon(name)).toBe(name); + ['comment', 'issues', 'status'].forEach((name) => { + expect(getEventIcon(name)).toBe(name); + }); }); it('should return a default icon name', () => { diff --git a/spec/helpers/sessions_helper_spec.rb b/spec/helpers/sessions_helper_spec.rb index fd3d7100ba1..15424425060 100644 --- a/spec/helpers/sessions_helper_spec.rb +++ b/spec/helpers/sessions_helper_spec.rb @@ -50,4 +50,51 @@ RSpec.describe SessionsHelper do expect(helper.unconfirmed_email?).to be_falsey end end + + describe '#send_rate_limited?' do + let_it_be(:user) { build(:user) } + + subject { helper.send_rate_limited?(user) } + + before do + allow(::Gitlab::ApplicationRateLimiter) + .to receive(:peek) + .with(:email_verification_code_send, scope: user) + .and_return(rate_limited) + end + + context 'when rate limited' do + let(:rate_limited) { true } + + it { is_expected.to eq(true) } + end + + context 'when not rate limited' do + let(:rate_limited) { false } + + it { is_expected.to eq(false) } + end + end + + describe '#obfuscated_email' do + subject { helper.obfuscated_email(email) } + + context 'when an email address is normal length' do + let(:email) { 'alex@gitlab.com' } + + it { is_expected.to eq('al**@g*****.com') } + end + + context 'when an email address contains multiple top level domains' do + let(:email) { 'alex@gl.co.uk' } + + it { is_expected.to eq('al**@g****.uk') } + end + + context 'when an email address is very short' do + let(:email) { 'a@b' } + + it { is_expected.to eq('a@b') } + end + end end diff --git a/spec/lib/gitlab/ci/yaml_processor/feature_flags_spec.rb b/spec/lib/gitlab/ci/yaml_processor/feature_flags_spec.rb new file mode 100644 index 00000000000..0bd9563d191 --- /dev/null +++ b/spec/lib/gitlab/ci/yaml_processor/feature_flags_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +RSpec.describe Gitlab::Ci::YamlProcessor::FeatureFlags do + let(:feature_flag) { :my_feature_flag } + + context 'when the actor is set' do + let(:actor) { double } + let(:another_actor) { double } + + it 'checks the feature flag using the given actor' do + described_class.with_actor(actor) do + expect(Feature).to receive(:enabled?).with(feature_flag, actor) + + described_class.enabled?(feature_flag) + end + end + + it 'returns the value of the block' do + result = described_class.with_actor(actor) do + :test + end + + expect(result).to eq(:test) + end + + it 'restores the existing actor if any' do + described_class.with_actor(actor) do + described_class.with_actor(another_actor) do + expect(Feature).to receive(:enabled?).with(feature_flag, another_actor) + + described_class.enabled?(feature_flag) + end + + expect(Feature).to receive(:enabled?).with(feature_flag, actor) + described_class.enabled?(feature_flag) + end + end + + it 'restores the actor to nil after the block' do + described_class.with_actor(actor) do + expect(Thread.current[described_class::ACTOR_KEY]).to eq(actor) + end + + expect(Thread.current[described_class::ACTOR_KEY]).to be nil + end + end + + context 'when feature flag is checked outside the "with_actor" block' do + it 'raises an error on dev/test environment' do + expect { described_class.enabled?(feature_flag) }.to raise_error(described_class::NoActorError) + end + + context 'when on production' do + before do + allow(Gitlab::ErrorTracking).to receive(:should_raise_for_dev?).and_return(false) + end + + it 'checks the feature flag without actor' do + expect(Feature).to receive(:enabled?).with(feature_flag, nil) + expect(Gitlab::ErrorTracking) + .to receive(:track_and_raise_for_dev_exception) + .and_call_original + + described_class.enabled?(feature_flag) + end + end + end + + context 'when actor is explicitly nil' do + it 'checks the feature flag without actor' do + described_class.with_actor(nil) do + expect(Feature).to receive(:enabled?).with(feature_flag, nil) + + described_class.enabled?(feature_flag) + end + end + end +end diff --git a/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb index dbc34681660..bfbabd858f0 100644 --- a/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red let(:user1) { build(:user, id: 1) } let(:user2) { build(:user, id: 2) } let(:user3) { build(:user, id: 3) } + let(:project) { build(:project) } let(:time) { Time.zone.now } shared_examples 'tracks and counts action' do @@ -15,10 +16,9 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red specify do aggregate_failures do - expect(track_action(author: user1)).to be_truthy - expect(track_action(author: user1)).to be_truthy - expect(track_action(author: user2)).to be_truthy - expect(track_action(author: user3, time: time - 3.days)).to be_truthy + expect(track_action(author: user1, project: project)).to be_truthy + expect(track_action(author: user2, project: project)).to be_truthy + expect(track_action(author: user3, time: time - 3.days, project: project)).to be_truthy expect(count_unique(date_from: time, date_to: Date.today)).to eq(2) expect(count_unique(date_from: time - 5.days, date_to: Date.tomorrow)).to eq(3) @@ -26,7 +26,7 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red end it 'does not track edit actions if author is not present' do - expect(track_action(author: nil)).to be_nil + expect(track_action(author: nil, project: project)).to be_nil end end @@ -67,16 +67,16 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red end it 'can return the count of actions per user deduplicated' do - described_class.track_web_ide_edit_action(author: user1) - described_class.track_live_preview_edit_action(author: user1) - described_class.track_snippet_editor_edit_action(author: user1) - described_class.track_sfe_edit_action(author: user1) - described_class.track_web_ide_edit_action(author: user2, time: time - 2.days) - described_class.track_web_ide_edit_action(author: user3, time: time - 3.days) - described_class.track_live_preview_edit_action(author: user2, time: time - 2.days) - described_class.track_live_preview_edit_action(author: user3, time: time - 3.days) - described_class.track_snippet_editor_edit_action(author: user3, time: time - 3.days) - described_class.track_sfe_edit_action(author: user3, time: time - 3.days) + described_class.track_web_ide_edit_action(author: user1, project: project) + described_class.track_live_preview_edit_action(author: user1, project: project) + described_class.track_snippet_editor_edit_action(author: user1, project: project) + described_class.track_sfe_edit_action(author: user1, project: project) + described_class.track_web_ide_edit_action(author: user2, time: time - 2.days, project: project) + described_class.track_web_ide_edit_action(author: user3, time: time - 3.days, project: project) + described_class.track_live_preview_edit_action(author: user2, time: time - 2.days, project: project) + described_class.track_live_preview_edit_action(author: user3, time: time - 3.days, project: project) + described_class.track_snippet_editor_edit_action(author: user3, time: time - 3.days, project: project) + described_class.track_sfe_edit_action(author: user3, time: time - 3.days, project: project) expect(described_class.count_edit_using_editor(date_from: time, date_to: Date.today)).to eq(1) expect(described_class.count_edit_using_editor(date_from: time - 5.days, date_to: Date.tomorrow)).to eq(3) diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 77e112edaca..439e32e572b 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -249,7 +249,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ) end - it 'includes imports usage data' do + it 'includes imports usage data', :clean_gitlab_redis_cache do for_defined_days_back do user = create(:user) @@ -1152,35 +1152,36 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do let(:user2) { build(:user, id: 2) } let(:user3) { build(:user, id: 3) } let(:user4) { build(:user, id: 4) } + let(:project) { build(:project) } before do counter = Gitlab::UsageDataCounters::TrackUniqueEvents - project = Event::TARGET_TYPES[:project] + project_type = Event::TARGET_TYPES[:project] wiki = Event::TARGET_TYPES[:wiki] design = Event::TARGET_TYPES[:design] - counter.track_event(event_action: :pushed, event_target: project, author_id: 1) - counter.track_event(event_action: :pushed, event_target: project, author_id: 1) - counter.track_event(event_action: :pushed, event_target: project, author_id: 2) - counter.track_event(event_action: :pushed, event_target: project, author_id: 3) - counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days) + counter.track_event(event_action: :pushed, event_target: project_type, author_id: 1) + counter.track_event(event_action: :pushed, event_target: project_type, author_id: 1) + counter.track_event(event_action: :pushed, event_target: project_type, author_id: 2) + counter.track_event(event_action: :pushed, event_target: project_type, author_id: 3) + counter.track_event(event_action: :pushed, event_target: project_type, author_id: 4, time: time - 3.days) counter.track_event(event_action: :created, event_target: wiki, author_id: 3) counter.track_event(event_action: :created, event_target: design, author_id: 3) counter.track_event(event_action: :created, event_target: design, author_id: 4) counter = Gitlab::UsageDataCounters::EditorUniqueCounter - counter.track_web_ide_edit_action(author: user1) - counter.track_web_ide_edit_action(author: user1) - counter.track_sfe_edit_action(author: user1) - counter.track_snippet_editor_edit_action(author: user1) - counter.track_snippet_editor_edit_action(author: user1, time: time - 3.days) + counter.track_web_ide_edit_action(author: user1, project: project) + counter.track_web_ide_edit_action(author: user1, project: project) + counter.track_sfe_edit_action(author: user1, project: project) + counter.track_snippet_editor_edit_action(author: user1, project: project) + counter.track_snippet_editor_edit_action(author: user1, time: time - 3.days, project: project) - counter.track_web_ide_edit_action(author: user2) - counter.track_sfe_edit_action(author: user2) + counter.track_web_ide_edit_action(author: user2, project: project) + counter.track_sfe_edit_action(author: user2, project: project) - counter.track_web_ide_edit_action(author: user3, time: time - 3.days) - counter.track_snippet_editor_edit_action(author: user3) + counter.track_web_ide_edit_action(author: user3, time: time - 3.days, project: project) + counter.track_snippet_editor_edit_action(author: user3, project: project) end it 'returns the distinct count of user actions within the specified time period' do diff --git a/spec/migrations/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events_spec.rb b/spec/migrations/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events_spec.rb new file mode 100644 index 00000000000..8cb6ab23fef --- /dev/null +++ b/spec/migrations/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe AddUserIdAndIpAddressSuccessIndexToAuthenticationEvents do + let(:db) { described_class.new } + let(:old_index) { described_class::OLD_INDEX_NAME } + let(:new_index) { described_class::NEW_INDEX_NAME } + + it 'correctly migrates up and down' do + reversible_migration do |migration| + migration.before -> { + expect(db.connection.indexes(:authentication_events).map(&:name)).to include(old_index) + expect(db.connection.indexes(:authentication_events).map(&:name)).not_to include(new_index) + } + + migration.after -> { + expect(db.connection.indexes(:authentication_events).map(&:name)).to include(new_index) + expect(db.connection.indexes(:authentication_events).map(&:name)).not_to include(old_index) + } + end + end +end diff --git a/spec/models/authentication_event_spec.rb b/spec/models/authentication_event_spec.rb index 83598fa6765..23e253c2a28 100644 --- a/spec/models/authentication_event_spec.rb +++ b/spec/models/authentication_event_spec.rb @@ -44,4 +44,31 @@ RSpec.describe AuthenticationEvent do expect(described_class.providers).to match_array %w(ldapmain google_oauth2 standard two-factor two-factor-via-u2f-device two-factor-via-webauthn-device) end end + + describe '.initial_login_or_known_ip_address?' do + let_it_be(:user) { create(:user) } + let_it_be(:ip_address) { '127.0.0.1' } + + subject { described_class.initial_login_or_known_ip_address?(user, ip_address) } + + context 'on first login, when no record exists yet' do + it { is_expected.to eq(true) } + end + + context 'on second login from the same ip address' do + before do + create(:authentication_event, :successful, user: user, ip_address: ip_address) + end + + it { is_expected.to eq(true) } + end + + context 'on second login from another ip address' do + before do + create(:authentication_event, :successful, user: user, ip_address: '1.2.3.4') + end + + it { is_expected.to eq(false) } + end + end end diff --git a/spec/models/concerns/require_email_verification_spec.rb b/spec/models/concerns/require_email_verification_spec.rb new file mode 100644 index 00000000000..66e35563c7f --- /dev/null +++ b/spec/models/concerns/require_email_verification_spec.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe RequireEmailVerification do + let_it_be(:model) do + Class.new(ApplicationRecord) do + self.table_name = 'users' + + devise :lockable + + include RequireEmailVerification + end + end + + using RSpec::Parameterized::TableSyntax + + where(:feature_flag_enabled, :two_factor_enabled, :overridden) do + false | false | false + false | true | false + true | false | true + true | true | false + end + + with_them do + let(:instance) { model.new } + + before do + stub_feature_flags(require_email_verification: feature_flag_enabled) + allow(instance).to receive(:two_factor_enabled?).and_return(two_factor_enabled) + end + + describe '#lock_access!' do + subject { instance.lock_access! } + + before do + allow(instance).to receive(:save) + end + + it 'sends Devise unlock instructions unless overridden and always sets locked_at' do + expect(instance).to receive(:send_unlock_instructions).exactly(overridden ? 0 : 1).times + + expect { subject }.to change { instance.locked_at }.from(nil) + end + end + + describe '#attempts_exceeded?' do + subject { instance.send(:attempts_exceeded?) } + + context 'when failed_attempts is LT overridden amount' do + before do + instance.failed_attempts = 5 + end + + it { is_expected.to eq(false) } + end + + context 'when failed_attempts is GTE overridden amount but LT Devise default amount' do + before do + instance.failed_attempts = 6 + end + + it { is_expected.to eq(overridden) } + end + + context 'when failed_attempts is GTE Devise default amount' do + before do + instance.failed_attempts = 10 + end + + it { is_expected.to eq(true) } + end + end + + describe '#lock_expired?' do + subject { instance.send(:lock_expired?) } + + context 'when locked shorter ago than Devise default time' do + before do + instance.locked_at = 9.minutes.ago + end + + it { is_expected.to eq(false) } + end + + context 'when locked longer ago than Devise default time but shorter ago than overriden time' do + before do + instance.locked_at = 11.minutes.ago + end + + it { is_expected.to eq(!overridden) } + end + + context 'when locked longer ago than overriden time' do + before do + instance.locked_at = (24.hours + 1.minute).ago + end + + it { is_expected.to eq(true) } + end + end + end +end diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 67c2ec91540..4c338a16f83 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -392,14 +392,25 @@ RSpec.describe API::Commits do end end - context 'when using warden' do - it 'increments usage counters', :clean_gitlab_redis_sessions do + context 'when using warden', :snowplow, :clean_gitlab_redis_sessions do + before do stub_session('warden.user.user.key' => [[user.id], user.encrypted_password[0, 29]]) + end + subject { post api(url), params: valid_c_params } + + it 'increments usage counters' do expect(::Gitlab::UsageDataCounters::WebIdeCounter).to receive(:increment_commits_count) expect(::Gitlab::UsageDataCounters::EditorUniqueCounter).to receive(:track_web_ide_edit_action) - post api(url), params: valid_c_params + subject + end + + it_behaves_like 'Snowplow event tracking' do + let(:namespace) { project.namespace } + let(:category) { 'ide_edit' } + let(:action) { 'g_edit_by_web_ide' } + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } end end diff --git a/spec/requests/api/graphql/mutations/snippets/update_spec.rb b/spec/requests/api/graphql/mutations/snippets/update_spec.rb index eb7e6f840fe..bf93c2aaa55 100644 --- a/spec/requests/api/graphql/mutations/snippets/update_spec.rb +++ b/spec/requests/api/graphql/mutations/snippets/update_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Updating a Snippet' do include GraphqlHelpers + include SessionHelpers let_it_be(:original_content) { 'Initial content' } let_it_be(:original_description) { 'Initial description' } @@ -162,7 +163,7 @@ RSpec.describe 'Updating a Snippet' do end end - context 'when the author is a member of the project' do + context 'when the author is a member of the project', :snowplow do before do project.add_developer(current_user) end @@ -185,6 +186,20 @@ RSpec.describe 'Updating a Snippet' do it_behaves_like 'has spam protection' do let(:mutation_class) { ::Mutations::Snippets::Update } end + + context 'when not sessionless', :clean_gitlab_redis_sessions do + before do + stub_session('warden.user.user.key' => [[current_user.id], current_user.encrypted_password[0, 29]]) + end + + it_behaves_like 'Snowplow event tracking' do + let(:user) { current_user } + let(:namespace) { project.namespace } + let(:category) { 'ide_edit' } + let(:action) { 'g_edit_by_snippet_ide' } + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + end + end end it_behaves_like 'when the snippet is not found' diff --git a/spec/requests/verifies_with_email_spec.rb b/spec/requests/verifies_with_email_spec.rb new file mode 100644 index 00000000000..5b568c1d3ed --- /dev/null +++ b/spec/requests/verifies_with_email_spec.rb @@ -0,0 +1,232 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'VerifiesWithEmail', :clean_gitlab_redis_sessions, :clean_gitlab_redis_rate_limiting do + include SessionHelpers + include EmailHelpers + + let(:user) { create(:user) } + + shared_examples_for 'send verification instructions' do + it 'locks the user' do + user.reload + expect(user.unlock_token).not_to be_nil + expect(user.locked_at).not_to be_nil + end + + it 'sends an email' do + mail = find_email_for(user) + expect(mail.to).to match_array([user.email]) + expect(mail.subject).to eq('Verify your identity') + end + end + + shared_examples_for 'prompt for email verification' do + it 'sets the verification_user_id session variable and renders the email verification template' do + expect(request.session[:verification_user_id]).to eq(user.id) + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('devise/sessions/email_verification') + end + end + + describe 'verify_with_email' do + context 'when user is locked and a verification_user_id session variable exists' do + before do + encrypted_token = Devise.token_generator.digest(User, :unlock_token, 'token') + user.update!(locked_at: Time.current, unlock_token: encrypted_token) + stub_session(verification_user_id: user.id) + end + + context 'when rate limited and a verification_token param exists' do + before do + allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) + + post(user_session_path(user: { verification_token: 'token' })) + end + + it_behaves_like 'prompt for email verification' + + it 'adds a verification error message' do + expect(response.body) + .to include("You've reached the maximum amount of tries. "\ + 'Wait 10 minutes or resend a new code and try again.') + end + end + + context 'when an invalid verification_token param exists' do + before do + post(user_session_path(user: { verification_token: 'invalid_token' })) + end + + it_behaves_like 'prompt for email verification' + + it 'adds a verification error message' do + expect(response.body).to include(('The code is incorrect. Enter it again, or resend a new code.')) + end + end + + context 'when an expired verification_token param exists' do + before do + user.update!(locked_at: 1.hour.ago) + post(user_session_path(user: { verification_token: 'token' })) + end + + it_behaves_like 'prompt for email verification' + + it 'adds a verification error message' do + expect(response.body).to include(('The code has expired. Resend a new code and try again.')) + end + end + + context 'when a valid verification_token param exists' do + before do + post(user_session_path(user: { verification_token: 'token' })) + end + + it 'unlocks the user' do + user.reload + expect(user.unlock_token).to be_nil + expect(user.locked_at).to be_nil + end + + it 'redirects to the successful verification path' do + expect(response).to redirect_to(users_successful_verification_path) + end + end + end + + context 'when signing in with a valid password' do + let(:sign_in) { post(user_session_path(user: { login: user.username, password: user.password })) } + + context 'when the feature flag is toggled on' do + before do + stub_feature_flags(require_email_verification: true) + end + + context 'when rate limited' do + before do + allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) + sign_in + end + + it 'redirects to the login form and shows an alert message' do + expect(response).to redirect_to(new_user_session_path) + expect(flash[:alert]).to eq('Maximum login attempts exceeded. Wait 10 minutes and try again.') + end + end + + context 'when the user already has an unlock_token set' do + before do + user.update!(unlock_token: 'token') + sign_in + end + + it_behaves_like 'prompt for email verification' + end + + context 'when the user is already locked' do + before do + user.update!(locked_at: Time.current) + perform_enqueued_jobs { sign_in } + end + + it_behaves_like 'send verification instructions' + it_behaves_like 'prompt for email verification' + end + + context 'when the user is signing in from an unknown ip address' do + before do + allow(AuthenticationEvent) + .to receive(:initial_login_or_known_ip_address?) + .and_return(false) + + perform_enqueued_jobs { sign_in } + end + + it_behaves_like 'send verification instructions' + it_behaves_like 'prompt for email verification' + end + end + + context 'when the feature flag is toggled off' do + before do + stub_feature_flags(require_email_verification: false) + sign_in + end + + it 'redirects to the root path' do + expect(response).to redirect_to(root_path) + end + end + end + end + + describe 'resend_verification_code' do + context 'when no verification_user_id session variable exists' do + before do + post(users_resend_verification_code_path) + end + + it 'returns 204 No Content' do + expect(response).to have_gitlab_http_status(:no_content) + expect(response.body).to be_empty + end + end + + context 'when a verification_user_id session variable exists' do + before do + stub_session(verification_user_id: user.id) + + perform_enqueued_jobs do + post(users_resend_verification_code_path) + end + end + + it_behaves_like 'send verification instructions' + it_behaves_like 'prompt for email verification' + end + + context 'when exceeding the rate limit' do + before do + allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true) + + stub_session(verification_user_id: user.id) + + perform_enqueued_jobs do + post(users_resend_verification_code_path) + end + end + + it 'does not lock the user' do + user.reload + expect(user.unlock_token).to be_nil + expect(user.locked_at).to be_nil + end + + it 'does not send an email' do + mail = find_email_for(user) + expect(mail).to be_nil + end + + it_behaves_like 'prompt for email verification' + end + end + + describe 'successful_verification' do + before do + sign_in(user) + end + + it 'renders the template and removes the verification_user_id session variable' do + stub_session(verification_user_id: user.id) + + get(users_successful_verification_path) + + expect(request.session.has_key?(:verification_user_id)).to eq(false) + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('successful_verification', layout: 'minimal') + expect(response.body).to include(root_path) + end + end +end diff --git a/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb b/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb index 731406613dd..88c5f6125b9 100644 --- a/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb +++ b/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb @@ -36,8 +36,20 @@ RSpec.describe IncidentManagement::IssuableEscalationStatuses::AfterUpdateServic end end + shared_examples 'adds a status change timeline event' do + specify do + expect(IncidentManagement::TimelineEvents::CreateService) + .to receive(:change_incident_status) + .with(issue, current_user, escalation_status) + .and_call_original + + expect { result }.to change { issue.reload.incident_management_timeline_events.count }.by(1) + end + end + context 'with status attributes' do it_behaves_like 'adds a status change system note' + it_behaves_like 'adds a status change timeline event' it 'updates the alert with the new alert status' do expect(::AlertManagement::Alerts::UpdateService).to receive(:new).once.and_call_original @@ -54,6 +66,7 @@ RSpec.describe IncidentManagement::IssuableEscalationStatuses::AfterUpdateServic it_behaves_like 'does not attempt to update the alert' it_behaves_like 'adds a status change system note' + it_behaves_like 'adds a status change timeline event' end context 'when new status matches the current status' do @@ -62,6 +75,7 @@ RSpec.describe IncidentManagement::IssuableEscalationStatuses::AfterUpdateServic it_behaves_like 'does not attempt to update the alert' specify { expect { result }.not_to change { issue.reload.notes.count } } + specify { expect { result }.not_to change { issue.reload.incident_management_timeline_events.count } } end end end diff --git a/spec/services/incident_management/timeline_events/create_service_spec.rb b/spec/services/incident_management/timeline_events/create_service_spec.rb index 133a644f243..a4e928b98f4 100644 --- a/spec/services/incident_management/timeline_events/create_service_spec.rb +++ b/spec/services/incident_management/timeline_events/create_service_spec.rb @@ -132,6 +132,40 @@ RSpec.describe IncidentManagement::TimelineEvents::CreateService do it 'creates a system note' do expect { execute }.to change { incident.notes.reload.count }.by(1) end + + context 'with auto_created param' do + let(:args) do + { + note: 'note', + occurred_at: Time.current, + action: 'new comment', + promoted_from_note: comment, + auto_created: auto_created + } + end + + context 'when auto_created is true' do + let(:auto_created) { true } + + it 'does not create a system note' do + expect { execute }.not_to change { incident.notes.reload.count } + end + + context 'when user does not have permissions' do + let(:current_user) { user_without_permissions } + + it_behaves_like 'success response' + end + end + + context 'when auto_created is false' do + let(:auto_created) { false } + + it 'creates a system note' do + expect { execute }.to change { incident.notes.reload.count }.by(1) + end + end + end end context 'when incident_timeline feature flag is disabled' do @@ -144,4 +178,71 @@ RSpec.describe IncidentManagement::TimelineEvents::CreateService do end end end + + describe 'automatically created timeline events' do + shared_examples 'successfully created timeline event' do + it 'creates a timeline event', :aggregate_failures do + expect(execute).to be_success + + result = execute.payload[:timeline_event] + expect(result).to be_a(::IncidentManagement::TimelineEvent) + expect(result.author).to eq(current_user) + expect(result.incident).to eq(incident) + expect(result.project).to eq(project) + expect(result.note).to eq(expected_note) + expect(result.editable).to eq(false) + expect(result.action).to eq(expected_action) + end + + it_behaves_like 'an incident management tracked event', :incident_management_timeline_event_created + + it 'successfully creates a database record', :aggregate_failures do + expect { execute }.to change { ::IncidentManagement::TimelineEvent.count }.by(1) + end + + it 'does not create a system note' do + expect { execute }.not_to change { incident.notes.reload.count } + end + end + + describe '.create_incident' do + subject(:execute) { described_class.create_incident(incident, current_user) } + + let(:expected_note) { "@#{current_user.username} created the incident" } + let(:expected_action) { 'issues' } + + it_behaves_like 'successfully created timeline event' + end + + describe '.reopen_incident' do + subject(:execute) { described_class.reopen_incident(incident, current_user) } + + let(:expected_note) { "@#{current_user.username} reopened the incident" } + let(:expected_action) { 'issues' } + + it_behaves_like 'successfully created timeline event' + end + + describe '.resolve_incident' do + subject(:execute) { described_class.resolve_incident(incident, current_user) } + + let(:expected_note) { "@#{current_user.username} resolved the incident" } + let(:expected_action) { 'status' } + + it_behaves_like 'successfully created timeline event' + end + + describe '.change_incident_status' do + subject(:execute) { described_class.change_incident_status(incident, current_user, escalation_status) } + + let(:escalation_status) do + instance_double('IncidentManagement::IssuableEscalationStatus', status_name: 'acknowledged') + end + + let(:expected_note) { "@#{current_user.username} changed the incident status to **Acknowledged**" } + let(:expected_action) { 'status' } + + it_behaves_like 'successfully created timeline event' + end + end end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 344da5a6582..e88fe1b42f0 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -122,14 +122,29 @@ RSpec.describe Issues::CloseService do expect(new_note.author).to eq(user) end + it 'adds a timeline event', :aggregate_failures do + expect(IncidentManagement::TimelineEvents::CreateService) + .to receive(:resolve_incident) + .with(issue, user) + .and_call_original + + expect { service.execute(issue) }.to change { issue.incident_management_timeline_events.count }.by(1) + end + context 'when the escalation status did not change to resolved' do let(:escalation_status) { instance_double('IncidentManagement::IssuableEscalationStatus', resolve: false) } - it 'does not create a system note' do + before do allow(issue).to receive(:incident_management_issuable_escalation_status).and_return(escalation_status) + end + it 'does not create a system note' do expect { service.execute(issue) }.not_to change { issue.notes.count } end + + it 'does not create a timeline event' do + expect { service.execute(issue) }.not_to change { issue.incident_management_timeline_events.count } + end end end end diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index ba2a50c6edb..0bc8511e3e3 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -135,6 +135,14 @@ RSpec.describe Issues::CreateService do issue end + it 'calls IncidentManagement::TimelineEvents::CreateService.create_incident' do + expect(IncidentManagement::TimelineEvents::CreateService) + .to receive(:create_incident) + .with(a_kind_of(Issue), reporter) + + issue + end + context 'when invalid' do before do opts.merge!(title: '') diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index c9469b861ac..477b44f4c2c 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -33,6 +33,8 @@ RSpec.describe Issues::ReopenService do context 'when user is authorized to reopen issue' do let(:user) { create(:user) } + subject(:execute) { described_class.new(project: project, current_user: user).execute(issue) } + before do project.add_maintainer(user) end @@ -41,14 +43,12 @@ RSpec.describe Issues::ReopenService do issue.assignees << user expect_any_instance_of(User).to receive(:invalidate_issue_cache_counts) - described_class.new(project: project, current_user: user).execute(issue) + execute end it 'refreshes the number of opened issues' do - service = described_class.new(project: project, current_user: user) - expect do - service.execute(issue) + execute BatchLoader::Executor.clear_current end.to change { project.open_issues_count }.from(0).to(1) @@ -61,16 +61,27 @@ RSpec.describe Issues::ReopenService do expect(service).to receive(:delete_cache).and_call_original end - described_class.new(project: project, current_user: user).execute(issue) + execute + end + + it 'does not create timeline event' do + expect { execute }.not_to change { issue.incident_management_timeline_events.count } end context 'issue is incident type' do let(:issue) { create(:incident, :closed, project: project) } let(:current_user) { user } - subject { described_class.new(project: project, current_user: user).execute(issue) } - it_behaves_like 'an incident management tracked event', :incident_management_incident_reopened + + it 'creates a timeline event' do + expect(IncidentManagement::TimelineEvents::CreateService) + .to receive(:reopen_incident) + .with(issue, current_user) + .and_call_original + + expect { execute }.to change { issue.incident_management_timeline_events.count }.by(1) + end end context 'when issue is not confidential' do @@ -78,18 +89,18 @@ RSpec.describe Issues::ReopenService do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks) - described_class.new(project: project, current_user: user).execute(issue) + execute end end context 'when issue is confidential' do - it 'executes confidential issue hooks' do - issue = create(:issue, :confidential, :closed, project: project) + let(:issue) { create(:issue, :confidential, :closed, project: project) } + it 'executes confidential issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks) - described_class.new(project: project, current_user: user).execute(issue) + execute end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6bd16edcb72..d01af996141 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -316,6 +316,10 @@ RSpec.configure do |config| # most cases. We do test the CAPTCHA flow in the appropriate specs. stub_feature_flags(arkose_labs_login_challenge: false) + # Specs should not require email verification by default, this makes the sign-in flow simpler in + # most cases. We do test the email verification flow in the appropriate specs. + stub_feature_flags(require_email_verification: false) + allow(Gitlab::GitalyClient).to receive(:can_use_disk?).and_return(enable_rugged) else unstub_all_feature_flags diff --git a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb index 2f908c4b428..cd03906b001 100644 --- a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb +++ b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb @@ -10,7 +10,6 @@ shared_examples 'Snowplow event tracking' do let(:label) { nil } - let(:project) { nil } it 'is not emitted if FF is disabled' do stub_feature_flags(feature_flag_name => false) diff --git a/vendor/gems/ipynbdiff/lib/transformed_notebook.rb b/vendor/gems/ipynbdiff/lib/transformed_notebook.rb index 7a8edf7c22f..f98e5f68086 100644 --- a/vendor/gems/ipynbdiff/lib/transformed_notebook.rb +++ b/vendor/gems/ipynbdiff/lib/transformed_notebook.rb @@ -6,7 +6,7 @@ module IpynbDiff attr_reader :blocks def as_text - @blocks.map { |b| b[:content] }.join("\n") + @blocks.map { |b| b[:content].gsub(/\n/, '\\n') }.join("\n") end private diff --git a/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected.md b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected.md new file mode 100644 index 00000000000..c62e8fd6b9a --- /dev/null +++ b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected.md @@ -0,0 +1,3 @@ +%% Cell type:markdown id: tags: + +> This is a test\n>\n> To see if I can duplicate my bug diff --git a/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected_symbols.txt b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected_symbols.txt new file mode 100644 index 00000000000..86a7f6b3960 --- /dev/null +++ b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/expected_symbols.txt @@ -0,0 +1,3 @@ +.cells.0 + +.cells.0.source diff --git a/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/input.ipynb b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/input.ipynb new file mode 100644 index 00000000000..faacc703969 --- /dev/null +++ b/vendor/gems/ipynbdiff/spec/testdata/source_with_linebreak/input.ipynb @@ -0,0 +1,11 @@ +{ + "metadata": { + }, + "cells": [ + { + "cell_type": "markdown", + "source": "> This is a test\n>\n> To see if I can duplicate my bug", + "metadata": {} + } + ] +} diff --git a/vendor/gems/ipynbdiff/spec/transformer_spec.rb b/vendor/gems/ipynbdiff/spec/transformer_spec.rb index 8f9527847fa..31acfe85359 100644 --- a/vendor/gems/ipynbdiff/spec/transformer_spec.rb +++ b/vendor/gems/ipynbdiff/spec/transformer_spec.rb @@ -55,6 +55,7 @@ describe IpynbDiff::Transformer do 'handles backslash correctly' | 'backslash_as_last_char' | {} 'multiline png output' | 'multiline_png_output' | {} 'hides images when option passed' | 'hide_images' | { hide_images: true } + '\n within source lines' | 'source_with_linebreak' | { hide_images: true } end with_them do