Commit 39d5303c authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 2c8f9ab7 4a5bda06
......@@ -31,8 +31,12 @@ class Projects::JobsController < Projects::ApplicationController
@builds
end
@builds = @builds.includes([
{ pipeline: :project },
{ pipeline: [:project, :user] },
:job_artifacts_archive,
:metadata,
:trigger_request,
:project,
:user,
:tags
])
@builds = @builds.page(params[:page]).per(30).without_count
......
......@@ -432,6 +432,24 @@ gitaly_enabled=false
When you run `service gitlab restart` Gitaly will be disabled on this
particular machine.
## Eliminating NFS altogether
If you are planning to use Gitaly without NFS for your storage needs
and want to eliminate NFS from your environment altogether, there are
a few things that you need to do:
1. Make sure the [`git` user home directory](https://docs.gitlab.com/omnibus/settings/configuration.html#moving-the-home-directory-for-a-user) is on local disk.
1. Configure [database lookup of SSH keys](https://docs.gitlab.com/ce/administration/operations/fast_ssh_key_lookup.html)
to eliminate the need for a shared authorized_keys file.
1. Configure [object storage for job artifacts](https://docs.gitlab.com/ce/administration/job_artifacts.html#using-object-storage)
including [live tracing](https://docs.gitlab.com/ce/administration/job_traces.html#new-live-trace-architecture).
1. Configure [object storage for LFS objects](https://docs.gitlab.com/ce/workflow/lfs/lfs_administration.html#storing-lfs-objects-in-remote-object-storage).
1. Configure [object storage for uploads](https://docs.gitlab.com/ce/administration/uploads.html#using-object-storage-core-only).
NOTE: **Note:** One current feature of GitLab still requires a shared directory (NFS): [GitLab Pages](../../user/project/pages/index.md).
There is [work in progress](https://gitlab.com/gitlab-org/gitlab-pages/issues/196)
to eliminate the need for NFS to support GitLab Pages.
## Troubleshooting Gitaly in production
Since GitLab 11.6, Gitaly comes with a command-line tool called
......
......@@ -73,21 +73,27 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
context 'number of queries' do
render_views
before do
Ci::Build::AVAILABLE_STATUSES.each do |status|
create_job(status, status)
end
allow(Appearance).to receive(:current_without_cache)
.and_return(nil)
end
it 'verifies number of queries', :request_store do
recorded = ActiveRecord::QueryRecorder.new { get_index }
expect(recorded.count).to be_within(5).of(7)
expect { get_index }.not_to be_n_plus_1_query.with_threshold(3)
end
def create_job(name, status)
pipeline = create(:ci_pipeline, project: project)
user = create(:user)
pipeline = create(:ci_pipeline, project: project, user: user)
create(:ci_build, :tags, :triggered, :artifacts,
pipeline: pipeline, name: name, status: status)
pipeline: pipeline, name: name, status: status,
user: user)
end
end
......
......@@ -35,5 +35,9 @@ module ActiveRecord
def log_message
@log.join("\n\n")
end
def occurrences
@log.group_by(&:to_s).transform_values(&:count)
end
end
end
# frozen_string_literal: true
module Nplus1QueryHelpers
DEFAULT_THRESHOLD = 3
def with_threshold(threshold)
@threshold = threshold
self
end
def for_query(query)
@query = query
self
end
def threshold
@threshold || DEFAULT_THRESHOLD
end
def occurrences
@occurrences ||=
if @query
recorder.occurrences.select { |recorded, count| recorded =~ @query }
else
recorder.occurrences
end
end
def over_threshold
occurrences.select do |recorded, count|
count > threshold
end
end
def recorder
@recorder ||= ActiveRecord::QueryRecorder.new(&@subject_block)
end
def verify_count(&block)
@subject_block = block
over_threshold.present?
end
def failure_message
log_message = over_threshold.to_yaml
"The following queries are executed more than #{threshold} time(s):\n#{log_message}"
end
end
RSpec::Matchers.define :be_n_plus_1_query do
supports_block_expectations
include Nplus1QueryHelpers
match do |block|
verify_count(&block)
end
failure_message_when_negated do |actual|
failure_message
end
end
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