gitlab-exporter 13.0.0 → 13.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83e761659c465160f92d3473b6d3f816066807a0126764e2dbba29a65d998273
4
- data.tar.gz: 68a0b79fe5aa6e44df1c073c09d75e2f1f6e20aacb377ec8303ea1b28aca79e0
3
+ metadata.gz: e25742f97cb40db0a84768e5b780c3d4d29af3c35ce456cc54ab5cebbf39ded7
4
+ data.tar.gz: 13cf4d4d86554c783d9c7cb1a7c9db42189b0fd6fe520e10f15b084cb5b43761
5
5
  SHA512:
6
- metadata.gz: 35394994c429efd84c43718f955d4dded45f9133894fc2da2ddeeba2446ab74c1a2018b831c1c03fe38abc8d25e48ec9455e8a4371493f897b033ae47cb88460
7
- data.tar.gz: 2143e9b485304140c3b7f5139f152eab9355b8bdad1cef7c4ea4cd03b5ca114a557bbb3daeba558f4ac8aac30a01827187682df6be4725799919702ce178acf8
6
+ metadata.gz: 7f48b26649ec291a96b41976d6b674171667c43ab0f8de188809e9d22fdb3d0ee0d17c33ac1ef30a4f217f1f52c701335a88ed600a915797d8013a264359bdde
7
+ data.tar.gz: 954a83f62a78a78244503a2b47c5bfe9fc2fac338e46cf692d03731b53b459ec715e83b4bbd5df5320c55efe47c8e7db17b0af944fb490e09ee1b1453b4bf6a3
data/.gitlab-ci.yml CHANGED
@@ -43,7 +43,7 @@ rspec:
43
43
  before_script: *before_scripts
44
44
  parallel:
45
45
  matrix:
46
- - RUBY_VERSION: ["2.7", "3.0"]
46
+ - RUBY_VERSION: ["2.7", "3.0", "3.1", "3.2"]
47
47
 
48
48
  rspec_integration:
49
49
  script:
@@ -55,7 +55,7 @@ rspec_integration:
55
55
  REDIS_URL: "redis://redis"
56
56
  parallel:
57
57
  matrix:
58
- - RUBY_VERSION: ["2.7", "3.0"]
58
+ - RUBY_VERSION: ["2.7", "3.0", "3.1", "3.2"]
59
59
 
60
60
  rubocop:
61
61
  script:
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem "rspec", "~>3.5"
6
+ gem "rspec", "~>3.12"
7
7
  gem "rubocop", "~>0.42"
8
8
  end
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-exporter (13.0.0)
4
+ gitlab-exporter (13.1.0)
5
5
  connection_pool (= 2.2.5)
6
6
  faraday (~> 1.8.0)
7
- pg (= 1.2.3)
7
+ pg (= 1.5.3)
8
8
  puma (= 5.6.5)
9
9
  quantile (= 0.2.1)
10
10
  redis (= 4.4.0)
@@ -18,7 +18,7 @@ GEM
18
18
  specs:
19
19
  ast (2.4.1)
20
20
  connection_pool (2.2.5)
21
- diff-lcs (1.3)
21
+ diff-lcs (1.5.0)
22
22
  faraday (1.8.0)
23
23
  faraday-em_http (~> 1.0)
24
24
  faraday-em_synchrony (~> 1.0)
@@ -45,7 +45,7 @@ GEM
45
45
  parallel (1.20.1)
46
46
  parser (3.0.0.0)
47
47
  ast (~> 2.4.1)
48
- pg (1.2.3)
48
+ pg (1.5.3)
49
49
  puma (5.6.5)
50
50
  nio4r (~> 2.0)
51
51
  quantile (0.2.1)
@@ -58,19 +58,19 @@ GEM
58
58
  redis (>= 4)
59
59
  regexp_parser (2.0.3)
60
60
  rexml (3.2.4)
