Commit 04750438 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 497e898831d3
......@@ -67,7 +67,7 @@ export default {
'setShowErrorBanner',
]),
chartHasData(chart) {
return chart.metrics.some(metric => this.metricsWithData().includes(metric.metric_id));
return chart.metrics.some(metric => this.metricsWithData().includes(metric.metricId));
},
onSidebarMutation() {
setTimeout(() => {
......
......@@ -13,11 +13,12 @@ export const gqClient = createGqClient(
/**
* Metrics loaded from project-defined dashboards do not have a metric_id.
* This method creates a unique ID combining metric_id and id, if either is present.
* This is hopefully a temporary solution until BE processes metrics before passing to fE
* This is hopefully a temporary solution until BE processes metrics before passing to FE
* @param {Object} metric - metric
* @returns {Object} - normalized metric with a uniqueID
*/
export const uniqMetricsId = metric => `${metric.metric_id}_${metric.id}`;
// eslint-disable-next-line babel/camelcase
export const uniqMetricsId = ({ metric_id, id }) => `${metric_id}_${id}`;
/**
* Project path has a leading slash that doesn't work well
......@@ -68,10 +69,6 @@ const mapToMetricsViewModel = (metrics, defaultLabel) =>
queryRange: query_range,
prometheusEndpointPath: prometheus_endpoint_path,
metricId: uniqMetricsId({ metric_id, id }),
// `metric_id` is used by embed.vue, keeping this duplicated.
// https://gitlab.com/gitlab-org/gitlab/issues/37492
metric_id: uniqMetricsId({ metric_id, id }),
...metric,
}));
......
......@@ -48,7 +48,7 @@ def k8s_params
end
def elasticsearch_params
params.permit(:container_name, :pod_name, :search, :start, :end)
params.permit(:container_name, :pod_name, :search, :start, :end, :cursor)
end
def environment
......
......@@ -77,7 +77,7 @@ class Issue < ApplicationRecord
scope :counts_by_state, -> { reorder(nil).group(:state_id).count }
ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22'
ignore_column :state, remove_with: '12.10', remove_after: '2020-03-22'
after_commit :expire_etag_cache, unless: :importing?
after_save :ensure_metrics, unless: :importing?
......
......@@ -261,7 +261,7 @@ def check_state?(merge_status)
includes(:metrics)
end
ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22'
ignore_column :state, remove_with: '12.10', remove_after: '2020-03-22'
after_save :keep_around_commit, unless: :importing?
......
......@@ -280,21 +280,17 @@ def send_message(issue, message, remote_link_props)
return unless client_url.present?
jira_request do
create_issue_link(issue, remote_link_props)
create_issue_comment(issue, message)
remote_link = find_remote_link(issue, remote_link_props[:object][:url])
create_issue_comment(issue, message) unless remote_link
remote_link ||= issue.remotelink.build
remote_link.save!(remote_link_props)
log_info("Successfully posted", client_url: client_url)
"SUCCESS: Successfully posted to #{client_url}."
end
end
def create_issue_link(issue, remote_link_props)
remote_link = find_remote_link(issue, remote_link_props[:object][:url])
remote_link ||= issue.remotelink.build
remote_link.save!(remote_link_props)
end
def create_issue_comment(issue, message)
return unless comment_on_event_enabled
......
......@@ -2,6 +2,7 @@
class X509Certificate < ApplicationRecord
include X509SerialNumberAttribute
include AfterCommitQueue
x509_serial_number_attribute :serial_number
......@@ -25,8 +26,14 @@ class X509Certificate < ApplicationRecord
validates :x509_issuer_id, presence: true
after_commit :mark_commit_signatures_unverified
def self.safe_create!(attributes)
create_with(attributes)
.safe_find_or_create_by!(subject_key_identifier: attributes[:subject_key_identifier])
end
def mark_commit_signatures_unverified
X509CertificateRevokeWorker.perform_async(self.id) if revoked?
end
end
......@@ -10,8 +10,6 @@ class BaseService < ::BaseService
CACHE_KEY_GET_POD_LOG = 'get_pod_log'
K8S_NAME_MAX_LENGTH = 253
SUCCESS_RETURN_KEYS = %i(status logs pod_name container_name pods).freeze
def id
cluster.id
end
......@@ -49,6 +47,10 @@ def valid_params
%w(pod_name container_name)
end
def success_return_keys
%i(status logs pod_name container_name pods)
end
def check_arguments(result)
return error(_('Cluster does not exist')) if cluster.nil?
return error(_('Namespace is empty')) if namespace.blank?
......@@ -122,7 +124,7 @@ def pod_logs(result)
end
def filter_return_keys(result)
result.slice(*SUCCESS_RETURN_KEYS)
result.slice(*success_return_keys)
end
def filter_params(params)
......
......@@ -10,6 +10,7 @@ class ElasticsearchService < PodLogs::BaseService
:check_container_name,
:check_times,
:check_search,
:check_cursor,
:pod_logs,
:filter_return_keys
......@@ -18,7 +19,11 @@ class ElasticsearchService < PodLogs::BaseService
private
def valid_params
%w(pod_name container_name search start end)
super + %w(search start end cursor)
end
def success_return_keys
super + %i(cursor)
end
def check_times(result)
......@@ -36,19 +41,28 @@ def check_search(result)
success(result)
end
def check_cursor(result)
result[:cursor] = params['cursor'] if params.key?('cursor')
success(result)
end
def pod_logs(result)
client = cluster&.application_elastic_stack&.elasticsearch_client
return error(_('Unable to connect to Elasticsearch')) unless client
result[:logs] = ::Gitlab::Elasticsearch::Logs.new(client).pod_logs(
response = ::Gitlab::Elasticsearch::Logs.new(client).pod_logs(
namespace,
result[:pod_name],
result[:container_name],
result[:search],
result[:start],
result[:end]
container_name: result[:container_name],
search: result[:search],
start_time: result[:start],
end_time: result[:end],
cursor: result[:cursor]
)
result.merge!(response)
success(result)
rescue Elasticsearch::Transport::Transport::ServerError => e
::Gitlab::ErrorTracking.track_exception(e)
......@@ -58,6 +72,8 @@ def pod_logs(result)
# there is no method on the exception other than the class name to determine the type of error encountered.
status_code: e.class.name.split('::').last
})
rescue ::Gitlab::Elasticsearch::Logs::InvalidCursor
error(_('Invalid cursor value provided'))
end
end
end
......@@ -5,19 +5,12 @@ class UpdateRepositoryStorageService < BaseService
include Gitlab::ShellAdapter
Error = Class.new(StandardError)
RepositoryAlreadyMoved = Class.new(StandardError)
def initialize(project)
@project = project
end
def execute(new_repository_storage_key)
# Raising an exception is a little heavy handed but this behavior (doing
# nothing if the repo is already on the right storage) prevents data
# loss, so it is valuable for us to be able to observe it via the
# exception.
raise RepositoryAlreadyMoved if project.repository_storage == new_repository_storage_key
mirror_repositories(new_repository_storage_key)
mark_old_paths_for_archive
......@@ -30,7 +23,7 @@ def execute(new_repository_storage_key)
success
rescue Error => e
rescue Error, ArgumentError, Gitlab::Git::BaseError => e
project.update(repository_read_only: false)
Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path)
......@@ -65,10 +58,7 @@ def mirror_repository(new_storage_key, type: Gitlab::GlRepository::PROJECT)
raw_repository.gl_repository,
full_path)
unless new_repository.fetch_repository_as_mirror(raw_repository)
raise Error, s_('UpdateRepositoryStorage|Failed to fetch %{type} repository as mirror') % { type: type.name }
end
new_repository.replicate(raw_repository)
new_checksum = new_repository.checksum
if checksum != new_checksum
......
# frozen_string_literal: true
class X509CertificateRevokeService
def execute(certificate)
return unless certificate.revoked?
certificate.x509_commit_signatures.update_all(verification_status: :unverified)
end
end
......@@ -11,4 +11,15 @@ class AttachmentUploader < GitlabUploader
def dynamic_segment
File.join(model.class.underscore, mounted_as.to_s, model.id.to_s)
end
def mounted_as
# Geo fails to sync attachments on Note, and LegacyDiffNotes with missing mount_point.
#
# See https://gitlab.com/gitlab-org/gitlab/-/issues/209752 for more details.
if model.class.underscore.include?('note')
super || 'attachment'
else
super
end
end
end
.gpg-popover-certificate-details
%strong= _('Certificate Subject')
- if signature.x509_certificate.revoked?
%strong.cred= _('(revoked)')
%ul
- x509_subject(signature.x509_certificate.subject, ["CN", "O"]).map do |key, value|
%li= key + "=" + value
......
......@@ -1291,3 +1291,10 @@
:resource_boundary: :unknown
:weight: 1
:idempotent:
- :name: x509_certificate_revoke
:feature_category: :source_code_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent: true
......@@ -9,7 +9,5 @@ def perform(project_id, new_repository_storage_key)
project = Project.find(project_id)
::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key)
rescue ::Projects::UpdateRepositoryStorageService::RepositoryAlreadyMoved
Rails.logger.info "#{self.class}: repository already moved: #{project}" # rubocop:disable Gitlab/RailsLogger
end
end
# frozen_string_literal: true
class X509CertificateRevokeWorker
include ApplicationWorker
feature_category :source_code_management
idempotent!
def perform(certificate_id)
return unless certificate_id
X509Certificate.find_by_id(certificate_id).try do |certificate|
X509CertificateRevokeService.new.execute(certificate)
end
end
end
---
title: Migrate mentions for commit notes to commit_user_mentions DB table
merge_request: 23859
author:
type: changed
---
title: Ensure valid mount point is used by attachments on notes
merge_request: 26849
author:
type: fixed
---
title: Generate JSON-formatted a11y CI artifacts
merge_request: 26687
author:
type: added
---
title: Remove state column from issues and merge_requests
merge_request: 25561
author:
type: deprecated
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment