gitlab-exporter 7.0.0 → 7.0.5
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 +4 -4
 - data/.gitlab-ci.yml +27 -9
 - data/Gemfile.lock +10 -12
 - data/lib/gitlab_exporter/database/ci_builds.rb +8 -8
 - data/lib/gitlab_exporter/database/row_count.rb +13 -2
 - data/lib/gitlab_exporter/version.rb +1 -1
 - data/spec/database/ci_builds_spec.rb +4 -4
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: de89f0131cde7415ce666ec09c4da388b53f4cbf57b8e7872f3e5538be257e30
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4b84a64c0d3b26306628ec04dc2ce7b56b36eda349385a43855b1a968c2a8560
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a292b9c5c4f24fab3014e6bc9ae5f3b86c86ff47d5034fce9280d1fa75372cbcd18e5d75a6e130c9de77fc662b1ef2fa6d1dd9f390a004236c727e311a9e02a3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6f1309c2abeeeca930d0485d66b9b714006f1d97814141fba7f6a2b4db063ee41f0181857de0044435d8e3b14d10e844d2ed595a5ce2505fe63a02ef6abce466
         
     | 
    
        data/.gitlab-ci.yml
    CHANGED
    
    | 
         @@ -1,13 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                -  
     | 
| 
      
 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 
     | 
    
         
            +
             
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                gitlab-exporter (7.0. 
     | 
| 
      
 4 
     | 
    
         
            +
                gitlab-exporter (7.0.5)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  connection_pool (~> 2.2.1)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  pg (~> 1.1)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  quantile (~> 0.2.0)
         
     | 
| 
         @@ -16,15 +16,14 @@ GEM 
     | 
|
| 
       16 
16 
     | 
    
         
             
                ast (2.4.0)
         
     | 
| 
       17 
17 
     | 
    
         
             
                connection_pool (2.2.2)
         
     | 
| 
       18 
18 
     | 
    
         
             
                diff-lcs (1.3)
         
     | 
| 
       19 
     | 
    
         
            -
                mustermann (1. 
     | 
| 
       20 
     | 
    
         
            -
                  ruby2_keywords (~> 0.0.1)
         
     | 
| 
      
 19 
     | 
    
         
            +
                mustermann (1.0.3)
         
     | 
| 
       21 
20 
     | 
    
         
             
                parser (2.5.1.0)
         
     | 
| 
       22 
21 
     | 
    
         
             
                  ast (~> 2.4.0)
         
     | 
| 
       23 
     | 
    
         
            -
                pg (1.2. 
     | 
| 
      
 22 
     | 
    
         
            +
                pg (1.2.2)
         
     | 
| 
       24 
23 
     | 
    
         
             
                powerpack (0.1.1)
         
     | 
| 
       25 
24 
     | 
    
         
             
                quantile (0.2.1)
         
     | 
| 
       26 
     | 
    
         
            -
                rack (2.0. 
     | 
| 
       27 
     | 
    
         
            -
                rack-protection (2.0. 
     | 
| 
      
 25 
     | 
    
         
            +
                rack (2.0.7)
         
     | 
| 
      
 26 
     | 
    
         
            +
                rack-protection (2.0.7)
         
     | 
| 
       28 
27 
     | 
    
         
             
                  rack
         
     | 
| 
       29 
28 
     | 
    
         
             
                rainbow (2.1.0)
         
     | 
| 
       30 
29 
     | 
    
         
             
                redis (4.1.3)
         
     | 
| 
         @@ -50,18 +49,17 @@ GEM 
     | 
|
| 
       50 
49 
     | 
    
         
             
                  ruby-progressbar (~> 1.7)
         
     | 
| 
       51 
50 
     | 
    
         
             
                  unicode-display_width (~> 1.0, >= 1.0.1)
         
     | 
| 
       52 
51 
     | 
    
         
             
                ruby-progressbar (1.8.1)
         
     | 
| 
       53 
     | 
    
         
            -
                 
     | 
| 
       54 
     | 
    
         
            -
                sidekiq (5.2.8)
         
     | 
| 
      
 52 
     | 
    
         
            +
                sidekiq (5.2.7)
         
     | 
| 
       55 
53 
     | 
    
         
             
                  connection_pool (~> 2.2, >= 2.2.2)
         
     | 
| 
       56 
     | 
    
         
            -
                  rack ( 
     | 
| 
      
 54 
     | 
    
         
            +
                  rack (>= 1.5.0)
         
     | 
| 
       57 
55 
     | 
    
         
             
                  rack-protection (>= 1.5.0)
         
     | 
| 
       58 
56 
     | 
    
         
             
                  redis (>= 3.3.5, < 5)
         
     | 
| 
       59 
     | 
    
         
            -
                sinatra (2.0. 
     | 
| 
      
 57 
     | 
    
         
            +
                sinatra (2.0.7)
         
     | 
| 
       60 
58 
     | 
    
         
             
                  mustermann (~> 1.0)
         
     | 
| 
       61 
59 
     | 
    
         
             
                  rack (~> 2.0)
         
     | 
| 
       62 
     | 
    
         
            -
                  rack-protection (= 2.0. 
     | 
| 
      
 60 
     | 
    
         
            +
                  rack-protection (= 2.0.7)
         
     | 
| 
       63 
61 
     | 
    
         
             
                  tilt (~> 2.0)
         
     | 
| 
       64 
     | 
    
         
            -
                tilt (2.0. 
     | 
| 
      
 62 
     | 
    
         
            +
                tilt (2.0.9)
         
     | 
| 
       65 
63 
     | 
    
         
             
                unicode-display_width (1.6.0)
         
     | 
| 
       66 
64 
     | 
    
         | 
| 
       67 
65 
     | 
    
         
             
            PLATFORMS
         
     | 
| 
         @@ -144,9 +144,9 @@ module GitLab 
     | 
|
| 
       144 
144 
     | 
    
         
             
                          ci_builds.trigger_request_id
         
     | 
| 
       145 
145 
     | 
    
         
             
                      SQL
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
                     
     | 
| 
      
 147 
     | 
    
         
            +
                    EE_CHECK_QUERY =
         
     | 
| 
       148 
148 
     | 
    
         
             
                      <<~SQL.freeze
         
     | 
| 
       149 
     | 
    
         
            -
                        SELECT  
     | 
| 
      
 149 
     | 
    
         
            +
                        SELECT COUNT(*) FROM licenses
         
     | 
| 
       150 
150 
     | 
    
         
             
                      SQL
         
     | 
| 
       151 
151 
     | 
    
         | 
| 
       152 
152 
     | 
    
         
             
                    REPEATED_COMMANDS_QUERY_EE =
         
     | 
| 
         @@ -289,7 +289,7 @@ module GitLab 
     | 
|
| 
       289 
289 
     | 
    
         
             
                    def builds(status)
         
     | 
| 
       290 
290 
     | 
    
         
             
                      results = []
         
     | 
| 
       291 
291 
     | 
    
         | 
| 
       292 
     | 
    
         
            -
                      query =  
     | 
| 
      
 292 
     | 
    
         
            +
                      query = ee? ? BUILDS_QUERY_EE : BUILDS_QUERY_CE
         
     | 
| 
       293 
293 
     | 
    
         
             
                      query = query % [status] # rubocop:disable Style/FormatString
         
     | 
| 
       294 
294 
     | 
    
         
             
                      exec_query_with_custom_random_page_cost(query).each do |row|
         
     | 
| 
       295 
295 
     | 
    
         
             
                        results << transform_builds_row_to_values(row)
         
     | 
| 
         @@ -318,7 +318,7 @@ module GitLab 
     | 
|
| 
       318 
318 
     | 
    
         
             
                    def per_runner_builds
         
     | 
| 
       319 
319 
     | 
    
         
             
                      results = []
         
     | 
| 
       320 
320 
     | 
    
         | 
| 
       321 
     | 
    
         
            -
                      query =  
     | 
| 
      
 321 
     | 
    
         
            +
                      query = ee? ? PER_RUNNER_QUERY_EE : PER_RUNNER_QUERY_CE
         
     | 
| 
       322 
322 
     | 
    
         
             
                      exec_query_with_custom_random_page_cost(query).each do |row|
         
     | 
| 
       323 
323 
     | 
    
         
             
                        results << transform_per_runners_builds_row_to_values(row)
         
     | 
| 
       324 
324 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -341,7 +341,7 @@ module GitLab 
     | 
|
| 
       341 
341 
     | 
    
         
             
                    def repeated_commands
         
     | 
| 
       342 
342 
     | 
    
         
             
                      results = []
         
     | 
| 
       343 
343 
     | 
    
         | 
| 
       344 
     | 
    
         
            -
                      query =  
     | 
| 
      
 344 
     | 
    
         
            +
                      query = ee? ? REPEATED_COMMANDS_QUERY_EE : REPEATED_COMMANDS_QUERY_CE
         
     | 
| 
       345 
345 
     | 
    
         
             
                      query = query % [allowed_repeated_commands_count] # rubocop:disable Style/FormatString
         
     | 
| 
       346 
346 
     | 
    
         
             
                      exec_query_with_custom_random_page_cost(query).each do |row|
         
     | 
| 
       347 
347 
     | 
    
         
             
                        results << transform_repeated_commands_row_to_values(row)
         
     | 
| 
         @@ -406,11 +406,11 @@ module GitLab 
     | 
|
| 
       406 
406 
     | 
    
         
             
                      end
         
     | 
| 
       407 
407 
     | 
    
         
             
                    end
         
     | 
| 
       408 
408 
     | 
    
         | 
| 
       409 
     | 
    
         
            -
                    def  
     | 
| 
       410 
     | 
    
         
            -
                      @ 
     | 
| 
      
 409 
     | 
    
         
            +
                    def ee?
         
     | 
| 
      
 410 
     | 
    
         
            +
                      @ee ||=
         
     | 
| 
       411 
411 
     | 
    
         
             
                        begin
         
     | 
| 
       412 
412 
     | 
    
         
             
                          with_connection_pool do |conn|
         
     | 
| 
       413 
     | 
    
         
            -
                            conn.exec( 
     | 
| 
      
 413 
     | 
    
         
            +
                            conn.exec(EE_CHECK_QUERY)[0]["count"].to_i > 0 # rubocop:disable Style/NumericPredicate
         
     | 
| 
       414 
414 
     | 
    
         
             
                          end
         
     | 
| 
       415 
415 
     | 
    
         
             
                        rescue PG::UndefinedColumn
         
     | 
| 
       416 
416 
     | 
    
         
             
                          false
         
     | 
| 
         @@ -10,10 +10,21 @@ 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
         
     | 
| 
      
 20 
     | 
    
         
            +
                      AND projects.archived = false
         
     | 
| 
       15 
21 
     | 
    
         
             
                      AND project_mirror_data.retry_count <= 14
         
     | 
| 
       16 
     | 
    
         
            -
                      AND ( 
     | 
| 
      
 22 
     | 
    
         
            +
                      AND (
         
     | 
| 
      
 23 
     | 
    
         
            +
                        (projects.visibility_level = 20 AND root_namespaces.visibility_level = 20)
         
     | 
| 
      
 24 
     | 
    
         
            +
                        OR
         
     | 
| 
      
 25 
     | 
    
         
            +
                        plans.name IN ('early_adopter', 'bronze', 'silver', 'gold')
         
     | 
| 
      
 26 
     | 
    
         
            +
                      )
         
     | 
| 
      
 27 
     | 
    
         
            +
                      AND project_mirror_data.next_execution_timestamp > '2020-03-28'
         
     | 
| 
       17 
28 
     | 
    
         
             
                    SQL
         
     | 
| 
       18 
29 
     | 
    
         | 
| 
       19 
30 
     | 
    
         
             
                    MIRROR_QUERY = {
         
     | 
| 
         @@ -99,7 +110,7 @@ module GitLab 
     | 
|
| 
       99 
110 
     | 
    
         
             
                            GROUP BY members.user_id
         
     | 
| 
       100 
111 
     | 
    
         
             
                          ) AS u
         
     | 
| 
       101 
112 
     | 
    
         
             
                          ON users.id = u.user_id",
         
     | 
| 
       102 
     | 
    
         
            -
                        where: " 
     | 
| 
      
 113 
     | 
    
         
            +
                        where: "user_type IS NULL",
         
     | 
| 
       103 
114 
     | 
    
         
             
                        fields: {
         
     | 
| 
       104 
115 
     | 
    
         
             
                          admin:        {},
         
     | 
| 
       105 
116 
     | 
    
         
             
                          external:     {},
         
     | 
| 
         @@ -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(: 
     | 
| 
      
 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( 
     | 
| 
      
 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( 
     | 
| 
      
 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:: 
     | 
| 
      
 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)
         
     |