gitlab-exporter 7.0.1 → 7.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c062d3df29ab27b462fab49affc7bf091a79485c7d6f09f6210d7484f379c9a
4
- data.tar.gz: cff7645b256b132bcfd9bf34ba1541dcd3d117ff1419bb2c5d2f90b5e4259496
3
+ metadata.gz: 5f44f68c2a2d894b29ec2c891e0b6af0248ddaa2cb2ffe2c972c5ce08dd8de2e
4
+ data.tar.gz: 44156a1741197ac6da5db3ddd9a85c839b0c969e73edde7e723edcdd6b9b5b3e
5
5
  SHA512:
6
- metadata.gz: 50f37bdbfd6bed68b11e0e1527e9e6cbde1afc30aed339495194ab311c9d52d879d7a1728ae6528fe69f63918f1921b3079977aab426b24b65c0ed49bb49815c
7
- data.tar.gz: 73cd73cb2de026b3737a488374fffa3066350b48a700b2742a002c52d5e650741d1dade7472d380031f0c175a3de3b66d1c0b561c1286e24fd752402c8777b15
6
+ metadata.gz: f031bc1502b34f26690cd009d24f3d3f0c0e18cdd1167a21b9e8f6a135c24927f229ac0a7214cdd633943b8d9d588e8f1e8ff0cdba75a3b2f0474fdaf260d8ed
7
+ data.tar.gz: e267adae77f66e5470cc7d60485d249bc3bb692e54380b0cfd5dd6b552a769ec0ea9147ef4bcca8c3d27bba0e37027c367a5125d2e86c98b74419ad11c0dba34
@@ -1,13 +1,23 @@
1
- image: "ruby:2.3"
1
+ default:
2
+ image: "ruby:2.3"
3
+ before_script:
4
+ - git config --global user.email "bot@gitlab.com"
5
+ - git config --global user.name "Bot User"
6
+ - bundle install -j $(nproc) --path vendor
7
+ cache:
8
+ paths:
9
+ - vendor
10
+ tags:
11
+ - gitlab-org
2
12
 
3
- before_script:
4
- - git config --global user.email "bot@gitlab.com"
5
- - git config --global user.name "Bot User"
6
- - bundle install -j $(nproc) --path vendor
7
-
8
- cache:
9
- paths:
10
- - vendor
13
+ workflow:
14
+ rules:
15
+ # For merge requests, create a pipeline.
16
+ - if: '$CI_MERGE_REQUEST_IID'
17
+ # For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
18
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
19
+ # For tags, create a pipeline.
20
+ - if: '$CI_COMMIT_TAG'
11
21
 
12
22
  rspec:
13
23
  script:
@@ -16,3 +26,11 @@ rspec:
16
26
  rubocop:
17
27
  script:
18
28
  - bundle exec rubocop
29
+
30
+ include:
31
+ - template: Security/DAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
32
+ - template: Security/Container-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml
33
+ - template: Security/Dependency-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml
34
+ - template: Security/License-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/License-Scanning.gitlab-ci.yml
35
+ - template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
36
+
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-exporter (7.0.1)
4
+ gitlab-exporter (7.0.6)
5
5
  connection_pool (~> 2.2.1)
6
6
  pg (~> 1.1)
7
7
  quantile (~> 0.2.0)
@@ -21,8 +21,7 @@ module GitLab
21
21
  ON namespaces.id = projects.namespace_id
22
22
  LEFT JOIN namespace_statistics
23
23
  ON namespace_statistics.namespace_id = namespaces.id
24
- JOIN application_settings
25
- ON application_settings.id = 1
24
+ JOIN application_settings ON (TRUE)
26
25
  WHERE ci_builds.type = 'Ci::Build'
27
26
  AND ci_builds.status = '%s'
28
27
  -- The created_at filter has been introduced for performance reasons only
@@ -95,8 +94,7 @@ module GitLab
95
94
  ON namespaces.id = projects.namespace_id