61
- rspec (3.7.0)
62
- rspec-core (~> 3.7.0)
63
- rspec-expectations (~> 3.7.0)
64
- rspec-mocks (~> 3.7.0)
65
- rspec-core (3.7.1)
66
- rspec-support (~> 3.7.0)
67
- rspec-expectations (3.7.0)
61
+ rspec (3.12.0)
62
+ rspec-core (~> 3.12.0)
63
+ rspec-expectations (~> 3.12.0)
64
+ rspec-mocks (~> 3.12.0)
65
+ rspec-core (3.12.2)
66
+ rspec-support (~> 3.12.0)
67
+ rspec-expectations (3.12.3)
68
68
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.7.0)
70
- rspec-mocks (3.7.0)
69
+ rspec-support (~> 3.12.0)
70
+ rspec-mocks (3.12.5)
71
71
  diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.7.0)
73
- rspec-support (3.7.1)
72
+ rspec-support (~> 3.12.0)
73
+ rspec-support (3.12.0)
74
74
  rubocop (0.93.1)
75
75
  parallel (~> 1.10)
76
76
  parser (>= 2.7.1.5)
@@ -102,8 +102,8 @@ PLATFORMS
102
102
 
103
103
  DEPENDENCIES
104
104
  gitlab-exporter!
105
- rspec (~> 3.5)
106
- rspec-expectations (~> 3.7.0)
105
+ rspec (~> 3.12)
106
+ rspec-expectations (~> 3.12.0)
107
107
  rubocop (~> 0.42)
108
108
 
109
109
  BUNDLED WITH
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_runtime_dependency "connection_pool", "2.2.5"
24
24
  s.add_runtime_dependency "faraday", "~> 1.8.0"
25
- s.add_runtime_dependency "pg", "1.2.3"
25
+ s.add_runtime_dependency "pg", "1.5.3"
26
26
  s.add_runtime_dependency "puma", "5.6.5"
27
27
  s.add_runtime_dependency "quantile", "0.2.1"
28
28
  s.add_runtime_dependency "redis", "4.4.0"
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency "sinatra", "~> 2.2.0"
32
32
  s.add_runtime_dependency "webrick", "~> 1.7"
33
33
 
34
- s.add_development_dependency "rspec", "~> 3.7.0"
35
- s.add_development_dependency "rspec-expectations", "~> 3.7.0"
34
+ s.add_development_dependency "rspec", "~> 3.12.0"
35
+ s.add_development_dependency "rspec-expectations", "~> 3.12.0"
36
36
  end
@@ -1,5 +1,19 @@
1
1
  require "yaml"
2
2
 
3
+ # TODO: Remove this once we're on Ruby 3
4
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/393651
5
+ unless YAML.respond_to?(:safe_load_file)
6
+ module YAML # rubocop:disable Style/Documentation
7
+ # Temporary Ruby 2 back-compat workaround.
8
+ #
9
+ # This method only exists as of stdlib 3.0.0:
10
+ # https://ruby-doc.org/stdlib-3.0.0/libdoc/psych/rdoc/Psych.html
11
+ def self.safe_load_file(path, **options)
12
+ YAML.safe_load(File.read(path), **options)
13
+ end
14
+ end
15
+ end
16
+
3
17
  module GitLab
4
18
  module Exporter
5
19
  # Stores runner classes in a single place
@@ -184,7 +198,7 @@ module GitLab
184
198
  def run
185
199
  validate!
186
200
 
187
- config = Utils.deep_symbolize_hash_keys(YAML.load_file(@config_file))
201
+ config = Utils.deep_symbolize_hash_keys(YAML.safe_load_file(@config_file, aliases: true))
188
202
 
189
203
  WebExporter.setup(config)
190
204
  WebExporter.run!
@@ -8,7 +8,7 @@ module GitLab
8
8
  # This class works under the assumption you do COUNT(*) queries, define
9
9
  # queries in the QUERIES constant. If in doubt how these work, read
10
10
  # #construct_query
11
- class RowCountCollector < Base
11
+ class RowCountCollector < Base # rubocop:disable Metrics/ClassLength
12
12
  # We ignore mirrors with a next_execution_timestamp before
13
13
  # 2020-03-28 because this is when we stopped processing mirrors
14
14
  # for private projects on the free plan. Skipping those can
@@ -29,6 +29,15 @@ module GitLab
29
29
  check: "SELECT 1 FROM information_schema.tables WHERE table_name='plans'"
