Move sync_db parameter to glance::api

Glance Registry will at some point be removed from puppet-glance once
API v1 is totally remove from Glance tree.
Some people using 100% v2 API don't need Glance Registry, so they don't
have to run glance::registry class. Though they need the db_sync, so
this patch aims to move the db_sync parameter from glance::registry to
glance::api.

The parameter in glance::registry is deprecated and will be removed in a
future release. Now people should use glance::api::sync_db.

Change-Id: Ib554edb13386845198140c87b0a9b931500656d2
This commit is contained in:
Emilien Macchi 2016-12-07 16:02:28 +01:00
parent e2a267aabe
commit 465cd11025
5 changed files with 33 additions and 11 deletions

View File

@ -238,6 +238,10 @@
# (Optional) Enable or not Glance API v2.
# Defaults to $::os_service_default.
#
# [*sync_db*]
# (Optional) Run db sync on the node.
# Defaults to true
#
# [*validate*]
# (optional) Whether to validate the service is working after any service refreshes
# Defaults to false
@ -321,6 +325,7 @@ class glance::api(
$enable_proxy_headers_parsing = $::os_service_default,
$enable_v1_api = $::os_service_default,
$enable_v2_api = $::os_service_default,
$sync_db = true,
$validate = false,
$validation_options = {},
# DEPRECATED PARAMETERS
@ -333,6 +338,10 @@ class glance::api(
include ::glance::api::logging
include ::glance::cache::logging
if $sync_db {
include ::glance::db::sync
}
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
ensure_packages('glance-api',
{

View File

@ -109,10 +109,6 @@
# (optional) CA certificate file to use to verify connecting clients
# Defaults to $::os_service_default.
#
# [*sync_db*]
# (Optional) Run db sync on the node.
# Defaults to true
#
# [*os_region_name*]
# (optional) Sets the keystone region to use.
# Defaults to $::os_service_default.
@ -125,6 +121,12 @@
# should be set to False.
# Defaults to $::os_service_default.
#
# DEPRECATED PARAMETERS
#
# [*sync_db*]
# (Optional) Run db sync on the node.
# Defaults to undef
#
class glance::registry(
$package_ensure = 'present',
$debug = undef,
@ -151,9 +153,10 @@ class glance::registry(
$cert_file = $::os_service_default,
$key_file = $::os_service_default,
$ca_file = $::os_service_default,
$sync_db = true,
$os_region_name = $::os_service_default,
$enable_v1_registry = $::os_service_default,
# DEPRECATED
$sync_db = undef,
) inherits glance {
include ::glance::deps
@ -206,6 +209,7 @@ class glance::registry(
}
if $sync_db {
warning('sync_db is deprecated in glance::registry. This option will be removed in a future release. Please use glance::api::sync_db.')
include ::glance::db::sync
}

View File

@ -0,0 +1,6 @@
---
deprecations:
- Deprecate glance::registry::sync_db. The option will be removed in a future release.
Now we should use glance::api::sync_db.
The reason of this change is because Glance Registry is no longer required with API v2
and API v1 has been deprecated since Mitaka.

View File

@ -44,6 +44,7 @@ describe 'glance::api' do
:conversion_format => '<SERVICE DEFAULT>',
:enable_v1_api => '<SERVICE DEFAULT>',
:enable_v2_api => '<SERVICE DEFAULT>',
:sync_db => true,
}
end
@ -70,6 +71,7 @@ describe 'glance::api' do
:image_cache_max_size => '10737418240',
:os_region_name => 'RegionOne2',
:pipeline => 'keystone2',
:sync_db => false,
}
].each do |param_set|
@ -88,6 +90,13 @@ describe 'glance::api' do
it { is_expected.to contain_class 'glance::api::logging' }
it { is_expected.to contain_class 'glance::api::db' }
it 'is_expected.to not sync the db if sync_db is set to false' do
if !param_hash[:sync_db]
is_expected.not_to contain_exec('glance-manage db_sync')
end
end
it { is_expected.to contain_service('glance-api').with(
'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
'enable' => param_hash[:enabled],

View File

@ -63,12 +63,6 @@ describe 'glance::registry' do
it { is_expected.to contain_service('glance-registry').that_subscribes_to('Anchor[glance::service::begin]')}
it { is_expected.to contain_service('glance-registry').that_notifies('Anchor[glance::service::end]')}
it 'is_expected.to not sync the db if sync_db is set to false' do
if !param_hash[:sync_db]
is_expected.not_to contain_exec('glance-manage db_sync')
end
end
it 'passes purge to resource' do
is_expected.to contain_resources('glance_registry_config').with({
:purge => false