Remove deprecated registry service

The glance registry has been deprecated upstream [1] and needs to be removed.
This removes all references to the registry service and moves the db migration
to the api recipe.

[1] https://blueprints.launchpad.net/glance/+spec/deprecate-registry

Depends-On: https://review.opendev.org/690410
Change-Id: I356aa65e63032e7866470ad507e5c9bce793a52b
Signed-off-by: Lance Albertson <lance@osuosl.org>
This commit is contained in:
Lance Albertson 2019-10-22 12:13:26 -07:00
parent 13c672e052
commit cf08cbb527
9 changed files with 10 additions and 358 deletions

View File

@ -17,7 +17,6 @@ Style/IfUnlessModifier:
Exclude: Exclude:
- 'recipes/api.rb' - 'recipes/api.rb'
- 'recipes/image_upload.rb' - 'recipes/image_upload.rb'
- 'recipes/registry.rb'
# Offense count: 97 # Offense count: 97
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.

View File

@ -49,8 +49,8 @@ descriptions of all the settable attributes for this cookbook.
Note that all attributes are in the `default['openstack']` "namespace" Note that all attributes are in the `default['openstack']` "namespace"
The usage of attributes to generate the glance-api.conf glance-registry.conf is The usage of attributes to generate the glance-api.conf is described in the
decribed in the openstack-common cookbook. openstack-common cookbook.
Recipes Recipes
======= =======
@ -64,14 +64,11 @@ Recipes
## openstack-image::identityr_registration ## openstack-image::identityr_registration
- Registers the API endpoint and glance service Keystone user - Registers the API endpoint and glance service Keystone user
## openstack-image::registry
- Installs the glance-registry server
## openstack-image::image-upload ## openstack-image::image-upload
- Upload image to glance. If you want to upload image during openstack - Upload image to glance. If you want to upload image during openstack
installation, you need to add this recipe or the os-image role to the run list installation, you need to add this recipe or the os-image role to the run list
in a certain role and ensure before this recipe or the os-image role glance api in a certain role and ensure before this recipe or the os-image role glance api
and glance registry recipes have been executed. recipes have been executed.
Glance Backend Glance Backend
============== ==============

View File