96
95
  LEFT JOIN namespace_statistics
97
96
  ON namespace_statistics.namespace_id = namespaces.id
98
- JOIN application_settings
99
- ON application_settings.id = 1
97
+ JOIN application_settings ON (TRUE)
100
98
  WHERE ci_builds.type = 'Ci::Build'
101
99
  AND ci_builds.status = 'running'
102
100
  -- The created_at filter has been introduced for performance reasons only
@@ -144,9 +142,9 @@ module GitLab
144
142
  ci_builds.trigger_request_id
145
143
  SQL
146
144
 
147
- MIRROR_COLUMN_QUERY =
145
+ EE_CHECK_QUERY =
148
146
  <<~SQL.freeze
149
- SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='projects' AND column_name='mirror')
147
+ SELECT COUNT(*) FROM licenses
150
148
  SQL
151
149
 
152
150
  REPEATED_COMMANDS_QUERY_EE =
@@ -175,8 +173,7 @@ module GitLab
175
173
  ON namespaces.id = projects.namespace_id
176
174
  LEFT JOIN namespace_statistics
177
175
  ON namespace_statistics.namespace_id = namespaces.id
178
- JOIN application_settings
179
- ON application_settings.id = 1
176
+ JOIN application_settings ON (TRUE)
180
177
  WHERE ci_builds.type = 'Ci::Build'
181
178
  AND ci_builds.status IN ('running', 'pending')
182
179
  -- The created_at filter has been introduced for performance reasons only
@@ -289,7 +286,7 @@ module GitLab
289
286
  def builds(status)
290
287
  results = []
291
288
 
292
- query = mirror_column? ? BUILDS_QUERY_EE : BUILDS_QUERY_CE
289
+ query = ee? ? BUILDS_QUERY_EE : BUILDS_QUERY_CE
293
290
  query = query % [status] # rubocop:disable Style/FormatString
294
291
  exec_query_with_custom_random_page_cost(query).each do |row|
295
292
  results << transform_builds_row_to_values(row)
@@ -318,7 +315,7 @@ module GitLab
318
315
  def per_runner_builds
319
316
  results = []
320
317
 
321
- query = mirror_column? ? PER_RUNNER_QUERY_EE : PER_RUNNER_QUERY_CE
318
+ query = ee? ? PER_RUNNER_QUERY_EE : PER_RUNNER_QUERY_CE
322
319
  exec_query_with_custom_random_page_cost(query).each do |row|
323
320
  results << transform_per_runners_builds_row_to_values(row)
324
321
  end
@@ -341,7 +338,7 @@ module GitLab
341
338
  def repeated_commands
342
339
  results = []
343
340
 
344
- query = mirror_column? ? REPEATED_COMMANDS_QUERY_EE : REPEATED_COMMANDS_QUERY_CE
341
+ query = ee? ? REPEATED_COMMANDS_QUERY_EE : REPEATED_COMMANDS_QUERY_CE
345
342
  query = query % [allowed_repeated_commands_count] # rubocop:disable Style/FormatString
346
343
  exec_query_with_custom_random_page_cost(query).each do |row|
347
344
  results << transform_repeated_commands_row_to_values(row)
@@ -406,11 +403,11 @@ module GitLab
406
403
  end
407
404
  end
408
405
 
409
- def mirror_column?
410
- @mirror_column ||=
406
+ def ee?
407
+ @ee ||=
411
408
  begin
412
409
  with_connection_pool do |conn|
413
- conn.exec(MIRROR_COLUMN_QUERY)[0]["exists"] == "t"
410
+ conn.exec(EE_CHECK_QUERY)[0]["count"].to_i > 0 # rubocop:disable Style/NumericPredicate
414
411
  end
415
412
  rescue PG::UndefinedColumn
416
413
  false
@@ -10,6 +10,11 @@ module GitLab
10
10
  # #construct_query
11
11
  # rubocop:disable Metrics/ClassLength
12
12
  class RowCountCollector < Base
