Enable compute node micro-services

nova::compute::libvirt was a class that deployed both libvirt (+
external services related to it) and nova-compute bits (mainly
configuration).

In the micro-services use-case, we want individual services, that can
run alone in containers. To allow it, we need to split the nova compute
configuration when libvirt is configured and the libvirt deployment.

This patch aims to create nova::compute::libvirt::services that contain
the bits from nova::compute::libvirt that used to deploy Libvirt and
some other packages / services related to it.

We keep backward compatibility by declaring the new class in
nova::compute::libvirt but allow to disable it and select what we
actually need thanks to parameters (we support hiera & non-hiera, see
code for comments that document it).

This is a first iteration of micro services for Compute nodes, soon
we'll also work on nova::migration class to separate nova-compute &
libvirt bits again.

Change-Id: Ib0d3111560af5af451e522c6dc3b3918d0463e7d
This commit is contained in:
Emilien Macchi
2016-06-14 18:03:30 -04:00
parent f85583a5f2
commit 050c1926fb
5 changed files with 207 additions and 63 deletions

View File

@@ -97,6 +97,13 @@
# (optional) Compute driver.
# Defaults to 'libvirt.LibvirtDriver'
#
# [*manage_libvirt_services*]
# (optional) Whether or not deploy Libvirt services.
# In the case of micro-services, set it to False and use
# nova::compute::libvirt::services + hiera to select what
# you actually want to deploy.
# Defaults to true for backward compatibility.
#
# DEPRECATED
#
# [*remove_unused_kernels*]
@@ -126,6 +133,7 @@ class nova::compute::libvirt (
$virtlock_service_name = $::nova::params::virtlock_service_name,
$virtlog_service_name = $::nova::params::virtlog_service_name,
$compute_driver = 'libvirt.LibvirtDriver',
$manage_libvirt_services = true,
# Deprecated
$remove_unused_kernels = undef,
) inherits nova::params {
@@ -133,8 +141,6 @@ class nova::compute::libvirt (
include ::nova::deps
include ::nova::params
Service['libvirt'] -> Service['nova-compute']
# libvirt_cpu_mode has different defaults depending on hypervisor.
if !$libvirt_cpu_mode {
case $libvirt_virt_type {
@@ -156,75 +162,35 @@ class nova::compute::libvirt (
}
}
if($::osfamily == 'RedHat' and $::operatingsystem != 'Fedora') {
service { 'messagebus':
ensure => running,
enable => true,
name => $::nova::params::messagebus_service_name,
provider => $::nova::params::special_service_provider,
}
Package['libvirt'] -> Service['messagebus'] -> Service['libvirt']
}
if $migration_support {
if $vncserver_listen != '0.0.0.0' and $vncserver_listen != '::0' {
fail('For migration support to work, you MUST set vncserver_listen to \'0.0.0.0\' or \'::0\'')
} else {
# TODO(emilien): explode ::nova::migration::libvirt to select what bits we want to configure
# and allow micro services between libvirt & nova-compute.
include ::nova::migration::libvirt
}
}
if $::osfamily == 'RedHat' {
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
}
case $libvirt_virt_type {
'qemu': {
$libvirt_package_name_real = "${::nova::params::libvirt_daemon_package_prefix}kvm"
}
default: {
$libvirt_package_name_real = "${::nova::params::libvirt_daemon_package_prefix}${libvirt_virt_type}"
}
}
} else {
$libvirt_package_name_real = $::nova::params::libvirt_package_name
}
package { 'libvirt':
ensure => present,
name => $libvirt_package_name_real,
tag => ['openstack', 'nova-support-package'],
}
service { 'libvirt' :
ensure => running,
enable => true,
name => $libvirt_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt'],
}
if $virtlock_service_name {
service { 'virtlockd':
ensure => running,
enable => true,
name => $virtlock_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt']
}
}
if $virtlog_service_name {
service { 'virtlogd':
ensure => running,
enable => true,
name => $virtlog_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt']
# manage_libvirt_services is here for backward compatibility to support
# deployments that do not include nova::compute::libvirt::services
#
# If you're using hiera:
# - set nova::compute::libvirt::manage_libvirt_services to false
# - include ::nova::compute::libvirt::services in your composition layer
# - select which services you want to deploy with
# ::nova::compute::libvirt::services:* parameters.
#
# If you're not using hiera:
# - set nova::compute::libvirt::manage_libvirt_services to true (default).
# - select which services you want to deploy with
# ::nova::compute::libvirt::*_service_name parameters.
if $manage_libvirt_services {
class { '::nova::compute::libvirt::services':
libvirt_service_name => $libvirt_service_name,
virtlock_service_name => $virtlock_service_name,
virtlog_service_name => $virtlog_service_name,
libvirt_virt_type => $libvirt_virt_type,
}
}

View File

@@ -0,0 +1,105 @@
# == Class: nova::compute::libvirt::services
#
# Install and manage libvirt services.
#
# === Parameters:
#
# [*libvirt_service_name*]
# (optional) libvirt service name.
# Defaults to $::nova::params::libvirt_service_name
#
# [*virtlock_service_name*]
# (optional) virtlock service name.
# Defaults to $::nova::params::virtlock_service_name
#
# [*virtlog_service_name*]
# (optional) virtlog service name.
# Defaults to $::nova::params::virtlog_service_name
#
# [*libvirt_virt_type*]
# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen
# Defaults to 'kvm'
#
class nova::compute::libvirt::services (
$libvirt_service_name = $::nova::params::libvirt_service_name,
$virtlock_service_name = $::nova::params::virtlock_service_name,
$virtlog_service_name = $::nova::params::virtlog_service_name,
$libvirt_virt_type = 'kvm',
) inherits nova::params {
include ::nova::deps
include ::nova::params
if $libvirt_service_name {
# messagebus
if($::osfamily == 'RedHat' and $::operatingsystem != 'Fedora') {
service { 'messagebus':
ensure => running,
enable => true,
name => $::nova::params::messagebus_service_name,
provider => $::nova::params::special_service_provider,
}
Package['libvirt'] -> Service['messagebus'] -> Service['libvirt']
}
# libvirt-nwfilter
if $::osfamily == 'RedHat' {
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
}
case $libvirt_virt_type {
'qemu': {
$libvirt_package_name_real = "${::nova::params::libvirt_daemon_package_prefix}kvm"
}
default: {
$libvirt_package_name_real = "${::nova::params::libvirt_daemon_package_prefix}${libvirt_virt_type}"
}
}
} else {
$libvirt_package_name_real = $::nova::params::libvirt_package_name
}
# libvirt
package { 'libvirt':
ensure => present,
name => $libvirt_package_name_real,
tag => ['openstack', 'nova-support-package'],
}
service { 'libvirt' :
ensure => running,
enable => true,
name => $libvirt_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt'],
}
# when nova-compute & libvirt run together
Service['libvirt'] -> Service<| title == 'nova-compute'|>
}
if $virtlock_service_name {
service { 'virtlockd':
ensure => running,
enable => true,
name => $virtlock_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt']
}
}
if $virtlog_service_name {
service { 'virtlogd':
ensure => running,
enable => true,
name => $virtlog_service_name,
provider => $::nova::params::special_service_provider,
require => Package['libvirt']
}
}
}

View File

@@ -0,0 +1,7 @@
---
features:
- Enable puppet-nova to deploy micro-services where libvirt & nova-compute
are separated. With a new class, nova::compute::libvirt::services, we're now
able to manage libvirt packages & services outside nova-compute.
This class is included by default in nova::compute::libvirt for backward
compatibility but can be disabled if you deploy compute services on containers.

View File

@@ -0,0 +1,36 @@
require 'spec_helper'
describe 'nova::compute::libvirt::services' do
shared_examples_for 'nova compute libvirt services' do
context 'with default parameters' do
it 'deploys libvirt packages and services' do
is_expected.to contain_package('libvirt')
is_expected.to contain_service('libvirt')
end
end
context 'with overridden parameters' do
let :params do
{ :libvirt_service_name => false }
end
it 'disable libvirt service' do
is_expected.not_to contain_package('libvirt')
is_expected.not_to contain_service('libvirt')
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova compute libvirt services'
end
end
end

View File

@@ -175,6 +175,21 @@ describe 'nova::compute::libvirt' do
end
end
describe 'when manage_libvirt_services is set to false' do
context 'without libvirt packages & services' do
let :params do
{ :manage_libvirt_services => false }
end
it { is_expected.not_to contain_package('libvirt') }
it { is_expected.not_to contain_service('libvirt') }
it { is_expected.not_to contain_package('libvirt-nwfilter') }
it { is_expected.not_to contain_service('messagebus') }
it { is_expected.not_to contain_service('virtlockd') }
it { is_expected.not_to contain_service('virtlogd') }
end
end
end
@@ -303,6 +318,21 @@ describe 'nova::compute::libvirt' do
end
end
describe 'when manage_libvirt_services is set to false' do
context 'without libvirt packages & services' do
let :params do
{ :manage_libvirt_services => false }
end
it { is_expected.not_to contain_package('libvirt') }
it { is_expected.not_to contain_service('libvirt') }
it { is_expected.not_to contain_package('libvirt-nwfilter') }
it { is_expected.not_to contain_service('messagebus') }
it { is_expected.not_to contain_service('virtlockd') }
it { is_expected.not_to contain_service('virtlogd') }
end
end
describe 'with default parameters on Fedora' do
before do
facts.merge!({ :operatingsystem => 'Fedora', :osfamily => 'RedHat' })