@ -28,12 +28,10 @@ default['openstack']['image']['custom_template_banner'] = '
' '
# SSL Options # SSL Options
# Enable SSL for glance api and registry bind endpoints. # Enable SSL for glance api bind endpoints.
default['openstack']['image']['ssl']['enabled'] = false default['openstack']['image']['ssl']['enabled'] = false
# Enable SSL for glance api bind endpoint. # Enable SSL for glance api bind endpoint.
default['openstack']['image']['ssl']['api']['enabled'] = node['openstack']['image']['ssl']['enabled'] default['openstack']['image']['ssl']['api']['enabled'] = node['openstack']['image']['ssl']['enabled']
# Enable SSL for glance registry bind endpoint.
default['openstack']['image']['ssl']['registry']['enabled'] = node['openstack']['image']['ssl']['enabled']
# Base directory for SSL certficate and key # Base directory for SSL certficate and key
default['openstack']['image']['ssl']['basedir'] = '/etc/glance/ssl' default['openstack']['image']['ssl']['basedir'] = '/etc/glance/ssl'
@ -68,6 +66,10 @@ default['openstack']['image']['cache']['dir'] = '/var/lib/glance/image-cache/'
# Number of seconds to leave invalid images around before they are eligible to be reaped # Number of seconds to leave invalid images around before they are eligible to be reaped
default['openstack']['image']['cache']['grace_period'] = 3600 default['openstack']['image']['cache']['grace_period'] = 3600
# Default configuration for image cache and scrubber
default['openstack']['image_cache']['conf'] = {}
default['openstack']['image_scrubber']['conf'] = {}
# Default Image Locations # Default Image Locations
default['openstack']['image']['upload_images'] = ['cirros'] default['openstack']['image']['upload_images'] = ['cirros']
default['openstack']['image']['upload_image']['artful'] = 'http://cloud-images.ubuntu.com/artful/current/artful-server-cloudimg-amd64-disk1.img' default['openstack']['image']['upload_image']['artful'] = 'http://cloud-images.ubuntu.com/artful/current/artful-server-cloudimg-amd64-disk1.img'
@ -99,7 +101,6 @@ when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
'image_packages' => %w(openstack-glance cronie), 'image_packages' => %w(openstack-glance cronie),
'swift_packages' => ['openstack-swift'], 'swift_packages' => ['openstack-swift'],
'image_api_service' => 'openstack-glance-api', 'image_api_service' => 'openstack-glance-api',
'image_registry_service' => 'openstack-glance-registry',
'image_api_process_name' => 'glance-api', 'image_api_process_name' => 'glance-api',
'package_overrides' => '', 'package_overrides' => '',
} }
@ -110,7 +111,6 @@ when 'suse'
'image_packages' => ['openstack-glance'], 'image_packages' => ['openstack-glance'],
'swift_packages' => ['openstack-swift'], 'swift_packages' => ['openstack-swift'],
'image_api_service' => 'openstack-glance-api', 'image_api_service' => 'openstack-glance-api',
'image_registry_service' => 'openstack-glance-registry',
'image_api_process_name' => 'glance-api', 'image_api_process_name' => 'glance-api',
'package_overrides' => '', 'package_overrides' => '',
} }
@ -121,8 +121,6 @@ when 'debian'
'image_packages' => ['glance'], 'image_packages' => ['glance'],
'swift_packages' => ['python-swift'], 'swift_packages' => ['python-swift'],
'image_api_service' => 'glance-api', 'image_api_service' => 'glance-api',
'image_registry_service' => 'glance-registry',
'image_registry_process_name' => 'glance-registry',
'package_overrides' => '', 'package_overrides' => '',
} }
end end
@ -130,17 +128,13 @@ end
# ******************** OpenStack Image Endpoints ****************************** # ******************** OpenStack Image Endpoints ******************************
# The OpenStack Image (Glance) endpoints # The OpenStack Image (Glance) endpoints
%w(public internal admin).each do |ep_type| %w(public internal).each do |ep_type|
%w(image_api image_registry).each do |service| %w(image_api).each do |service|
default['openstack']['endpoints'][ep_type][service]['scheme'] = 'http' default['openstack']['endpoints'][ep_type][service]['scheme'] = 'http'
default['openstack']['endpoints'][ep_type][service]['host'] = '127.0.0.1' default['openstack']['endpoints'][ep_type][service]['host'] = '127.0.0.1'
default['openstack']['endpoints'][ep_type]['image_api']['path'] = '' default['openstack']['endpoints'][ep_type]['image_api']['path'] = ''
default['openstack']['endpoints'][ep_type]['image_api']['port'] = 9292 default['openstack']['endpoints'][ep_type]['image_api']['port'] = 9292
default['openstack']['endpoints'][ep_type]['image_registry']['path'] = '/v3'
default['openstack']['endpoints'][ep_type]['image_registry']['port'] = 9191
end end
end end
default['openstack']['bind_service']['all']['image_registry']['host'] = '127.0.0.1'
default['openstack']['bind_service']['all']['image_registry']['port'] = 9191
default['openstack']['bind_service']['all']['image_api']['host'] = '127.0.0.1' default['openstack']['bind_service']['all']['image_api']['host'] = '127.0.0.1'
default['openstack']['bind_service']['all']['image_api']['port'] = 9292 default['openstack']['bind_service']['all']['image_api']['port'] = 9292

View File

@ -1,19 +0,0 @@
default['openstack']['image_registry']['conf'].tap do |conf|
# [DEFAULT] section
if node['openstack']['image']['syslog']['use']
conf['DEFAULT']['log_config'] = '/etc/openstack/logging.conf'
else
conf['DEFAULT']['log_file'] = '/var/log/glance/registry.log'
end
# [paste_deploy] section
conf['paste_deploy']['flavor'] = 'keystone'
# [keystone_authtoken] section
conf['keystone_authtoken']['auth_type'] = 'v3password'
conf['keystone_authtoken']['region_name'] = node['openstack']['region']
conf['keystone_authtoken']['username'] = 'glance'
conf['keystone_authtoken']['project_name'] = 'service'
conf['keystone_authtoken']['user_domain_name'] = 'Default'
conf['keystone_authtoken']['project_domain_name'] = 'Default'
end

View File

