diff --git a/doc/development/new-services.md b/doc/development/new-services.md index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZG9jL2RldmVsb3BtZW50L25ldy1zZXJ2aWNlcy5tZA==..b19102c055f0ed1057934ea701093dd542c39e3c_ZG9jL2RldmVsb3BtZW50L25ldy1zZXJ2aWNlcy5tZA== 100644 --- a/doc/development/new-services.md +++ b/doc/development/new-services.md @@ -38,10 +38,10 @@ for your service. For a service you should define an `enable` option by default. ```ruby -default['gitlab']['best-service']['enable'] = false -default['gitlab']['best-service']['dir'] = '/var/opt/gitlab/best-service' -default['gitlab']['best-service']['log_directory'] = '/var/log/gitlab/best-service' +default['gitlab']['best_service']['enable'] = false +default['gitlab']['best_service']['dir'] = '/var/opt/gitlab/best-service' +default['gitlab']['best_service']['log_directory'] = '/var/log/gitlab/best-service' ``` - `default` is how you define basic cookbook attributes. - `['gitlab']` contains the cookbook name. @@ -44,9 +44,9 @@ ``` - `default` is how you define basic cookbook attributes. - `['gitlab']` contains the cookbook name. -- `['best-service']` is the name of your service, at this level we use hyphens to separate words. -- `enable`, `dir`, and `log_directory` are our configuration settings, and we use underscores to separate words at this and deeper levels. +- `['best_service']` is the name of your service. +- `enable`, `dir`, and `log_directory` are our configuration settings. - `/var/opt/gitlab` is where the working directory and configuration files for the services are placed. - `/var/log/gitlab` is where logs are written to for the GitLab package. @@ -54,6 +54,22 @@ them to `nil` if you need to calculate their defaults based on other settings for now. +#### Naming convention + +A service is referred to mainly in two scenarios - when accessing the Chef +attributes corresponding to the service, and when referring to items such as +the users, groups, and paths corresponding to the service. In the attribute names, we use +underscores to differentiate words in the service name, while in other cases we +use hyphens to differentiate them. For example, if we take GitLab Pages, the +attributes are available as `Gitlab['gitlab_pages']` and `node['gitlab_pages']` +while the default directories and paths might look like +`/var/log/gitlab/gitlab-pages` and `/var/opt/gitlab/gitlab-pages`. + +NOTE: +The migration of existing services to use the underscored form while +accessing Chef attributes is underway. For current status, check the +corresponding [issue](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6873). + ### Create a configuration Mash for your service In order for user to be able to configure your service from `/etc/gitlab/gitlab.rb` @@ -63,11 +79,8 @@ `attribute` methods. If your service exists within the attributes for the GitLab cookbook, you should -add it within the `attribute_block('gitlab')` block. Otherwise, if your service -has its own cookbook, add it above. - -Add your service as an attribute, using an underscore to separate words, **even if you -used a hyphen in the default attributes.** +add it as an attribute within the `attribute_block('gitlab')` block. Otherwise, +if your service has its own cookbook, add it above. ```ruby attribute('best_service') @@ -96,10 +109,10 @@ # best_service['log_directory'] = '/var/log/gitlab/best-service' ``` -Use the underscore syntax here for word separation. The values provided are not -meant to reflect the defaults, but are to make it easier to uncomment to use the -service. If that isn't possible you can use values clearly meant to be replaced -like `YOURSECRET` etc. Or use the default when it makes the most sense. +The values provided are not meant to reflect the defaults, but are to make it +easier to uncomment to use the service. If that isn't possible you can use +values clearly meant to be replaced like `YOURSECRET` etc. Or use the default +when it makes the most sense. ## Include the service in the services list @@ -115,9 +128,8 @@ service 'best_service', groups: ['bestest'] ``` -We use the underscore word separation because these services act on the Mash -objects we created earlier. Specifying groups makes it easier to disable/enable -multiple related services as once. +Specifying groups makes it easier to disable/enable multiple related services as +once. If none of the existing groups match with what your service does, and you don't currently need to enable/disable the service using a group. Don't bother adding diff --git a/files/gitlab-cookbooks/gitlab-pages/attributes/default.rb b/files/gitlab-cookbooks/gitlab-pages/attributes/default.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvYXR0cmlidXRlcy9kZWZhdWx0LnJi..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvYXR0cmlidXRlcy9kZWZhdWx0LnJi 100644 --- a/files/gitlab-cookbooks/gitlab-pages/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab-pages/attributes/default.rb @@ -1,50 +1,50 @@ #### # GitLab Pages Daemon #### -default['gitlab-pages']['enable'] = false -default['gitlab-pages']['external_http'] = [] -default['gitlab-pages']['external_https'] = [] -default['gitlab-pages']['external_https_proxyv2'] = [] -default['gitlab-pages']['listen_proxy'] = "localhost:8090" -default['gitlab-pages']['gitlab_server'] = nil -default['gitlab-pages']['internal_gitlab_server'] = nil -default['gitlab-pages']['metrics_address'] = nil -default['gitlab-pages']['pages_path'] = nil -default['gitlab-pages']['enable_disk'] = nil -default['gitlab-pages']['domain'] = nil -default['gitlab-pages']['cert'] = nil -default['gitlab-pages']['cert_key'] = nil -default['gitlab-pages']['redirect_http'] = false -default['gitlab-pages']['use_http2'] = true -default['gitlab-pages']['dir'] = "/var/opt/gitlab/gitlab-pages" -default['gitlab-pages']['log_directory'] = "/var/log/gitlab/gitlab-pages" -default['gitlab-pages']['status_uri'] = nil -default['gitlab-pages']['max_connections'] = nil -default['gitlab-pages']['max_uri_length'] = nil -default['gitlab-pages']['log_format'] = "json" -default['gitlab-pages']['artifacts_server'] = true -default['gitlab-pages']['artifacts_server_url'] = nil -default['gitlab-pages']['artifacts_server_timeout'] = 10 -default['gitlab-pages']['propagate_correlation_id'] = false -default['gitlab-pages']['log_verbose'] = false -default['gitlab-pages']['access_control'] = false -default['gitlab-pages']['gitlab_id'] = nil -default['gitlab-pages']['gitlab_secret'] = nil -default['gitlab-pages']['auth_redirect_uri'] = nil -default['gitlab-pages']['auth_secret'] = nil -default['gitlab-pages']['auth_scope'] = nil -default['gitlab-pages']['auth_cookie_session_timeout'] = nil -default['gitlab-pages']['insecure_ciphers'] = false -default['gitlab-pages']['tls_min_version'] = nil -default['gitlab-pages']['tls_max_version'] = nil -default['gitlab-pages']['sentry_enabled'] = false -default['gitlab-pages']['sentry_dsn'] = nil -default['gitlab-pages']['sentry_environment'] = nil -default['gitlab-pages']['headers'] = nil -default['gitlab-pages']['api_secret_key'] = nil -default['gitlab-pages']['gitlab_client_http_timeout'] = nil -default['gitlab-pages']['server_shutdown_timeout'] = nil -default['gitlab-pages']['gitlab_client_jwt_expiry'] = nil -default['gitlab-pages']['env_directory'] = '/opt/gitlab/etc/gitlab-pages/env' +default['gitlab_pages']['enable'] = false +default['gitlab_pages']['external_http'] = [] +default['gitlab_pages']['external_https'] = [] +default['gitlab_pages']['external_https_proxyv2'] = [] +default['gitlab_pages']['listen_proxy'] = "localhost:8090" +default['gitlab_pages']['gitlab_server'] = nil +default['gitlab_pages']['internal_gitlab_server'] = nil +default['gitlab_pages']['metrics_address'] = nil +default['gitlab_pages']['pages_path'] = nil +default['gitlab_pages']['enable_disk'] = nil +default['gitlab_pages']['domain'] = nil +default['gitlab_pages']['cert'] = nil +default['gitlab_pages']['cert_key'] = nil +default['gitlab_pages']['redirect_http'] = false +default['gitlab_pages']['use_http2'] = true +default['gitlab_pages']['dir'] = "/var/opt/gitlab/gitlab-pages" +default['gitlab_pages']['log_directory'] = "/var/log/gitlab/gitlab-pages" +default['gitlab_pages']['status_uri'] = nil +default['gitlab_pages']['max_connections'] = nil +default['gitlab_pages']['max_uri_length'] = nil +default['gitlab_pages']['log_format'] = "json" +default['gitlab_pages']['artifacts_server'] = true +default['gitlab_pages']['artifacts_server_url'] = nil +default['gitlab_pages']['artifacts_server_timeout'] = 10 +default['gitlab_pages']['propagate_correlation_id'] = false +default['gitlab_pages']['log_verbose'] = false +default['gitlab_pages']['access_control'] = false +default['gitlab_pages']['gitlab_id'] = nil +default['gitlab_pages']['gitlab_secret'] = nil +default['gitlab_pages']['auth_redirect_uri'] = nil +default['gitlab_pages']['auth_secret'] = nil +default['gitlab_pages']['auth_scope'] = nil +default['gitlab_pages']['auth_cookie_session_timeout'] = nil +default['gitlab_pages']['insecure_ciphers'] = false +default['gitlab_pages']['tls_min_version'] = nil +default['gitlab_pages']['tls_max_version'] = nil +default['gitlab_pages']['sentry_enabled'] = false +default['gitlab_pages']['sentry_dsn'] = nil +default['gitlab_pages']['sentry_environment'] = nil +default['gitlab_pages']['headers'] = nil +default['gitlab_pages']['api_secret_key'] = nil +default['gitlab_pages']['gitlab_client_http_timeout'] = nil +default['gitlab_pages']['server_shutdown_timeout'] = nil +default['gitlab_pages']['gitlab_client_jwt_expiry'] = nil +default['gitlab_pages']['env_directory'] = '/opt/gitlab/etc/gitlab-pages/env' # Serving from zip archives fine grained configuration. # The recommended default values are set inside GitLab Pages. @@ -49,9 +49,9 @@ # Serving from zip archives fine grained configuration. # The recommended default values are set inside GitLab Pages. -default['gitlab-pages']['zip_cache_expiration'] = nil -default['gitlab-pages']['zip_cache_cleanup'] = nil -default['gitlab-pages']['zip_cache_refresh'] = nil -default['gitlab-pages']['zip_open_timeout'] = nil -default['gitlab-pages']['zip_http_client_timeout'] = nil +default['gitlab_pages']['zip_cache_expiration'] = nil +default['gitlab_pages']['zip_cache_cleanup'] = nil +default['gitlab_pages']['zip_cache_refresh'] = nil +default['gitlab_pages']['zip_open_timeout'] = nil +default['gitlab_pages']['zip_http_client_timeout'] = nil # API-based fine grained configuration. # The recommended default values are set inside GitLab Pages. @@ -56,9 +56,9 @@ # API-based fine grained configuration. # The recommended default values are set inside GitLab Pages. -default['gitlab-pages']['gitlab_cache_expiry'] = nil -default['gitlab-pages']['gitlab_cache_refresh'] = nil -default['gitlab-pages']['gitlab_cache_cleanup'] = nil -default['gitlab-pages']['gitlab_retrieval_timeout'] = nil -default['gitlab-pages']['gitlab_retrieval_interval'] = nil -default['gitlab-pages']['gitlab_retrieval_retries'] = nil +default['gitlab_pages']['gitlab_cache_expiry'] = nil +default['gitlab_pages']['gitlab_cache_refresh'] = nil +default['gitlab_pages']['gitlab_cache_cleanup'] = nil +default['gitlab_pages']['gitlab_retrieval_timeout'] = nil +default['gitlab_pages']['gitlab_retrieval_interval'] = nil +default['gitlab_pages']['gitlab_retrieval_retries'] = nil # Rate-limiting @@ -64,10 +64,10 @@ # Rate-limiting -default['gitlab-pages']['rate_limit_source_ip'] = nil -default['gitlab-pages']['rate_limit_source_ip_burst'] = nil -default['gitlab-pages']['rate_limit_domain'] = nil -default['gitlab-pages']['rate_limit_domain_burst'] = nil -default['gitlab-pages']['rate_limit_tls_source_ip'] = nil -default['gitlab-pages']['rate_limit_tls_source_ip_burst'] = nil -default['gitlab-pages']['rate_limit_tls_domain'] = nil -default['gitlab-pages']['rate_limit_tls_domain_burst'] = nil +default['gitlab_pages']['rate_limit_source_ip'] = nil +default['gitlab_pages']['rate_limit_source_ip_burst'] = nil +default['gitlab_pages']['rate_limit_domain'] = nil +default['gitlab_pages']['rate_limit_domain_burst'] = nil +default['gitlab_pages']['rate_limit_tls_source_ip'] = nil +default['gitlab_pages']['rate_limit_tls_source_ip_burst'] = nil +default['gitlab_pages']['rate_limit_tls_domain'] = nil +default['gitlab_pages']['rate_limit_tls_domain_burst'] = nil # HTTP Server timeouts @@ -73,7 +73,7 @@ # HTTP Server timeouts -default['gitlab-pages']['server_read_timeout'] = nil -default['gitlab-pages']['server_read_header_timeout'] = nil -default['gitlab-pages']['server_write_timeout'] = nil -default['gitlab-pages']['server_keep_alive'] = nil +default['gitlab_pages']['server_read_timeout'] = nil +default['gitlab_pages']['server_read_header_timeout'] = nil +default['gitlab_pages']['server_write_timeout'] = nil +default['gitlab_pages']['server_keep_alive'] = nil # _redirects file fine grained configuration. # The recommended default values are set inside GitLab Pages. @@ -78,6 +78,11 @@ # _redirects file fine grained configuration. # The recommended default values are set inside GitLab Pages. -default['gitlab-pages']['redirects_max_config_size'] = nil -default['gitlab-pages']['redirects_max_path_segments'] = nil -default['gitlab-pages']['redirects_max_rule_count'] = nil -default['gitlab-pages']['register_as_oauth_app'] = true +default['gitlab_pages']['redirects_max_config_size'] = nil +default['gitlab_pages']['redirects_max_path_segments'] = nil +default['gitlab_pages']['redirects_max_rule_count'] = nil +default['gitlab_pages']['register_as_oauth_app'] = true + +# Temporarily retain support for `node['gitlab-pages'][*]` usage in +# `/etc/gitlab/gitlab.rb` +# TODO: Remove support in 16.0 +default['gitlab-pages'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['gitlab_pages'].to_h }, "node['gitlab-pages']", "node['gitlab_pages']") diff --git a/files/gitlab-cookbooks/gitlab-pages/recipes/enable.rb b/files/gitlab-cookbooks/gitlab-pages/recipes/enable.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvcmVjaXBlcy9lbmFibGUucmI=..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvcmVjaXBlcy9lbmFibGUucmI= 100644 --- a/files/gitlab-cookbooks/gitlab-pages/recipes/enable.rb +++ b/files/gitlab-cookbooks/gitlab-pages/recipes/enable.rb @@ -17,9 +17,9 @@ account_helper = AccountHelper.new(node) omnibus_helper = OmnibusHelper.new(node) -working_dir = node['gitlab-pages']['dir'] -log_directory = node['gitlab-pages']['log_directory'] -env_directory = node['gitlab-pages']['env_directory'] +working_dir = node['gitlab_pages']['dir'] +log_directory = node['gitlab_pages']['log_directory'] +env_directory = node['gitlab_pages']['env_directory'] gitlab_pages_static_etc_dir = "/opt/gitlab/etc/gitlab-pages" pages_secret_path = File.join(working_dir, ".gitlab_pages_secret") @@ -42,10 +42,10 @@ GitlabPages.authorize_with_gitlab end - only_if { node['gitlab-pages']['access_control'] && node['gitlab-pages']['register_as_oauth_app'] } + only_if { node['gitlab_pages']['access_control'] && node['gitlab_pages']['register_as_oauth_app'] } end # Options may have changed in the previous step ruby_block "re-populate GitLab Pages configuration options" do block do node.consume_attributes( @@ -46,10 +46,10 @@ end # Options may have changed in the previous step ruby_block "re-populate GitLab Pages configuration options" do block do node.consume_attributes( - { 'gitlab-pages' => Gitlab.hyphenate_config_keys['gitlab-pages'] } + { 'gitlab_pages' => Gitlab.hyphenate_config_keys['gitlab_pages'] } ) end end @@ -70,7 +70,7 @@ owner 'root' group account_helper.gitlab_group mode "0640" - variables(secret_token: node['gitlab-pages']['api_secret_key']) + variables(secret_token: node['gitlab_pages']['api_secret_key']) notifies :restart, "runit_service[gitlab-pages]" end @@ -82,8 +82,8 @@ variables( lazy do { - pages_external_http: [node['gitlab-pages']['external_http']].flatten.compact, - pages_external_https: [node['gitlab-pages']['external_https']].flatten.compact, - pages_external_https_proxyv2: [node['gitlab-pages']['external_https_proxyv2']].flatten.compact, - pages_headers: [node['gitlab-pages']['headers']].flatten.compact, + pages_external_http: [node['gitlab_pages']['external_http']].flatten.compact, + pages_external_https: [node['gitlab_pages']['external_https']].flatten.compact, + pages_external_https_proxyv2: [node['gitlab_pages']['external_https_proxyv2']].flatten.compact, + pages_headers: [node['gitlab_pages']['headers']].flatten.compact, api_secret_key_path: pages_secret_path @@ -89,7 +89,7 @@ api_secret_key_path: pages_secret_path - }.merge(node['gitlab-pages'].to_hash) + }.merge(node['gitlab_pages'].to_hash) end ) notifies :restart, "runit_service[gitlab-pages]" end @@ -91,10 +91,10 @@ end ) notifies :restart, "runit_service[gitlab-pages]" end -node.default['gitlab-pages']['env'] = { +node.default['gitlab_pages']['env'] = { 'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/", } env_dir env_directory do @@ -97,8 +97,8 @@ 'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/", } env_dir env_directory do - variables node['gitlab-pages']['env'] + variables node['gitlab_pages']['env'] notifies :restart, "runit_service[gitlab-pages]" if omnibus_helper.should_notify?('gitlab-pages') end @@ -107,5 +107,5 @@ log_directory: log_directory, env_dir: env_directory, }.merge(params)) - log_options node['gitlab']['logging'].to_hash.merge(node['gitlab-pages'].to_hash) + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab_pages'].to_hash) end diff --git a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-log-run.erb b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-log-run.erb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2l0bGFiLXBhZ2VzLWxvZy1ydW4uZXJi..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2l0bGFiLXBhZ2VzLWxvZy1ydW4uZXJi 100644 --- a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-log-run.erb +++ b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-log-run.erb @@ -1,2 +1,2 @@ #!/bin/sh -exec svlogd <% unless node['gitlab-pages']['log_format'].eql?('json') %>-tt <% end %><%= @options[:log_directory] %> +exec svlogd <% unless node['gitlab_pages']['log_format'].eql?('json') %>-tt <% end %><%= @options[:log_directory] %> diff --git a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2l0bGFiLXBhZ2VzLXJ1bi5lcmI=..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItcGFnZXMvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2l0bGFiLXBhZ2VzLXJ1bi5lcmI= 100644 --- a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb +++ b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb @@ -5,5 +5,5 @@ exec 2>&1 <%= render("mount_point_check.erb") %> -cd <%= node['gitlab-pages']['dir'] %> +cd <%= node['gitlab_pages']['dir'] %> @@ -9,5 +9,5 @@ -<% headers = [ node['gitlab-pages']['headers'] ].flatten.compact %> +<% headers = [ node['gitlab_pages']['headers'] ].flatten.compact %> exec chpst -e <%= @options[:env_dir] %> \ /opt/gitlab/embedded/bin/gitlab-pages \ @@ -11,4 +11,4 @@ exec chpst -e <%= @options[:env_dir] %> \ /opt/gitlab/embedded/bin/gitlab-pages \ - -config="<%= node['gitlab-pages']['dir'] %>/gitlab-pages-config" \ + -config="<%= node['gitlab_pages']['dir'] %>/gitlab-pages-config" \ diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHMucmI=..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHMucmI= 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb @@ -300,11 +300,11 @@ gitlab_ci_all_broken_builds: node['gitlab']['gitlab-ci']['gitlab_ci_all_broken_builds'], gitlab_ci_add_pusher: node['gitlab']['gitlab-ci']['gitlab_ci_add_pusher'], builds_directory: gitlab_ci_builds_dir, - pages_external_http: node['gitlab-pages']['external_http'], - pages_external_https: node['gitlab-pages']['external_https'], - pages_external_https_proxyv2: node['gitlab-pages']['external_https_proxyv2'], - pages_artifacts_server: node['gitlab-pages']['artifacts_server'], - pages_access_control: node['gitlab-pages']['access_control'], + pages_external_http: node['gitlab_pages']['external_http'], + pages_external_https: node['gitlab_pages']['external_https'], + pages_external_https_proxyv2: node['gitlab_pages']['external_https_proxyv2'], + pages_artifacts_server: node['gitlab_pages']['artifacts_server'], + pages_access_control: node['gitlab_pages']['access_control'], pages_object_store_enabled: node['gitlab']['gitlab-rails']['pages_object_store_enabled'], pages_object_store_remote_directory: node['gitlab']['gitlab-rails']['pages_object_store_remote_directory'], pages_object_store_connection: node['gitlab']['gitlab-rails']['pages_object_store_connection'], @@ -389,5 +389,5 @@ group 'root' mode "0644" sensitive true - variables(secret_token: node['gitlab-pages']['api_secret_key']) + variables(secret_token: node['gitlab_pages']['api_secret_key']) gitlab_pages_services.each { |svc| notifies :restart, svc } @@ -393,5 +393,5 @@ gitlab_pages_services.each { |svc| notifies :restart, svc } - only_if { node['gitlab-pages']['api_secret_key'] } + only_if { node['gitlab_pages']['api_secret_key'] } end gitlab_kas_services = dependent_services diff --git a/files/gitlab-cookbooks/gitlab/recipes/nginx.rb b/files/gitlab-cookbooks/gitlab/recipes/nginx.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvcmVjaXBlcy9uZ2lueC5yYg==..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvcmVjaXBlcy9uZ2lueC5yYg== 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/nginx.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/nginx.rb @@ -219,7 +219,7 @@ variables(pages_nginx_vars.merge( { pages_path: node['gitlab']['gitlab-rails']['pages_path'], - pages_listen_proxy: node['gitlab-pages']['listen_proxy'] + pages_listen_proxy: node['gitlab_pages']['listen_proxy'] } )) notifies :restart, 'runit_service[nginx]' if omnibus_helper.should_notify?("nginx") diff --git a/files/gitlab-cookbooks/gitlab/templates/default/remote_syslog.yml.erb b/files/gitlab-cookbooks/gitlab/templates/default/remote_syslog.yml.erb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvdGVtcGxhdGVzL2RlZmF1bHQvcmVtb3RlX3N5c2xvZy55bWwuZXJi..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvdGVtcGxhdGVzL2RlZmF1bHQvcmVtb3RlX3N5c2xvZy55bWwuZXJi 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/remote_syslog.yml.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/remote_syslog.yml.erb @@ -1,6 +1,7 @@ files: <% @services.each do |service| %> - <% log_dir = node['gitlab'].has_key?(service) ? node['gitlab'][service]['log_directory'] : node[service]['log_directory'] %> + <% node_attribute_key = SettingsDSL::Utils.sanitized_key(service) %> + <% log_dir = node['gitlab'].has_key?(node_attribute_key) ? node['gitlab'][node_attribute_key]['log_directory'] : node[node_attribute_key]['log_directory'] %> - <%= File.join(log_dir, "*.log") %> <% end %> exclude_files: diff --git a/files/gitlab-cookbooks/package/libraries/deprecations.rb b/files/gitlab-cookbooks/package/libraries/deprecations.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9kZXByZWNhdGlvbnMucmI=..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9kZXByZWNhdGlvbnMucmI= 100644 --- a/files/gitlab-cookbooks/package/libraries/deprecations.rb +++ b/files/gitlab-cookbooks/package/libraries/deprecations.rb @@ -57,7 +57,7 @@ note: 'Use client_output_buffer_limit_replica instead' }, { - config_keys: %w(gitlab gitlab-pages http_proxy), + config_keys: %w(gitlab gitlab_pages http_proxy), deprecation: '13.1', removal: '14.0', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6137 note: "Set gitlab_pages['env']['http_proxy'] instead. See https://docs.gitlab.com/omnibus/settings/environment-variables.html" @@ -117,7 +117,7 @@ note: 'The config have been renamed, use analytics_usage_trends_count_job_trigger_worker_cron option.' }, { - config_keys: %w(gitlab-pages domain_config_source), + config_keys: %w(gitlab_pages domain_config_source), deprecation: '13.9', removal: '14.0', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6033 note: "Starting with GitLab 14.0, GitLab Pages only supports API-based configuration. Check https://docs.gitlab.com/ee/administration/pages/#deprecated-domain_config_source for details." @@ -129,9 +129,9 @@ note: "The config has been deprecated. Value for this directive in NGINX configuration will be controlled by `nginx['gzip_enabled']` setting in `/etc/gitlab/gitlab.rb`." }, { - config_keys: %w(gitlab-pages use_legacy_storage), + config_keys: %w(gitlab_pages use_legacy_storage), deprecation: '14.0', removal: '14.3', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6166 note: "This parameter was introduced as a temporary solution in case of unforseen problems with new storage format. It will be removed in 14.3. If you use this parameter, please comment on https://gitlab.com/gitlab-org/gitlab/-/issues/331699" }, { @@ -133,9 +133,9 @@ deprecation: '14.0', removal: '14.3', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6166 note: "This parameter was introduced as a temporary solution in case of unforseen problems with new storage format. It will be removed in 14.3. If you use this parameter, please comment on https://gitlab.com/gitlab-org/gitlab/-/issues/331699" }, { - config_keys: %w(gitlab-pages daemon-inplace-chroot), + config_keys: %w(gitlab_pages daemon-inplace-chroot), deprecation: '14.4', removal: '15.0', note: "Starting with GitLab 14.3, chroot has been removed along with disk-based configuration source. Because of this, the flag is a no-op and can be removed." diff --git a/files/gitlab-cookbooks/package/libraries/settings_dsl.rb b/files/gitlab-cookbooks/package/libraries/settings_dsl.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9zZXR0aW5nc19kc2wucmI=..b19102c055f0ed1057934ea701093dd542c39e3c_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9zZXR0aW5nc19kc2wucmI= 100644 --- a/files/gitlab-cookbooks/package/libraries/settings_dsl.rb +++ b/files/gitlab-cookbooks/package/libraries/settings_dsl.rb @@ -251,7 +251,7 @@ def sanitized_key(key) # Services that have been migrated to use underscored form in Chef code # and no longer needs to be hyphenated. - skip_hyphenation = %w[] + skip_hyphenation = %w[gitlab_pages] return underscored_form(key) if skip_hyphenation.include?(underscored_form(key)) diff --git a/spec/chef/cookbooks/gitlab/recipes/gitlab-rails_spec.rb b/spec/chef/cookbooks/gitlab/recipes/gitlab-rails_spec.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHNfc3BlYy5yYg==..b19102c055f0ed1057934ea701093dd542c39e3c_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHNfc3BlYy5yYg== 100644 --- a/spec/chef/cookbooks/gitlab/recipes/gitlab-rails_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/gitlab-rails_spec.rb @@ -1157,25 +1157,6 @@ end end - describe 'logrotate settings' do - context 'default values' do - it_behaves_like 'configured logrotate service', 'gitlab-pages', 'git', 'git' - end - - context 'specified username and group' do - before do - stub_gitlab_rb( - user: { - username: 'foo', - group: 'bar' - } - ) - end - - it_behaves_like 'configured logrotate service', 'gitlab-pages', 'foo', 'bar' - end - end - describe 'cleaning up the legacy sidekiq log symlink' do it 'removes the link if it existed' do allow(File).to receive(:symlink?).with('/var/log/gitlab/gitlab-rails/sidekiq.log') { true } diff --git a/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb b/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb index e511ee4c1662912f729b6a6744bb9defb32a2a11_c3BlYy9jaGVmL2Nvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9zZXR0aW5nc19kc2xfc3BlYy5yYg==..b19102c055f0ed1057934ea701093dd542c39e3c_c3BlYy9jaGVmL2Nvb2tib29rcy9wYWNrYWdlL2xpYnJhcmllcy9zZXR0aW5nc19kc2xfc3BlYy5yYg== 100644 --- a/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb +++ b/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb @@ -22,4 +22,23 @@ expect(subject.underscored_form('foo-bar')).to eq('foo_bar') end end + + describe '.sanitized_key' do + it 'returns underscored form for services specified to skip hyphenation' do + [ + %w[gitlab-pages gitlab_pages] + ].each do |input, output| + expect(subject.sanitized_key(input)).to eq(output) + end + end + + it 'returns hyphenated form for services not specified to skip hyphenation' do + [ + %w[foo-bar foo-bar], + %w[foo_bar foo-bar], + ].each do |input, output| + expect(subject.sanitized_key(input)).to eq(output) + end + end + end end