13
+ # We ignore mirrors with a next_execution_timestamp before
14
+ # 2020-03-28 because this is when we stopped processing mirrors
15
+ # for private projects on the free plan. Skipping those can
16
+ # significantly improve query performance:
17
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/216252#note_334514544
13
18
  WHERE_MIRROR_ENABLED = <<~SQL.freeze
14
19
  projects.mirror = true
15
20
  AND projects.archived = false
@@ -19,6 +24,7 @@ module GitLab
19
24
  OR
20
25
  plans.name IN ('early_adopter', 'bronze', 'silver', 'gold')
21
26
  )
27
+ AND project_mirror_data.next_execution_timestamp > '2020-03-28'
22
28
  SQL
23
29
 
24
30
  MIRROR_QUERY = {
@@ -104,7 +110,7 @@ module GitLab
104
110
  GROUP BY members.user_id
105
111
  ) AS u
106
112
  ON users.id = u.user_id",
107
- where: "ghost IS NULL AND bot_type IS NULL",
113
+ where: "user_type IS NULL",
108
114
  fields: {
109
115
  admin: {},
110
116
  external: {},
@@ -1,5 +1,5 @@
1
1
  module GitLab
2
2
  module Exporter
3
- VERSION = "7.0.1".freeze
3
+ VERSION = "7.0.6".freeze
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ describe GitLab::Exporter::Database do
9
9
  let(:stale_builds_query) { "SELECT NOT UPDATED RUNNING" }
10
10
  let(:per_runner_query_ee) { "SELECT ALL RUNNING PER RUNNER EE" }
11
11
  let(:per_runner_query_ce) { "SELECT ALL RUNNING PER RUNNER CE" }
12
- let(:mirror_column_query) { "SELECT DOES MIRROR COLUMN EXISTS" }
12
+ let(:ee_check_query) { "SELECT COUNT(*) FROM licenses" }
13
13
  let(:repeated_commands_query_ee) { "SELECT EE REPEATED COMNANDS %d" }
14
14
  let(:repeated_commands_query_ce) { "SELECT CE REPEATED COMNANDS %d" }
15
15
  let(:unarchived_traces_query) { "SELECT UNARCHIVED TRACES %s LIST" }
@@ -22,11 +22,11 @@ describe GitLab::Exporter::Database do
22
22
  let(:unarchived_traces_offset_minutes) { 60 }
23
23
 
24
24
  def stub_ee
25
- allow(connection).to receive(:exec).with(mirror_column_query).and_return([{ "exists" => "t" }])
25
+ allow(connection).to receive(:exec).with(ee_check_query).and_return([{ "count" => 1 }])
26
26
  end
27
27
 
28
28
  def stub_ce
29
- allow(connection).to receive(:exec).with(mirror_column_query).and_return([{ "exists" => "f" }])
29
+ allow(connection).to receive(:exec).with(ee_check_query).and_return([{ "count" => 0 }])
30
30
  end
31
31
 
32
32
  def builds_query_row_ee(shared_runners_enabled, status, namespace_id, has_minutes, count)
@@ -86,7 +86,7 @@ describe GitLab::Exporter::Database do
86
86
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::STALE_BUILDS_QUERY", stale_builds_query)
87
87
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::PER_RUNNER_QUERY_EE", per_runner_query_ee)
88
88
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::PER_RUNNER_QUERY_CE", per_runner_query_ce)
89
- stub_const("GitLab::Exporter::Database::CiBuildsCollector::MIRROR_COLUMN_QUERY", mirror_column_query)
89
+ stub_const("GitLab::Exporter::Database::CiBuildsCollector::EE_CHECK_QUERY", ee_check_query)
90
90
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::REPEATED_COMMANDS_QUERY_EE", repeated_commands_query_ee)
91
91
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::REPEATED_COMMANDS_QUERY_CE", repeated_commands_query_ce)
92
92
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::UNARCHIVED_TRACES_QUERY", unarchived_traces_query)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Carranza