@ -74,7 +74,6 @@ if node['openstack']['mq']['service_type'] == 'rabbit'
node.default['openstack']['image_api']['conf_secrets']['DEFAULT']['transport_url'] = rabbit_transport_url 'image' node.default['openstack']['image_api']['conf_secrets']['DEFAULT']['transport_url'] = rabbit_transport_url 'image'
end end
registry_endpoint = internal_endpoint 'image_registry'
api_bind = node['openstack']['bind_service']['all']['image_api'] api_bind = node['openstack']['bind_service']['all']['image_api']
api_bind_address = bind_address api_bind api_bind_address = bind_address api_bind
@ -82,25 +81,10 @@ node.default['openstack']['image_api']['conf'].tap do |conf|
# [DEFAULT] section # [DEFAULT] section
conf['DEFAULT']['bind_host'] = api_bind_address conf['DEFAULT']['bind_host'] = api_bind_address
conf['DEFAULT']['bind_port'] = api_bind['port'] conf['DEFAULT']['bind_port'] = api_bind['port']
conf['DEFAULT']['registry_host'] = registry_endpoint.host
conf['DEFAULT']['registry_port'] = registry_endpoint.port
conf['DEFAULT']['registry_client_protocol'] = registry_endpoint.scheme
# [keystone_authtoken] section # [keystone_authtoken] section
conf['keystone_authtoken']['auth_url'] = auth_url conf['keystone_authtoken']['auth_url'] = auth_url
end end
node.default['openstack']['image_cache']['conf'].tap do |conf|
# [DEFAULT] section
conf['DEFAULT']['registry_host'] = registry_endpoint.host
conf['DEFAULT']['registry_port'] = registry_endpoint.port
end
node.default['openstack']['image_scrubber']['conf'].tap do |conf|
# [DEFAULT] section
conf['DEFAULT']['registry_host'] = registry_endpoint.host
conf['DEFAULT']['registry_port'] = registry_endpoint.port
end
# merge all config options and secrets # merge all config options and secrets
glance_api_conf = merge_config_options 'image_api' glance_api_conf = merge_config_options 'image_api'
glance_cache_conf = merge_config_options 'image_cache' glance_cache_conf = merge_config_options 'image_cache'

View File

@ -1,106 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-image
# Recipe:: registry
#
# Copyright 2012, Rackspace US, Inc.
# Copyright 2013, Opscode, Inc.
# Copyright 2014, SUSE Linux, GmbH.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class ::Chef::Recipe
include ::Openstack
end
if node['openstack']['image']['syslog']['use']
include_recipe 'openstack-common::logging'
end
platform_options = node['openstack']['image']['platform']
db_user = node['openstack']['db']['image']['username']
db_pass = get_password 'db', 'glance'
node.default['openstack']['image_registry']['conf_secrets']
.[]('database')['connection'] = db_uri('image', db_user, db_pass)
if node['openstack']['mq']['service_type'] == 'rabbit'
node.default['openstack']['image_registry']['conf_secrets']['DEFAULT']['transport_url'] = rabbit_transport_url 'image'
end
registry_bind = node['openstack']['bind_service']['all']['image_registry']
registry_bind_address = bind_address registry_bind
node.default['openstack']['image_registry']['conf_secrets']
.[]('keystone_authtoken')['password'] = get_password 'service', 'openstack-image'
identity_endpoint = internal_endpoint 'identity'
auth_url = ::URI.decode identity_endpoint.to_s
db_type = node['openstack']['db']['image']['service_type']
node['openstack']['db']['python_packages'][db_type].each do |pkg|
package pkg do
action :upgrade
options platform_options['package_overrides']
end
end
platform_options['image_packages'].each do |pkg|
package pkg do
action :upgrade
options platform_options['package_overrides']
end
end
file '/var/lib/glance/glance.sqlite' do
action :delete
not_if { node['openstack']['db']['image']['service_type'] == 'sqlite' }
end
node.default['openstack']['image_registry']['conf'].tap do |conf|
# [DEFAULT] section
conf['DEFAULT']['bind_host'] = registry_bind_address
conf['DEFAULT']['bind_port'] = registry_bind['port']
# [keystone_authtoken] section
conf['keystone_authtoken']['auth_url'] = auth_url
end
# merge all config options and secrets to be used in the nova.conf.erb
glance_registry_conf_options = merge_config_options 'image_registry'
template '/etc/glance/glance-registry.conf' do
source 'openstack-service.conf.erb'
cookbook 'openstack-common'
owner node['openstack']['image']['user']
group node['openstack']['image']['group']
mode 0o0640
variables(
service_config: glance_registry_conf_options
)
end
# delete all secrets saved in the attribute
# node['openstack']['image_registry']['conf_secrets'] after creating the glance-registry.conf
ruby_block "delete all attributes in node['openstack']['image_registry']['conf_secrets']" do
block do
node.rm(:openstack, :image_registry, :conf_secrets)
end
end
service 'glance-registry' do
service_name platform_options['image_registry_service']
supports status: true, restart: true
action [:enable, :start]
subscribes :restart, 'template[/etc/glance/glance-registry.conf]', :immediately
end

View File

