Skip to content

Commit 6d3dac0

Browse files
ibaumfh1ch
andcommitted
Merge branch 'feat/support-registry-gc-config' into 'master'
Add config support for container registry garbage collection Closes #8438 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7447 Merged-by: Ian Baum <[email protected]> Approved-by: Mitchell Nielsen <[email protected]> Approved-by: Ian Baum <[email protected]> Reviewed-by: Ian Baum <[email protected]> Co-authored-by: Fabio Huser <[email protected]>
2 parents 6b64ec2 + 32205d5 commit 6d3dac0

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

files/gitlab-config-template/gitlab.rb.template

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,25 @@ external_url 'GENERATED_EXTERNAL_URL'
10231023
# }
10241024
# }
10251025

1026+
### Registry garbage collection
1027+
###! Docs: https://gitlab.com/gitlab-org/container-registry/-/blob/master/docs/configuration.md?ref_type=heads#gc
1028+
# registry['gc'] = {
1029+
# 'disabled' => false,
1030+
# 'maxbackoff' => '24h',
1031+
# 'noidlebackoff' => false,
1032+
# 'transactiontimeout' => '10s',
1033+
# 'reviewafter' => '24h',
1034+
# 'manifests' => {
1035+
# 'disabled' => false,
1036+
# 'interval' => '5s'
1037+
# },
1038+
# 'blobs' => {
1039+
# 'disabled' => false,
1040+
# 'interval' => '5s',
1041+
# 'storagetimeout' => '5s'
1042+
# }
1043+
# }
1044+
10261045
### Registry notifications endpoints
10271046
# registry['notifications'] = [
10281047
# {

files/gitlab-cookbooks/registry/attributes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
default['registry']['autoredirect'] = false
3838
default['registry']['compatibility_schema1_enabled'] = false
3939
default['registry']['database'] = nil
40+
default['registry']['gc'] = nil
4041

4142
####
4243
# Notifications

files/gitlab-cookbooks/registry/templates/default/registry-config.yml.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ notifications:
4747
<% if @database %>
4848
database: <%= @database.to_json %>
4949
<% end %>
50+
<% if @gc %>
51+
gc: <%= @gc.to_json %>
52+
<% end %>

spec/chef/cookbooks/registry/recipes/registry_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,32 @@
173173
end
174174
end
175175

176+
context 'when the registry garbage collector configuration is present' do
177+
let(:gc_config) do
178+
{ "disabled" => false,
179+
"maxbackoff" => "24h",
180+
"noidlebackoff" => false,
181+
"transactiontimeout" => "10s",
182+
"reviewafter" => "24h",
183+
"manifests" => {
184+
"disabled" => false,
185+
"interval" => "5s"
186+
},
187+
"blobs" => {
188+
"disabled" => false,
189+
"interval" => "5s",
190+
"storagetimeout" => "5s"
191+
} }
192+
end
193+
194+
before { stub_gitlab_rb(registry: { gc: gc_config }) }
195+
196+
it 'creates registry config with gc' do
197+
expect(chef_run).to render_file('/var/opt/gitlab/registry/config.yml')
198+
.with_content(%r(^gc: {"disabled":false))
199+
end
200+
end
201+
176202
context 'when a log formatter is specified' do
177203
before { stub_gitlab_rb(registry: { log_formatter: 'json' }) }
178204

spec/chef/support/shared_examples/registry_service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
expect(content).not_to match(/^compatibility:/)
6464
expect(content).not_to match(/^middleware:/)
6565
expect(content).not_to match(/^database:/)
66+
expect(content).not_to match(/^gc:/)
6667
end
6768
)
6869
end

0 commit comments

Comments
 (0)