diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 12:10:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 12:10:05 +0300 |
commit | 4901ff1764398bb017487d4a5104b74bc284f33a (patch) | |
tree | 49d16dce22b451cfe024fb93701b55c2b84de25e | |
parent | 93ea45e25a0cf3dfebd11b484e6967da6d95d4ab (diff) |
Add latest changes from gitlab-org/gitlab@master
7 files changed, 67 insertions, 54 deletions
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index fe7a9b21a85..1d187b140ef 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -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? diff --git a/config/feature_flags/development/linear_application_setting_ancestor_scopes.yml b/config/feature_flags/development/linear_application_setting_ancestor_scopes.yml deleted file mode 100644 index 18c64df78d7..00000000000 --- a/config/feature_flags/development/linear_application_setting_ancestor_scopes.yml +++ /dev/null @@ -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 diff --git a/doc/administration/nfs.md b/doc/administration/nfs.md index f18c39af24a..2a2e9f05312 100644 --- a/doc/administration/nfs.md +++ b/doc/administration/nfs.md @@ -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. diff --git a/doc/development/service_ping/metrics_dictionary.md b/doc/development/service_ping/metrics_dictionary.md index c1478e6290e..b3c404de150 100644 --- a/doc/development/service_ping/metrics_dictionary.md +++ b/doc/development/service_ping/metrics_dictionary.md @@ -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. diff --git a/generator_templates/usage_metric_definition/metric_definition.yml b/generator_templates/usage_metric_definition/metric_definition.yml index 9ce03bdb7b4..c094d6d3d88 100644 --- a/generator_templates/usage_metric_definition/metric_definition.yml +++ b/generator_templates/usage_metric_definition/metric_definition.yml @@ -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: diff --git a/lib/generators/gitlab/usage_metric_definition_generator.rb b/lib/generators/gitlab/usage_metric_definition_generator.rb index 2d65363bf7b..bd34ab0a16f 100644 --- a/lib/generators/gitlab/usage_metric_definition_generator.rb +++ b/lib/generators/gitlab/usage_metric_definition_generator.rb @@ -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 diff --git a/spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb b/spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb index 05833cf4ec4..b67425ae012 100644 --- a/spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb +++ b/spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb @@ -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 |