@ -57,9 +57,6 @@ describe 'openstack-image::api' do
%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$},
/^bind_host = 127.0.0.1$/, /^bind_host = 127.0.0.1$/,
/^bind_port = 9292$/, /^bind_port = 9292$/,
/^registry_host = 127.0.0.1$/,
/^registry_port = 9191$/,
/^registry_client_protocol = http$/,
].each do |line| ].each do |line|
expect(chef_run).to render_config_file(file.name) expect(chef_run).to render_config_file(file.name)
.with_section_content('DEFAULT', line) .with_section_content('DEFAULT', line)
@ -123,18 +120,6 @@ describe 'openstack-image::api' do
mode: 0o0640 mode: 0o0640
) )
end end
context 'template contents' do
it do
[
/^registry_port = 9191$/,
/^registry_host = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('DEFAULT', line)
end
end
end
end end
describe 'glance-scrubber.conf' do describe 'glance-scrubber.conf' do
@ -150,18 +135,6 @@ describe 'openstack-image::api' do
mode: 0o0640 mode: 0o0640
) )
end end
context 'template contents' do
it do
[
/^registry_port = 9191$/,
/^registry_host = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('DEFAULT', line)
end
end
end
end end
it do it do

View File

@ -1,44 +0,0 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-image::registry' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
runner.converge(described_recipe)
end
include_context 'image-stubs'
it 'converges when configured to use sqlite' do
node.override['openstack']['db']['image']['service_type'] = 'sqlite'
expect { chef_run }.to_not raise_error
end
it 'does not upgrade keystoneclient package' do
expect(chef_run).not_to upgrade_package('python-keystoneclient')
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package('MySQL-python')
end
it 'upgrades glance packages' do
expect(chef_run).to upgrade_package('openstack-glance')
expect(chef_run).to upgrade_package('cronie')
end
it 'starts glance registry on boot' do
expect(chef_run).to enable_service('openstack-glance-registry')
end
it 'does not version the database' do
stub_command('glance-manage db_version').and_return(false)
cmd = 'glance-manage version_control 0'
expect(chef_run).not_to run_execute(cmd)
end
end
end

View File

@ -1,126 +0,0 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-image::registry' do
describe 'ubuntu' do
before do
# Lame we must still stub this, since the recipe contains shell
# guards. Need to work on a way to resolve this.
stub_command('glance-manage db_version').and_return(true)
end
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
runner.converge(described_recipe)
end
include_context 'image-stubs'
it 'converges when configured to use sqlite' do
node.override['openstack']['db']['image']['service_type'] = 'sqlite'
expect { chef_run }.to_not raise_error
end
it 'upgrades mysql python package' do
expect(chef_run).to upgrade_package('python-mysqldb')
end
%w(db2 postgresql).each do |service_type|
it "upgrades #{service_type} python packages if chosen" do
node.override['openstack']['db']['image']['service_type'] = service_type
node.override['openstack']['db']['python_packages'][service_type] = ["my-#{service_type}-py"]
expect(chef_run).to upgrade_package("my-#{service_type}-py")
end
end
it 'deletes glance.sqlite' do
expect(chef_run).to delete_file('/var/lib/glance/glance.sqlite')
end
it 'does not delete glance.sqlite when configured to use sqlite' do
node.override['openstack']['db']['image']['service_type'] = 'sqlite'
expect(chef_run).not_to delete_file('/var/lib/glance/glance.sqlite')
end
describe 'glance-registry.conf' do
let(:file) { chef_run.template('/etc/glance/glance-registry.conf') }
it 'creates glance-registry.conf' do
expect(chef_run).to create_template(file.name).with(
source: 'openstack-service.conf.erb',
cookbook: 'openstack-common',
user: 'glance',
group: 'glance',
mode: 0o0640
)
end
context 'template contents' do
it do
[
%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$},
%r{^log_file = /var/log/glance/registry.log$},
/^bind_port = 9191$/,
/^bind_host = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('DEFAULT', line)
end
end
it do
[
/^flavor = keystone$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('paste_deploy', line)
end
end
it do
[
/^auth_type = v3password$/,
/^region_name = RegionOne$/,
/^username = glance$/,
/^project_name = service/,
%r{^auth_url = http://127.0.0.1:5000/v3},
/^user_domain_name = Default$/,
/^password = glance-pass$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('keystone_authtoken', line)
end
end
it do
[
%r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$},
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('database', line)
end
end
end
end
it do
expect(chef_run).to run_ruby_block(
"delete all attributes in node['openstack']['image_registry']['conf_secrets']"
)
end
it do
expect(chef_run).to enable_service('glance-registry')
end
it do
expect(chef_run).to start_service('glance-registry')
end
it do
resource = chef_run.service('glance-registry')
expect(resource).to subscribe_to('template[/etc/glance/glance-registry.conf]').on(:restart).immediately
end
end
end