Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-11-08 09:10:05 +00:00
parent 93ea45e25a
commit 4901ff1764
7 changed files with 67 additions and 54 deletions

View File

@ -45,7 +45,7 @@ module Projects
if namespace_id
# Find matching namespace and check if it allowed
# for current user if namespace_id passed.
unless current_user.can?(:create_projects, project_namespace)
unless current_user.can?(:create_projects, parent_namespace)
@project.namespace_id = nil
deny_namespace
return @project
@ -227,14 +227,14 @@ module Projects
def extra_attributes_for_measurement
{
current_user: current_user&.name,
project_full_path: "#{project_namespace&.full_path}/#{@params[:path]}"
project_full_path: "#{parent_namespace&.full_path}/#{@params[:path]}"
}
end
private
def project_namespace
@project_namespace ||= Namespace.find_by_id(@params[:namespace_id]) || current_user.namespace
def parent_namespace
@parent_namespace ||= Namespace.find_by_id(@params[:namespace_id]) || current_user.namespace
end
def create_from_template?

View File

@ -1,8 +0,0 @@
---
name: linear_application_setting_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70579
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341346
milestone: '14.4'
type: development
group: group::access
default_enabled: false

View File

@ -93,6 +93,27 @@ is moved to NFS.
We are investigating the use of
[fast lookup as the default](https://gitlab.com/groups/gitlab-org/-/epics/3104).
## Improving NFS performance with GitLab
NFS performance with GitLab can in some cases be improved with
[direct Git access](gitaly/index.md#direct-access-to-git-in-gitlab) using
[Rugged](https://github.com/libgit2/rugged).
From GitLab 12.1, GitLab automatically detects if Rugged can and should be used per storage.
If you previously enabled Rugged using the feature flag and you want to use automatic detection instead,
you must unset the feature flag:
```shell
sudo gitlab-rake gitlab:features:unset_rugged
```
If the Rugged feature flag is explicitly set to either `true` or `false`, GitLab uses the value explicitly set.
From GitLab 12.7, Rugged is only automatically enabled for use with Puma
if the [Puma thread count is set to `1`](../install/requirements.md#puma-settings).
To use Rugged with a Puma thread count of more than `1`, enable Rugged using the [feature flag](../development/gitaly.md#legacy-rugged-code).
## NFS server
Installing the `nfs-kernel-server` package allows you to share directories with
@ -165,32 +186,6 @@ You may not need to disable NFS server delegation if you know you are using a ve
the Linux kernel that has been fixed. That said, GitLab still encourages instance
administrators to keep NFS server delegation disabled.
### Improving NFS performance with GitLab
NFS performance with GitLab can in some cases be improved with
[direct Git access](gitaly/index.md#direct-access-to-git-in-gitlab) using
[Rugged](https://github.com/libgit2/rugged).
NOTE:
From GitLab 12.1, it automatically detects if Rugged can and should be used per storage.
If you previously enabled Rugged using the feature flag, you need to unset the feature flag by using:
```shell
sudo gitlab-rake gitlab:features:unset_rugged
```
If the Rugged feature flag is explicitly set to either `true` or `false`, GitLab uses the value explicitly set.
#### Improving NFS performance with Puma
NOTE:
From GitLab 12.7, Rugged is not automatically enabled if Puma thread count is greater than `1`.
If you want to use Rugged with Puma, [set Puma thread count to `1`](../install/requirements.md#puma-settings).
If you want to use Rugged with Puma thread count more than `1`, Rugged can be enabled using the [feature flag](../development/gitaly.md#legacy-rugged-code).
## NFS client
The `nfs-common` provides NFS functionality without installing server components which
@ -232,7 +227,7 @@ Note there are several options that you should consider using:
It's recommended that you use `hard` in your mount options, unless you have a specific
reason to use `soft`.
On GitLab.com, we use `soft` because there were times when we had NFS servers
When GitLab.com used NFS, we used `soft` because there were times when we had NFS servers
reboot and `soft` improved availability, but everyone's infrastructure is different.
If your NFS is provided by on-premise storage arrays with redundant controllers,
for example, you shouldn't need to worry about NFS server availability.

View File

@ -197,18 +197,28 @@ tier:
The GitLab codebase provides a dedicated [generator](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb) to create new metric definitions.
For uniqueness, the generated file includes a timestamp prefix, in ISO 8601 format.
For uniqueness, the generated files include a timestamp prefix in ISO 8601 format.
The generator takes the key path argument and 2 options and creates the metric YAML definition in corresponding location:
The generator takes a list of key paths and 2 options as arguments. It creates metric YAML definitions in the corresponding location:
- `--ee`, `--no-ee` Indicates if metric is for EE.
- `--dir=DIR` indicates the metric directory. It must be one of: `counts_7d`, `7d`, `counts_28d`, `28d`, `counts_all`, `all`, `settings`, `license`.
- `--dir=DIR` Indicates the metric directory. It must be one of: `counts_7d`, `7d`, `counts_28d`, `28d`, `counts_all`, `all`, `settings`, `license`.
**Single metric example**
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues --dir=7d
create config/metrics/counts_7d/issues.yml
```
**Multiple metrics example**
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues counts.users --dir=7d
create config/metrics/counts_7d/issues.yml
create config/metrics/counts_7d/users.yml
```
NOTE:
To create a metric definition used in EE, add the `--ee` flag.

View File

@ -1,5 +1,5 @@
---
key_path: <%= key_path %><%= metric_name_suggestion %>
key_path: <%= args.second %><%= metric_name_suggestion(args.second) %>
description:
product_section:
product_stage:

View File

@ -30,18 +30,20 @@ module Gitlab
source_root File.expand_path('../../../generator_templates/usage_metric_definition', __dir__)
desc 'Generates a metric definition yml file'
desc 'Generates metric definitions yml files'
class_option :ee, type: :boolean, optional: true, default: false, desc: 'Indicates if metric is for ee'
class_option :dir,
type: :string, desc: "Indicates the metric location. It must be one of: #{VALID_INPUT_DIRS.join(', ')}"
argument :key_path, type: :string, desc: 'Unique JSON key path for the metric'
argument :key_paths, type: :array, desc: 'Unique JSON key paths for the metrics'
def create_metric_file
validate!
template "metric_definition.yml", file_path
key_paths.each do |key_path|
template "metric_definition.yml", file_path(key_path), key_path
end
end
def time_frame
@ -66,12 +68,12 @@ module Gitlab
private
def metric_name_suggestion
def metric_name_suggestion(key_path)
"\nname: \"#{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}\""
end
def file_path
path = File.join(TOP_LEVEL_DIR, 'metrics', directory&.name, "#{file_name}.yml")
def file_path(key_path)
path = File.join(TOP_LEVEL_DIR, 'metrics', directory&.name, "#{file_name(key_path)}.yml")
path = File.join(TOP_LEVEL_DIR_EE, path) if ee?
path
end
@ -79,7 +81,10 @@ module Gitlab
def validate!
raise "--dir option is required" unless input_dir.present?
raise "Invalid dir #{input_dir}, allowed options are #{VALID_INPUT_DIRS.join(', ')}" unless directory.present?
raise "Metric definition with key path '#{key_path}' already exists" if metric_definition_exists?
key_paths.each do |key_path|
raise "Metric definition with key path '#{key_path}' already exists" if metric_definition_exists?(key_path)
end
end
def ee?
@ -93,15 +98,15 @@ module Gitlab
# Example of file name
#
# 20210201124931_g_project_management_issue_title_changed_weekly.yml
def file_name
"#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{metric_name}"
def file_name(key_path)
"#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{metric_name(key_path)}"
end
def directory
@directory ||= TIME_FRAME_DIRS.find { |d| d.match?(input_dir) }
end
def metric_name
def metric_name(key_path)
key_path.split('.').last
end
@ -109,7 +114,7 @@ module Gitlab
@definitions ||= Gitlab::Usage::MetricDefinition.definitions(skip_validation: true)
end
def metric_definition_exists?
def metric_definition_exists?(key_path)
metric_definitions[key_path].present?
end
end

View File

@ -99,4 +99,15 @@ RSpec.describe Gitlab::UsageMetricDefinitionGenerator, :silence_stdout do
expect(YAML.safe_load(File.read(metric_definition_path))).to include("name" => "some name")
end
end
context 'with multiple file names' do
let(:key_paths) { ['counts_weekly.test_metric', 'counts_weekly.test1_metric'] }
it 'creates multiple files' do
described_class.new(key_paths, { 'dir' => dir }).invoke_all
files = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_metric.yml'))
expect(files.count).to eq(2)
end
end
end