Commit 73391dcc authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent a7df1d87
...@@ -177,7 +177,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -177,7 +177,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
message << _("Create a GitLab account first, and then connect it to your %{label} account.") % { label: label } message << _("Create a GitLab account first, and then connect it to your %{label} account.") % { label: label }
end end
flash[:notice] = message.join(' ') flash[:alert] = message.join(' ')
redirect_to new_user_session_path redirect_to new_user_session_path
end end
......
---
title: Log database time in Sidekiq JSON logs
merge_request: 22548
author:
type: other
---
title: Show regular rules without approvers
merge_request: 21918
author:
type: fixed
---
title: Expose issue link type in REST API
merge_request: 21375
author:
type: added
---
title: "Prevent omniauth signup redirect loop"
merge_request: 22432
author: Balazs Nagy
type: fixed
---
title: Update set-value from 2.0.0 to 2.0.1
merge_request: 22366
author: Takuya Noguchi
type: security
...@@ -249,7 +249,7 @@ Instead of the format above, you can opt to generate JSON logs for ...@@ -249,7 +249,7 @@ Instead of the format above, you can opt to generate JSON logs for
Sidekiq. For example: Sidekiq. For example:
```json ```json
{"severity":"INFO","time":"2018-04-03T22:57:22.071Z","queue":"cronjob:update_all_mirrors","args":[],"class":"UpdateAllMirrorsWorker","retry":false,"queue_namespace":"cronjob","jid":"06aeaa3b0aadacf9981f368e","created_at":"2018-04-03T22:57:21.930Z","enqueued_at":"2018-04-03T22:57:21.931Z","pid":10077,"message":"UpdateAllMirrorsWorker JID-06aeaa3b0aadacf9981f368e: done: 0.139 sec","job_status":"done","duration":0.139,"completed_at":"2018-04-03T22:57:22.071Z"} {"severity":"INFO","time":"2018-04-03T22:57:22.071Z","queue":"cronjob:update_all_mirrors","args":[],"class":"UpdateAllMirrorsWorker","retry":false,"queue_namespace":"cronjob","jid":"06aeaa3b0aadacf9981f368e","created_at":"2018-04-03T22:57:21.930Z","enqueued_at":"2018-04-03T22:57:21.931Z","pid":10077,"message":"UpdateAllMirrorsWorker JID-06aeaa3b0aadacf9981f368e: done: 0.139 sec","job_status":"done","duration":0.139,"completed_at":"2018-04-03T22:57:22.071Z","db_duration":0.05,"db_duration_s":0.0005,"gitaly_duration":0,"gitaly_calls":0}
``` ```
For Omnibus GitLab installations, add the configuration option: For Omnibus GitLab installations, add the configuration option:
......
...@@ -196,7 +196,7 @@ is a Unicorn worker that is spinning via `top`. Try to use the `gdb` ...@@ -196,7 +196,7 @@ is a Unicorn worker that is spinning via `top`. Try to use the `gdb`
techniques above. In addition, using `strace` may help isolate issues: techniques above. In addition, using `strace` may help isolate issues:
```shell ```shell
strace -tt -T -f -s 1024 -p <PID of unicorn worker> -o /tmp/unicorn.txt strace -ttTfyyy -s 1024 -p <PID of unicorn worker> -o /tmp/unicorn.txt
``` ```
If you cannot isolate which Unicorn worker is the issue, try to run `strace` If you cannot isolate which Unicorn worker is the issue, try to run `strace`
...@@ -204,7 +204,7 @@ on all the Unicorn workers to see where the `/internal/allowed` endpoint gets ...@@ -204,7 +204,7 @@ on all the Unicorn workers to see where the `/internal/allowed` endpoint gets
stuck: stuck:
```shell ```shell
ps auwx | grep unicorn | awk '{ print " -p " $2}' | xargs strace -tt -T -f -s 1024 -o /tmp/unicorn.txt ps auwx | grep unicorn | awk '{ print " -p " $2}' | xargs strace -ttTfyyy -s 1024 -o /tmp/unicorn.txt
``` ```
The output in `/tmp/unicorn.txt` may help diagnose the root cause. The output in `/tmp/unicorn.txt` may help diagnose the root cause.
......
...@@ -48,6 +48,7 @@ Parameters: ...@@ -48,6 +48,7 @@ Parameters:
"web_url": "http://example.com/example/example/issues/14", "web_url": "http://example.com/example/example/issues/14",
"confidential": false, "confidential": false,
"weight": null, "weight": null,
"link_type": "relates_to"
} }
] ]
``` ```
...@@ -66,6 +67,7 @@ POST /projects/:id/issues/:issue_iid/links ...@@ -66,6 +67,7 @@ POST /projects/:id/issues/:issue_iid/links
| `issue_iid` | integer | yes | The internal ID of a project's issue | | `issue_iid` | integer | yes | The internal ID of a project's issue |
| `target_project_id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) of a target project | | `target_project_id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) of a target project |
| `target_issue_iid` | integer/string | yes | The internal ID of a target project's issue | | `target_issue_iid` | integer/string | yes | The internal ID of a target project's issue |
| `link_type` | string | no | The type of the relation ("relates_to", "blocks", "is_blocked_by"), defaults to "relates_to"). Ignored unless `issue_link_types` feature flag is enabled. |
```bash ```bash
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues/1/links?target_project_id=5&target_issue_iid=1" curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues/1/links?target_project_id=5&target_issue_iid=1"
...@@ -134,7 +136,8 @@ Example response: ...@@ -134,7 +136,8 @@ Example response:
"web_url": "http://example.com/example/example/issues/14", "web_url": "http://example.com/example/example/issues/14",
"confidential": false, "confidential": false,
"weight": null, "weight": null,
} },
"link_type": "relates_to"
} }
``` ```
...@@ -151,6 +154,7 @@ DELETE /projects/:id/issues/:issue_iid/links/:issue_link_id ...@@ -151,6 +154,7 @@ DELETE /projects/:id/issues/:issue_iid/links/:issue_link_id
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user |
| `issue_iid` | integer | yes | The internal ID of a project's issue | | `issue_iid` | integer | yes | The internal ID of a project's issue |
| `issue_link_id` | integer/string | yes | The ID of an issue relationship | | `issue_link_id` | integer/string | yes | The ID of an issue relationship |
| `link_type` | string | no | The type of the relation ('relates_to', 'blocks', 'is_blocked_by'), defaults to 'relates_to' |
```json ```json
{ {
...@@ -213,6 +217,7 @@ DELETE /projects/:id/issues/:issue_iid/links/:issue_link_id ...@@ -213,6 +217,7 @@ DELETE /projects/:id/issues/:issue_iid/links/:issue_link_id
"web_url": "http://example.com/example/example/issues/14", "web_url": "http://example.com/example/example/issues/14",
"confidential": false, "confidential": false,
"weight": null, "weight": null,
} },
"link_type": "relates_to"
} }
``` ```
# frozen_string_literal: true # frozen_string_literal: true
require 'active_record'
require 'active_record/log_subscriber'
module Gitlab module Gitlab
module SidekiqLogging module SidekiqLogging
class StructuredLogger class StructuredLogger
...@@ -10,6 +13,7 @@ module Gitlab ...@@ -10,6 +13,7 @@ module Gitlab
def call(job, queue) def call(job, queue)
started_time = get_time started_time = get_time
base_payload = parse_job(job) base_payload = parse_job(job)
ActiveRecord::LogSubscriber.reset_runtime
Sidekiq.logger.info log_job_start(base_payload) Sidekiq.logger.info log_job_start(base_payload)
...@@ -63,6 +67,9 @@ module Gitlab ...@@ -63,6 +67,9 @@ module Gitlab
convert_to_iso8601(payload, DONE_TIMESTAMP_FIELDS) convert_to_iso8601(payload, DONE_TIMESTAMP_FIELDS)
payload['db_duration'] = ActiveRecord::LogSubscriber.runtime
payload['db_duration_s'] = payload['db_duration'] / 1000
payload payload
end end
......
...@@ -287,6 +287,34 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode: ...@@ -287,6 +287,34 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode:
request.env['omniauth.auth'] = Rails.application.env_config['omniauth.auth'] request.env['omniauth.auth'] = Rails.application.env_config['omniauth.auth']
end end
context 'sign up' do
before do
user.destroy
end
it 'denies login if sign up is enabled, but block_auto_created_users is set' do
post :saml, params: { SAMLResponse: mock_saml_response }
expect(flash[:alert]).to start_with 'Your account has been blocked.'
end
it 'accepts login if sign up is enabled' do
stub_omniauth_setting(block_auto_created_users: false)
post :saml, params: { SAMLResponse: mock_saml_response }
expect(request.env['warden']).to be_authenticated
end
it 'denies login if sign up is not enabled' do
stub_omniauth_setting(allow_single_sign_on: false, block_auto_created_users: false)
post :saml, params: { SAMLResponse: mock_saml_response }
expect(flash[:alert]).to start_with 'Signing in using your saml account without a pre-existing GitLab account is not allowed.'
end
end
context 'with GitLab initiated request' do context 'with GitLab initiated request' do
before do before do
post :saml, params: { SAMLResponse: mock_saml_response } post :saml, params: { SAMLResponse: mock_saml_response }
......
...@@ -25,7 +25,7 @@ describe('Diff settiings dropdown component', () => { ...@@ -25,7 +25,7 @@ describe('Diff settiings dropdown component', () => {
extendStore(store); extendStore(store);
vm = mount(localVue.extend(SettingsDropdown), { vm = mount(SettingsDropdown, {
localVue, localVue,
store, store,
sync: false, sync: false,
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import searchComponent from '~/frequent_items/components/frequent_items_search_input.vue'; import searchComponent from '~/frequent_items/components/frequent_items_search_input.vue';
import eventHub from '~/frequent_items/event_hub'; import eventHub from '~/frequent_items/event_hub';
const localVue = createLocalVue();
const createComponent = (namespace = 'projects') => const createComponent = (namespace = 'projects') =>
shallowMount(localVue.extend(searchComponent), { shallowMount(searchComponent, {
propsData: { namespace }, propsData: { namespace },
localVue,
sync: false, sync: false,
}); });
...@@ -42,7 +39,7 @@ describe('FrequentItemsSearchInputComponent', () => { ...@@ -42,7 +39,7 @@ describe('FrequentItemsSearchInputComponent', () => {
jest.spyOn(eventHub, '$on').mockImplementation(() => {}); jest.spyOn(eventHub, '$on').mockImplementation(() => {});
const vmX = createComponent().vm; const vmX = createComponent().vm;
localVue.nextTick(() => { vmX.$nextTick(() => {
expect(eventHub.$on).toHaveBeenCalledWith( expect(eventHub.$on).toHaveBeenCalledWith(
`${vmX.namespace}-dropdownOpen`, `${vmX.namespace}-dropdownOpen`,
expect.any(Function), expect.any(Function),
...@@ -60,7 +57,7 @@ describe('FrequentItemsSearchInputComponent', () => { ...@@ -60,7 +57,7 @@ describe('FrequentItemsSearchInputComponent', () => {
vmX.$mount(); vmX.$mount();
vmX.$destroy(); vmX.$destroy();
localVue.nextTick(() => { vmX.$nextTick(() => {
expect(eventHub.$off).toHaveBeenCalledWith( expect(eventHub.$off).toHaveBeenCalledWith(
`${vmX.namespace}-dropdownOpen`, `${vmX.namespace}-dropdownOpen`,
expect.any(Function), expect.any(Function),
......
# frozen_string_literal: true # frozen_string_literal: true
require 'fast_spec_helper' require 'spec_helper'
describe Gitlab::SidekiqLogging::StructuredLogger do describe Gitlab::SidekiqLogging::StructuredLogger do
describe '#call' do describe '#call' do
...@@ -40,8 +40,10 @@ describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -40,8 +40,10 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec', 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec',
'job_status' => 'done', 'job_status' => 'done',
'duration' => 0.0, 'duration' => 0.0,
"completed_at" => timestamp.iso8601(3), 'completed_at' => timestamp.iso8601(3),
"cpu_s" => 1.111112 'cpu_s' => 1.111112,
'db_duration' => 0,
'db_duration_s' => 0
) )
end end
let(:exception_payload) do let(:exception_payload) do
...@@ -183,6 +185,43 @@ describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -183,6 +185,43 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
end end
end end
end end
context 'when the job performs database queries' do
before do
allow(Time).to receive(:now).and_return(timestamp)
allow(Process).to receive(:clock_gettime).and_call_original
end
let(:expected_start_payload) { start_payload.except('args') }
let(:expected_end_payload) do
end_payload.except('args').merge('cpu_s' => a_value > 0)
end
let(:expected_end_payload_with_db) do
expected_end_payload.merge(
'db_duration' => a_value >= 100,
'db_duration_s' => a_value >= 0.1
)
end
it 'logs the database time' do
expect(logger).to receive(:info).with(expected_start_payload).ordered
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
subject.call(job, 'test_queue') { ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') }
end
it 'prevents database time from leaking to the next job' do
expect(logger).to receive(:info).with(expected_start_payload).ordered
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
expect(logger).to receive(:info).with(expected_start_payload).ordered
expect(logger).to receive(:info).with(expected_end_payload).ordered
subject.call(job, 'test_queue') { ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') }
subject.call(job, 'test_queue') { }
end
end
end end
describe '#add_time_keys!' do describe '#add_time_keys!' do
......
...@@ -6118,7 +6118,7 @@ is-plain-obj@^1.1.0: ...@@ -6118,7 +6118,7 @@ is-plain-obj@^1.1.0:
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: is-plain-object@^2.0.3, is-plain-object@^2.0.4:
version "2.0.4" version "2.0.4"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==
...@@ -10076,20 +10076,10 @@ set-blocking@^2.0.0, set-blocking@~2.0.0: ...@@ -10076,20 +10076,10 @@ set-blocking@^2.0.0, set-blocking@~2.0.0:
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
set-value@^0.4.3: set-value@^2.0.0, set-value@^2.0.1:
version "0.4.3" version "2.0.1"
resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b"
integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==
dependencies:
extend-shallow "^2.0.1"
is-extendable "^0.1.1"
is-plain-object "^2.0.1"
to-object-path "^0.3.0"
set-value@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274"
integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==
dependencies: dependencies:
extend-shallow "^2.0.1" extend-shallow "^2.0.1"
is-extendable "^0.1.1" is-extendable "^0.1.1"
...@@ -11349,14 +11339,14 @@ unified@^7.0.0: ...@@ -11349,14 +11339,14 @@ unified@^7.0.0:
x-is-string "^0.1.0" x-is-string "^0.1.0"
union-value@^1.0.0: union-value@^1.0.0:
version "1.0.0" version "1.0.1"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"
integrity sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ= integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==
dependencies: dependencies:
arr-union "^3.1.0" arr-union "^3.1.0"
get-value "^2.0.6" get-value "^2.0.6"
is-extendable "^0.1.1" is-extendable "^0.1.1"
set-value "^0.4.3" set-value "^2.0.1"
uniq@^1.0.1: uniq@^1.0.1:
version "1.0.1" version "1.0.1"
......
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