30
30
  }.freeze
31
31
 
32
+ CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY = {
33
+ select: :container_repositories,
34
+ joins: <<~SQL,
35
+ INNER JOIN container_expiration_policies
36
+ ON container_repositories.project_id = container_expiration_policies.project_id
37
+ SQL
38
+ where: "container_expiration_policies.enabled = TRUE"
39
+ }.freeze
40
+
32
41
  QUERIES = {
33
42
  mirrors_ready_to_sync: MIRROR_QUERY.merge( # EE only
34
43
  where: <<~SQL
@@ -117,6 +126,52 @@ module GitLab
117
126
  visibility_level: {},
118
127
  root: { definition: "(parent_id IS NULL)" }
119
128
  }
129
+ },
130
+ container_repositories: { select: :container_repositories },
131
+ container_repositories_delete_scheduled: { select: :container_repositories, where: "status = 0" },
132
+ container_repositories_delete_failed: { select: :container_repositories, where: "status = 1" },
133
+ container_repositories_delete_ongoing: { select: :container_repositories, where: "status = 2" },
134
+ container_repositories_delete_staled: {
135
+ select: :container_repositories,
136
+ where: "status = 2 AND delete_started_at < (NOW() - INTERVAL '30 minutes')"
137
+ },
138
+ container_repositories_cleanup_enabled: CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY,
139
+ container_repositories_cleanup_pending: CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY.merge(
140
+ where: <<~SQL
141
+ container_expiration_policies.enabled = TRUE
142
+ AND container_repositories.expiration_policy_cleanup_status IN (0, 1)
143
+ AND (container_repositories.expiration_policy_started_at IS NULL OR container_repositories.expiration_policy_started_at < container_expiration_policies.next_run_at)
144
+ AND (container_expiration_policies.next_run_at < NOW())
145
+ SQL
146
+ ),
147
+ container_repositories_cleanup_unfinished: CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY.merge(
148
+ where: <<~SQL
149
+ container_expiration_policies.enabled = TRUE
150
+ AND container_repositories.expiration_policy_cleanup_status = 2
151
+ SQL
152
+ ),
153
+ container_repositories_cleanup_unscheduled: CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY.merge(
154
+ where: <<~SQL
155
+ container_expiration_policies.enabled = TRUE
156
+ AND container_repositories.expiration_policy_cleanup_status = 0
157
+ SQL
158
+ ),
159
+ container_repositories_cleanup_scheduled: CONTAINER_REPOSITORIES_CLEANUP_ENABLED_QUERY.merge(
160
+ where: <<~SQL
161
+ container_expiration_policies.enabled = TRUE
162
+ AND container_repositories.expiration_policy_cleanup_status = 1
163
+ SQL
164
+ ),
165
+ container_repositories_cleanup_ongoing: {
166
+ select: :container_repositories,
167
+ where: "expiration_policy_cleanup_status = 3"
168
+ },
169
+ container_repositories_cleanup_staled: {
170
+ select: :container_repositories,
171
+ where: <<~SQL
172
+ expiration_policy_cleanup_status = 3
173
+ AND (expiration_policy_started_at < (NOW() - INTERVAL '35 minutes') OR expiration_policy_started_at IS NULL)
174
+ SQL
120
175
  }
121
176
  }.freeze
122
177
 
@@ -1,5 +1,5 @@
1
1
  module GitLab
2
2
  module Exporter
3
- VERSION = "13.0.0".freeze
3
+ VERSION = "13.1.0".freeze
4
4
  end
5
5
  end
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: 13.0.0
4
+ version: 13.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Carranza
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.3
47
+ version: 1.5.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.3
54
+ version: 1.5.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: puma
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -156,28 +156,28 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 3.7.0
159
+ version: 3.12.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 3.7.0
166
+ version: 3.12.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec-expectations
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 3.7.0
173
+ version: 3.12.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 3.7.0
180
+ version: 3.12.0
181
181
  description: GitLab metrics exporter to use with prometheus
182
182
  email: pablo@gitlab.com
183
183
  executables: