Skip to content

Commit

Permalink
Add latest changes from gitlab-org/gitlab@master
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab Bot committed Jul 20, 2021
1 parent a84766a commit b212768
Show file tree
Hide file tree
Showing 20 changed files with 236 additions and 55 deletions.
2 changes: 1 addition & 1 deletion GITALY_SERVER_VERSION
@@ -1 +1 @@
b56e0680f4d85505205945c39c01aa641d37bd9b
499b72a41063d61dbb8a73ed7ffa7aa42f1584fd
Expand Up @@ -8,6 +8,7 @@ import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { isLoggedIn } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import getRefMixin from '../mixins/get_ref';
import blobInfoQuery from '../queries/blob_info.query.graphql';
import BlobButtonGroup from './blob_button_group.vue';
import BlobEdit from './blob_edit.vue';
Expand All @@ -21,13 +22,20 @@ export default {
BlobContent,
GlLoadingIcon,
},
mixins: [getRefMixin],
inject: {
originalBranch: {
default: '',
},
},
apollo: {
project: {
query: blobInfoQuery,
variables() {
return {
projectPath: this.projectPath,
filePath: this.path,
ref: this.originalBranch || this.ref,
};
},
result() {
Expand Down
@@ -1,11 +1,11 @@
query getBlobInfo($projectPath: ID!, $filePath: String!) {
query getBlobInfo($projectPath: ID!, $filePath: String!, $ref: String!) {
project(fullPath: $projectPath) {
userPermissions {
pushCode
}
repository {
empty
blobs(paths: [$filePath]) {
blobs(paths: [$filePath], ref: $ref) {
nodes {
webPath
name
Expand Down
2 changes: 1 addition & 1 deletion app/models/application_setting.rb
Expand Up @@ -30,7 +30,7 @@ class ApplicationSetting < ApplicationRecord
def self.kroki_formats_attributes
{
blockdiag: {
label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag)'
label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, and RackDiag)'
},
bpmn: {
label: 'BPMN'
Expand Down
17 changes: 17 additions & 0 deletions app/services/projects/overwrite_project_service.rb
Expand Up @@ -5,6 +5,8 @@ class OverwriteProjectService < BaseService
def execute(source_project)
return unless source_project && source_project.namespace == @project.namespace

start_time = ::Gitlab::Metrics::System.monotonic_time

Project.transaction do
move_before_destroy_relationships(source_project)
# Reset is required in order to get the proper
Expand All @@ -25,10 +27,25 @@ def execute(source_project)
else
raise
end

ensure
track_service(start_time, source_project, e)
end

private

def track_service(start_time, source_project, exception)
return if ::Feature.disabled?(:project_overwrite_service_tracking, source_project, default_enabled: :yaml)

duration = ::Gitlab::Metrics::System.monotonic_time - start_time

Gitlab::AppJsonLogger.info(class: self.class.name,
namespace_id: source_project.namespace.id,
project_id: source_project.id,
duration_s: duration.to_f,
error: exception.class.name)
end

def move_before_destroy_relationships(source_project)
options = { remove_remaining_elements: false }

Expand Down
11 changes: 8 additions & 3 deletions app/views/admin/application_settings/_kroki.html.haml
Expand Up @@ -6,7 +6,8 @@
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _('Allow rendering of diagrams in AsciiDoc and Markdown documents using %{link}.').html_safe % { link: link_to('Kroki', 'https://kroki.io', target: '_blank') }
= _('Users can render diagrams in AsciiDoc, Markdown, reStructuredText, and Textile documents using Kroki.')
= link_to _('Learn more.'), help_page_path('administration/integration/kroki.md'), target: '_blank', rel: 'noopener noreferrer'
.settings-content
= form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-kroki-settings'), html: { class: 'fieldset-form', id: 'kroki-settings' } do |f|
= form_errors(@application_setting) if expanded
Expand All @@ -20,11 +21,15 @@
= f.label :kroki_url, 'Kroki URL', class: 'label-bold'
= f.text_field :kroki_url, class: 'form-control gl-form-input', placeholder: 'http://your-kroki-instance:8000'
.form-text.text-muted
= (_('When Kroki is enabled, GitLab sends diagrams to an instance of Kroki to display them as images. You can use the free public cloud instance %{kroki_public_url} or you can %{install_link} on your own infrastructure. Once you\'ve installed Kroki, make sure to update the server URL to point to your instance.') % { kroki_public_url: '<code>https://kroki.io</code>', install_link: link_to('install Kroki', 'https://docs.kroki.io/kroki/setup/install/', target: '_blank') }).html_safe
- install_link_url = 'https://docs.kroki.io/kroki/setup/install/'
- install_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: install_link_url }
= html_escape(_('Use the public cloud instance URL (%{kroki_public_url}) or %{install_link_start}install Kroki%{install_link_end} on your own infrastructure and use your own instance URL.')) % { kroki_public_url: '<code>https://kroki.io</code>'.html_safe, install_link_start: install_link_start, install_link_end: '</a>'.html_safe }
.form-group
= f.label :kroki_formats, 'Additional diagram formats', class: 'label-bold'
.form-text.text-muted
= (_('Using additional formats requires starting the companion containers. Make sure that all %{kroki_images} are running.') % { kroki_images: link_to('required containers', 'https://docs.kroki.io/kroki/setup/install/#_images', target: '_blank') }).html_safe
- container_link_url = 'https://docs.kroki.io/kroki/setup/install/#images'
- container_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: container_link_url }
= html_escape(_('To use the additional formats, you must start the required %{container_link_start}companion containers%{container_link_end}.')) % { container_link_start: container_link_start, container_link_end: '</a>'.html_safe }
- kroki_available_formats.each do |format|
.form-check
= f.check_box format[:name], class: 'form-check-input'
Expand Down
7 changes: 4 additions & 3 deletions app/views/jira_connect/subscriptions/index.html.haml
Expand Up @@ -24,9 +24,10 @@

%p.jira-connect-app-body.gl-px-5.gl-mt-7.gl-font-base.gl-text-center
%strong= s_('Integrations|Browser limitations')
- firefox_link_url = 'https://www.mozilla.org/en-US/firefox/'
- firefox_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: firefox_link_url }
= s_('Integrations|Adding a namespace works only in browsers that allow cross‑site cookies. Use %{firefox_link_start}Firefox%{firefox_link_end}, or enable cross‑site cookies in your browser, when adding a namespace.').html_safe % { firefox_link_start: firefox_link_start, firefox_link_end: '</a>'.html_safe }
- browser_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'
- firefox_link_start = browser_link_start.html_safe % { url: 'https://www.mozilla.org/en-US/firefox/' }
- chrome_link_start = browser_link_start.html_safe % { url: 'https://www.google.com/chrome/' }
= s_('Integrations|Adding a namespace works only in browsers that allow cross‑site cookies. Use %{firefox_link_start}Firefox%{link_end}, %{chrome_link_start}Google Chrome%{link_end}, or enable cross‑site cookies in your browser, when adding a namespace.').html_safe % { firefox_link_start: firefox_link_start, chrome_link_start: chrome_link_start, link_end: '</a>'.html_safe }
= link_to _('Learn more'), 'https://gitlab.com/gitlab-org/gitlab/-/issues/284211', target: '_blank', rel: 'noopener noreferrer'

= webpack_bundle_tag 'performance_bar' if performance_bar_enabled?
Expand Down
6 changes: 6 additions & 0 deletions config.ru
Expand Up @@ -9,6 +9,12 @@ def master_process?
end

warmup do |app|
# The following is necessary to ensure stale Prometheus metrics don't accumulate over time.
# It needs to be done as early as here to ensure metrics files aren't deleted.
# After we hit our app in `warmup`, first metrics and corresponding files already being created,
# for example in `lib/gitlab/metrics/requests_rack_middleware.rb`.
Prometheus::CleanupMultiprocDirService.new.execute if master_process?

client = Rack::MockRequest.new(app)
client.get('/')
end
Expand Down
@@ -0,0 +1,8 @@
---
name: project_overwrite_service_tracking
introduced_by_url:
rollout_issue_url:
milestone: '14.1'
type: development
group: group::pipeline execution
default_enabled: false
3 changes: 0 additions & 3 deletions config/initializers/7_prometheus_metrics.rb
Expand Up @@ -40,9 +40,6 @@ def prometheus_default_multiproc_dir
# When running Puma in a Single mode, `on_master_start` and `on_worker_start` are the same.
# Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first.
Gitlab::Cluster::LifecycleEvents.on_master_start do
# Ensure that stale Prometheus metrics don't accumulate over time
::Prometheus::CleanupMultiprocDirService.new.execute

::Prometheus::Client.reinitialize_on_pid_change(force: true)

if Gitlab::Runtime.puma?
Expand Down
1 change: 1 addition & 0 deletions doc/.vale/gitlab/spelling-exceptions.txt
Expand Up @@ -128,6 +128,7 @@ CrowdIn
CSV
cybersecurity
Dangerfile
Datadog
datasource
datasources
datetime
Expand Down
63 changes: 41 additions & 22 deletions doc/integration/datadog.md
Expand Up @@ -8,25 +8,44 @@ info: To determine the technical writer assigned to the Stage/Group associated w

> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/270123) in GitLab 14.1
This integration allows sending CI/CD pipeline and job information to [Datadog](https://www.datadoghq.com/) for monitoring and troubleshooting of job failures and performance issues using the [CI Visibility](https://app.datadoghq.com/ci) product.

You can find out more information on [Datadog's CI Visibility documentation site](https://docs.datadoghq.com/continuous_integration/).

## How to configure it

The integration is based on [Webhooks](../user/project/integrations/webhooks.md) and it only requires setup on GitLab.

Configure the integration on a project or group by going to **Settings > Integrations > Datadog** for each project or group you want to instrument. You can also activate the integration for the entire GitLab instance.

Fill in the integration configuration settings:

- `Active` enables the integration.
- `Datadog site` specifies which [Datadog site](https://docs.datadoghq.com/getting_started/site/) to send data to.
- `API URL` (optional) allows overriding the API URL used for sending data directly, only used in advanced scenarios.
- `API key` specifies which API key to use when sending data. You can generate one in the [APIs tab](https://app.datadoghq.com/account/settings#api) of the Integrations section on Datadog.
- `Service` (optional) specifies which service name to attach to each span generated by the integration. Use this to differentiate between GitLab instances.
- `Env` (optional) specifies which environment (`env` tag) to attach to each span generated by the integration. Use this to differentiate between groups of GitLab instances (i.e. staging vs production).

You can test the integration with the `Test settings` button. After it’s successful, click `Save changes` to finish the integration set up.

Data sent by the integration will be available in the [CI Visibility](https://app.datadoghq.com/ci) section of your Datadog account.
This integration enables you to send CI/CD pipeline and job information to
[Datadog](https://www.datadoghq.com/). Datadog's [CI Visibility](https://app.datadoghq.com/ci)
product helps you monitor for job failures and performance issues, then troubleshoot them.
It's based on [Webhooks](../user/project/integrations/webhooks.md),
and only requires configuration on GitLab.

## Configure the integration

Users with the **Administrator** role can configure the integration at the
project, group, or instance level:

1. If you do not have a Datadog API key:
1. Sign in to Datadog.
1. Go to the **Integrations** section.
1. Generate an API key in the [APIs tab](https://app.datadoghq.com/account/settings#api).
Copy this value, as you need it in a later step.
1. *For project-level or group-level integrations:* In GitLab, go to your project or group.
1. *For instance-level integrations:*
1. Sign in to GitLab as a user with the [Administrator role](../user/permissions.md).
1. On the top bar, select **Menu >** **{admin}** **Admin**.
1. In the left sidebar, select **Settings > Integrations**.
1. Scroll to **Add an integration**, and select **Datadog**.
1. Select **Active** to enable the integration.
1. Specify the [**Datadog site**](https://docs.datadoghq.com/getting_started/site/) to send data to.
1. (Optional) To override the API URL used to send data directly, provide an **API URL**.
Used only in advanced scenarios.
1. Provide your Datadog **API key**.
1. (Optional) If you use more than one GitLab instance, provide a unique **Service** name
to differentiate between your GitLab instances.
1. (Optional) If you use groups of GitLab instances (such as staging and production
environments), provide an **Env** name. This value is attached to each span
the integration generates.
1. (Optional) Select **Test settings** to test your integration.
1. Select **Save changes**.

When the integration sends data, you can view it in the [CI Visibility](https://app.datadoghq.com/ci)
section of your Datadog account.

## Related links

- [Datadog's CI Visibility](https://docs.datadoghq.com/continuous_integration/) documentation.
1 change: 1 addition & 0 deletions doc/integration/index.md
Expand Up @@ -49,6 +49,7 @@ GitLab has integrated with several security partners. For more information, see
GitLab can be integrated with the following external service for continuous integration:

- [Jenkins](jenkins.md) CI.
- [Datadog](datadog.md), to monitor for CI/CD job failures and performance issues.

## Feature enhancements

Expand Down
2 changes: 1 addition & 1 deletion doc/integration/jira/connect-app.md
Expand Up @@ -130,4 +130,4 @@ The GitLab.com for Jira Cloud app uses an iframe to add namespaces on the settin

> "You need to sign in or sign up before continuing."
In this case, use [Firefox](https://www.mozilla.org/en-US/firefox/) or enable cross-site cookies in your browser.
In this case, use [Firefox](https://www.mozilla.org/en-US/firefox/), [Google Chrome](https://www.google.com/chrome/), or enable cross-site cookies in your browser.
4 changes: 2 additions & 2 deletions lib/api/internal/base.rb
Expand Up @@ -165,9 +165,9 @@ def with_admin_mode_bypass!(actor_id)
# Check whether an SSH key is known to GitLab
#
get '/authorized_keys', feature_category: :source_code_management do
fingerprint = Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
fingerprint = Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint_sha256

key = Key.find_by_fingerprint(fingerprint)
key = Key.find_by_fingerprint_sha256(fingerprint)
not_found!('Key') if key.nil?
present key, with: Entities::SSHKey
end
Expand Down
15 changes: 11 additions & 4 deletions lib/gitlab/usage/metrics/instrumentations/generic_metric.rb
Expand Up @@ -12,19 +12,26 @@ class GenericMetric < BaseMetric
# Gitlab::CurrentSettings.uuid
# end
# end
FALLBACK = -1

class << self
attr_reader :metric_operation
attr_reader :metric_operation, :metric_value

@metric_operation = :alt

def fallback(custom_fallback = FALLBACK)
return @metric_fallback if defined?(@metric_fallback)

@metric_fallback = custom_fallback
end

def value(&block)
@metric_value = block
end

attr_reader :metric_value
end

def value
alt_usage_data do
alt_usage_data(fallback: self.class.fallback) do
self.class.metric_value.call
end
end
Expand Down
20 changes: 10 additions & 10 deletions locale/gitlab.pot
Expand Up @@ -3339,9 +3339,6 @@ msgstr ""
msgid "Allow rendering of PlantUML diagrams in Asciidoc documents."
msgstr ""

msgid "Allow rendering of diagrams in AsciiDoc and Markdown documents using %{link}."
msgstr ""

msgid "Allow requests to the local network from hooks and services."
msgstr ""

Expand Down Expand Up @@ -17572,7 +17569,7 @@ msgstr ""
msgid "Integrations|Add namespace"
msgstr ""

msgid "Integrations|Adding a namespace works only in browsers that allow cross‑site cookies. Use %{firefox_link_start}Firefox%{firefox_link_end}, or enable cross‑site cookies in your browser, when adding a namespace."
msgid "Integrations|Adding a namespace works only in browsers that allow cross‑site cookies. Use %{firefox_link_start}Firefox%{link_end}, %{chrome_link_start}Google Chrome%{link_end}, or enable cross‑site cookies in your browser, when adding a namespace."
msgstr ""

msgid "Integrations|All details"
Expand Down Expand Up @@ -34324,6 +34321,9 @@ msgstr ""
msgid "To use Gitpod you must first enable the feature in the integrations section of your %{user_prefs}."
msgstr ""

msgid "To use the additional formats, you must start the required %{container_link_start}companion containers%{container_link_end}."
msgstr ""

msgid "To view all %{scannedResourcesCount} scanned URLs, %{linkStart}please download the CSV file%{linkEnd}"
msgstr ""

Expand Down Expand Up @@ -35559,6 +35559,9 @@ msgstr ""
msgid "Use the link below to confirm your email address."
msgstr ""

msgid "Use the public cloud instance URL (%{kroki_public_url}) or %{install_link_start}install Kroki%{install_link_end} on your own infrastructure and use your own instance URL."
msgstr ""

msgid "Use the search bar on the top of this page"
msgstr ""

Expand Down Expand Up @@ -35898,6 +35901,9 @@ msgstr ""
msgid "Users can launch a development environment from a GitLab browser tab when the %{linkStart}Gitpod%{linkEnd} integration is enabled."
msgstr ""

msgid "Users can render diagrams in AsciiDoc, Markdown, reStructuredText, and Textile documents using Kroki."
msgstr ""

msgid "Users in License"
msgstr ""

Expand Down Expand Up @@ -35934,9 +35940,6 @@ msgstr ""
msgid "Using %{code_start}::%{code_end} denotes a %{link_start}scoped label set%{link_end}"
msgstr ""

msgid "Using additional formats requires starting the companion containers. Make sure that all %{kroki_images} are running."
msgstr ""

msgid "Using required encryption strategy when encrypted field is missing!"
msgstr ""

Expand Down Expand Up @@ -36880,9 +36883,6 @@ msgstr ""
msgid "What’s your experience level?"
msgstr ""

msgid "When Kroki is enabled, GitLab sends diagrams to an instance of Kroki to display them as images. You can use the free public cloud instance %{kroki_public_url} or you can %{install_link} on your own infrastructure. Once you've installed Kroki, make sure to update the server URL to point to your instance."
msgstr ""

msgid "When a deployment job is successful, skip older deployment jobs that are still pending."
msgstr ""

Expand Down

0 comments on commit b212768

Please sign in to comment.