From f97b186bfdbaac727c1e418f4c4061f1ddd8349d Mon Sep 17 00:00:00 2001 From: Michael Polenchuk Date: Mon, 1 Feb 2016 18:51:46 +0300 Subject: [PATCH] Fix idempotency of compute tasks * make one entry point for network_device_mtu * disable start of nova-compute service * mend of cpufrequtils resources DocImpact: "integration bridge waiting" has been moved to enable_nova_compute_service task where it actually should be used. Change-Id: Ide46e5053dadeb41b7fdafcdc3b49fd6db1b8f3d Closes-Bug: #1526895 --- .../puppet/openstack/manifests/compute.pp | 22 +++++----- .../spec/classes/openstack_compute_spec.rb | 40 +++++++++++++++---- .../modular/astute/enable_compute.pp | 23 ++++++++++- .../modular/openstack-network/compute-nova.pp | 23 ----------- .../spec/hosts/astute/enable_compute_spec.rb | 33 ++++++++++++--- .../openstack-network/compute-nova_spec.rb | 20 +--------- 6 files changed, 93 insertions(+), 68 deletions(-) diff --git a/deployment/puppet/openstack/manifests/compute.pp b/deployment/puppet/openstack/manifests/compute.pp index b5c7eace6e..51dfd25210 100644 --- a/deployment/puppet/openstack/manifests/compute.pp +++ b/deployment/puppet/openstack/manifests/compute.pp @@ -141,6 +141,7 @@ class openstack::compute ( $install_bridge_utils = false, $compute_driver = 'libvirt.LibvirtDriver', $config_drive_format = undef, + $network_device_mtu = '65000', ) { include ::nova::params @@ -310,6 +311,7 @@ class openstack::compute ( #NOTE(bogdando) default became true in 4.0.0 puppet-nova (was false) neutron_enabled => ($network_provider == 'neutron'), install_bridge_utils => $install_bridge_utils, + network_device_mtu => $network_device_mtu, instance_usage_audit => $instance_usage_audit, instance_usage_audit_period => $instance_usage_audit_period, reserved_host_memory => $nova_hash['reserved_host_memory'], @@ -380,24 +382,23 @@ class openstack::compute ( # From legacy libvirt.pp if $::operatingsystem == 'Ubuntu' { - package { 'cpufrequtils': ensure => present; } file { '/etc/default/cpufrequtils': - content => "GOVERNOR=\"performance\" \n", + content => "GOVERNOR=\"performance\"\n", require => Package['cpufrequtils'], notify => Service['cpufrequtils'], } service { 'cpufrequtils': - name => 'cpufrequtils', - enable => true, - ensure => true, + ensure => 'running', + enable => true, + status => '/bin/true', } + Package<| title == 'cpufrequtils'|> ~> Service<| title == 'cpufrequtils'|> if !defined(Service['cpufrequtils']) { - notify{ "Module ${module_name} cannot notify service cpufrequtils\ - on package update": } + notify{ "Module ${module_name} cannot notify service cpufrequtils on package update": } } } @@ -436,10 +437,6 @@ class openstack::compute ( Service<| title == 'libvirt'|> ~> Service<| title == 'nova-compute'|> Package<| title == "nova-compute-${libvirt_type}"|> ~> Service<| title == 'nova-compute'|> - if !defined(Service['nova-compute']) { - notify{ "Module ${module_name} cannot notify service nova-compute\ -on packages update": } - } case $::osfamily { 'RedHat': { @@ -474,8 +471,7 @@ on packages update": } Package<| title == 'nova-compute'|> ~> Service<| title == 'nova-compute'|> if !defined(Service['nova-compute']) { - notify{ "Module ${module_name} cannot notify service nova-compute\ - on packages update": } + notify{ "Module ${module_name} cannot notify service nova-compute on packages update": } } Package<| title == 'libvirt'|> ~> Service<| title == 'libvirt'|> diff --git a/deployment/puppet/openstack/spec/classes/openstack_compute_spec.rb b/deployment/puppet/openstack/spec/classes/openstack_compute_spec.rb index ce5d718372..07c5bfa80b 100644 --- a/deployment/puppet/openstack/spec/classes/openstack_compute_spec.rb +++ b/deployment/puppet/openstack/spec/classes/openstack_compute_spec.rb @@ -2,6 +2,12 @@ require 'spec_helper' describe 'openstack::compute' do + before :each do + Puppet::Parser::Functions.newfunction(:is_pkg_installed, :type => :rvalue) { + |args| true + } + end + let(:default_params) { { :internal_address => nil, :nova_user_password => nil, @@ -127,6 +133,7 @@ describe 'openstack::compute' do :force_config_drive => false, :neutron_enabled => false, :install_bridge_utils => p[:install_bridge_utils], + :network_device_mtu => '65000', :instance_usage_audit => true, :instance_usage_audit_period => 'hour', :default_availability_zone => 'nova', @@ -154,16 +161,33 @@ describe 'openstack::compute' do should contain_class('nova::client') should contain_install_ssh_keys('nova_ssh_key_for_migration') should contain_file('/var/lib/nova/.ssh/config') + + if facts[:operatingsystem] == 'Ubuntu' + should contain_package('cpufrequtils').with( + :ensure => 'present' + ) + should contain_file('/etc/default/cpufrequtils').with( + :content => "GOVERNOR=\"performance\"\n", + :require => 'Package[cpufrequtils]', + :notify => 'Service[cpufrequtils]', + ) + should contain_service('cpufrequtils').with( + :ensure => 'running', + :enable => true, + :status => '/bin/true', + ) + end end end end context 'on Debian platforms' do let :facts do - { :osfamily => 'Debian', - :operatingsystem => 'Debian', - :hostname => 'hostname.example.com', - :openstack_version => {'nova' => 'present' }, + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :hostname => 'hostname.example.com', + :openstack_version => { 'nova' => 'present' }, :os_service_default => '', } end @@ -173,9 +197,11 @@ describe 'openstack::compute' do context 'on RedHat platforms' do let :facts do - { :osfamily => 'RedHat', - :hostname => 'hostname.example.com', - :openstack_version => {'nova' => 'present' }, + { + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + :hostname => 'hostname.example.com', + :openstack_version => { 'nova' => 'present' }, :os_service_default => '', } end diff --git a/deployment/puppet/osnailyfacter/modular/astute/enable_compute.pp b/deployment/puppet/osnailyfacter/modular/astute/enable_compute.pp index 8738f70e64..07493d9ff4 100644 --- a/deployment/puppet/osnailyfacter/modular/astute/enable_compute.pp +++ b/deployment/puppet/osnailyfacter/modular/astute/enable_compute.pp @@ -1,9 +1,30 @@ include nova::params $compute_service_name = $::nova::params::compute_service_name +$use_neutron = hiera('use_neutron', true) -service { $compute_service_name: +if $use_neutron { + $neutron_integration_bridge = 'br-int' + $bridge_exists_check = "ovs-vsctl br-exists ${neutron_integration_bridge}" + + # We need to restart nova-compute service in orderto apply new settings + # nova-compute must not be restarted until integration bridge is created by + # Neutron L2 agent. + # The reason is described here https://bugs.launchpad.net/fuel/+bug/1477475 + exec { 'wait-for-int-br': + command => $bridge_exists_check, + path => ['/usr/bin', '/usr/sbin'], + unless => $bridge_exists_check, + try_sleep => 6, + tries => 10, + } + + Exec['wait-for-int-br'] -> Service['nova-compute'] +} + +service { 'nova-compute': ensure => running, + name => $compute_service_name, enable => true, hasstatus => true, hasrestart => true, diff --git a/deployment/puppet/osnailyfacter/modular/openstack-network/compute-nova.pp b/deployment/puppet/osnailyfacter/modular/openstack-network/compute-nova.pp index 82cae90b56..36578a6101 100644 --- a/deployment/puppet/osnailyfacter/modular/openstack-network/compute-nova.pp +++ b/deployment/puppet/osnailyfacter/modular/openstack-network/compute-nova.pp @@ -83,7 +83,6 @@ if $use_neutron { nova_config { 'DEFAULT/linuxnet_interface_driver': value => 'nova.network.linux_net.LinuxOVSInterfaceDriver'; 'DEFAULT/linuxnet_ovs_integration_bridge': value => $neutron_integration_bridge; - 'DEFAULT/network_device_mtu': value => '65000'; 'DEFAULT/my_ip': value => $nova_migration_ip; } @@ -113,28 +112,6 @@ if $use_neutron { before => Service['libvirt'], } - # We need to restart nova-compute service in orderto apply new settings - # nova-compute must not be restarted until integration bridge is created by - # Neutron L2 agent. - # The reason is described here https://bugs.launchpad.net/fuel/+bug/1477475 - exec { 'wait-for-int-br': - command => "ovs-vsctl br-exists ${neutron_integration_bridge}", - path => [ '/sbin', '/bin', '/usr/bin', '/usr/sbin' ], - try_sleep => 6, - tries => 10, - refreshonly => true, - } - - Augeas<||> ~> Exec['wait-for-int-br'] - Exec['wait-for-int-br'] -> Service['nova-compute'] - - service { 'nova-compute': - ensure => 'running', - name => $::nova::params::compute_service_name, - } - - Nova_config<| |> ~> Service['nova-compute'] - } else { $nova_hash = hiera_hash('nova', { }) $bind_address = get_network_role_property('nova/api', 'ipaddr') diff --git a/tests/noop/spec/hosts/astute/enable_compute_spec.rb b/tests/noop/spec/hosts/astute/enable_compute_spec.rb index d37562ae4e..fca3964450 100644 --- a/tests/noop/spec/hosts/astute/enable_compute_spec.rb +++ b/tests/noop/spec/hosts/astute/enable_compute_spec.rb @@ -5,19 +5,40 @@ manifest = 'astute/enable_compute.pp' describe manifest do shared_examples 'catalog' do - it "should contain nova-compute service" do - case facts[:operatingsystem] + it 'should contain nova-compute service' do + service_name = case facts[:operatingsystem] when 'Ubuntu' - service_name = 'nova-compute' + 'nova-compute' when 'CentOS' - service_name = 'openstack-nova-compute' + 'openstack-nova-compute' else - service_name = 'nova-compute' + 'nova-compute' end - should contain_service(service_name) + is_expected.to contain_service('nova-compute').with( + :ensure => 'running', + :name => service_name, + :enable => true, + :hasstatus => true, + :hasrestart => true, + ) + end + + if Noop.hiera('use_neutron') && Noop.hiera('role') == 'compute' + neutron_integration_bridge = 'br-int' + bridge_exists_check = "ovs-vsctl br-exists #{neutron_integration_bridge}" + + it 'should contain wait-for-int-br exec' do + is_expected.to contain_exec('wait-for-int-br').with( + :command => bridge_exists_check, + :unless => bridge_exists_check, + :try_sleep => 6, + :tries => 10, + ).that_comes_before('Service[nova-compute]') + end end end + test_ubuntu_and_centos manifest end diff --git a/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb b/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb index 315f02efba..3ae4f24256 100644 --- a/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb +++ b/tests/noop/spec/hosts/openstack-network/compute-nova_spec.rb @@ -122,17 +122,12 @@ describe manifest do it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_interface_driver').with( :value => 'nova.network.linux_net.LinuxOVSInterfaceDriver' )} - it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_interface_driver').that_notifies('Service[nova-compute]') } + it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_interface_driver') } # it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_ovs_integration_bridge').with( :value => neutron_integration_bridge )} - it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_ovs_integration_bridge').that_notifies('Service[nova-compute]') } - # - it { expect(subject).to contain_nova_config('DEFAULT/network_device_mtu').with( - :value => '65000' - )} - it { expect(subject).to contain_nova_config('DEFAULT/network_device_mtu').that_notifies('Service[nova-compute]') } + it { expect(subject).to contain_nova_config('DEFAULT/linuxnet_ovs_integration_bridge') } # it { expect(subject).to contain_class('nova::network::neutron').with( :neutron_admin_password => admin_password, @@ -173,17 +168,6 @@ describe manifest do )} it { expect(subject).to contain_augeas('sysctl-net.bridge.bridge-nf-call-arptables').that_comes_before('Service[libvirt]')} # - it { expect(subject).to contain_service('nova-compute').with( - :ensure => 'running', - )} - # - it { expect(subject).to contain_exec('wait-for-int-br').with( - :command => "ovs-vsctl br-exists #{neutron_integration_bridge}", - :try_sleep => 6, - :tries => 10, - )} - it { expect(subject).to contain_exec('wait-for-int-br').that_comes_before('Service[nova-compute]') } - # end elsif !Noop.hiera('use_neutron') && Noop.hiera('role') == 'compute' context 'Nova-network is used' do