Upgrade script for contrail packages

Change-Id: I13fabb71b63f9589f2d2393cc1ddb9112bc25911
This commit is contained in:
Oleksandr Martsyniuk 2016-04-14 10:02:57 +03:00
parent 9e9b184c43
commit b8dc6638bf
15 changed files with 442 additions and 29 deletions

View File

@ -13,6 +13,11 @@
# under the License.
class contrail::compute::vrouter {
Exec {
path => '/sbin:/usr/sbin:/bin:/usr/bin',
}
$dev_mac = getvar("::macaddress_${contrail::phys_dev}")
if $contrail::compute_dpdk_enabled {
@ -39,17 +44,21 @@ class contrail::compute::vrouter {
path => '/etc/init/supervisor-vrouter.override',
content => 'manual',
} ->
class { 'contrail::package':
install => [$install_packages],
remove => [$delete_packages],
package { $delete_packages:
ensure => purged,
tag => ['delete'],
} ->
package { $install_packages:
ensure => present,
tag => ['install'],
} ->
exec { 'remove-ovs-modules':
command => '/sbin/modprobe -r openvswitch'
command => 'modprobe -r openvswitch'
} ->
file {'/etc/contrail/agent_param':
ensure => present,
content => template('contrail/agent_param.erb'),
require => Class[Contrail::Package],
require => Package[$install_packages],
} ->
file {'/etc/contrail/contrail-vrouter-agent.conf':
ensure => present,
@ -62,12 +71,14 @@ class contrail::compute::vrouter {
exec { 'remove_supervisor_override':
command => 'rm -rf /etc/init/supervisor-vrouter.override',
provider => shell,
require => Class[Contrail::Package],
require => Package[$install_packages],
} ->
service {'supervisor-vrouter':
ensure => running,
enable => true,
subscribe => [Class[Contrail::Package],Exec['remove-ovs-modules'],
ensure => running,
enable => true,
hasrestart => false,
restart => 'service supervisor-vrouter stop && modprobe -r vrouter && service supervisor-vrouter start',
subscribe => [Package[$install_packages],Exec['remove-ovs-modules'],
File['/etc/contrail/agent_param','/etc/contrail/contrail-vrouter-agent.conf',
'/etc/contrail/contrail-vrouter-nodemgr.conf']
],

View File

@ -134,8 +134,8 @@ class contrail::config {
service { 'supervisor-config':
ensure => $contrail::service_ensure,
enable => true,
require => [Package['contrail-openstack-config'],Package['contrail-config']],
subscribe => [File['/etc/contrail/contrail-api.conf'],
subscribe => [Package['contrail-openstack-config'],Package['contrail-config'],
File['/etc/contrail/contrail-api.conf'],
File['/etc/contrail/supervisord_config_files/contrail-api.ini'],
File['/etc/contrail/contrail-discovery.conf'],
File['/etc/contrail/contrail-keystone-auth.conf'],

View File

@ -70,18 +70,18 @@ class contrail::control {
# Control service
service { 'contrail-named':
ensure => running,
require => Package['contrail-dns'],
subscribe => [File['/etc/contrail/dns/contrail-named.conf'],
subscribe => [Package['contrail-dns'],
File['/etc/contrail/dns/contrail-named.conf'],
File['/etc/contrail/dns/contrail-rndc.conf'],
]
}
service { 'supervisor-control':
ensure => $contrail::service_ensure,
enable => true,
require => [Package['contrail-openstack-control'],Package['contrail-control']],
subscribe => [File['/etc/contrail/contrail-control.conf'],
File['/etc/contrail/contrail-dns.conf'],
],
subscribe => [Package['contrail-openstack-control'],Package['contrail-control'],
File['/etc/contrail/contrail-control.conf'],
File['/etc/contrail/contrail-dns.conf'],
],
}
}

View File

@ -111,15 +111,14 @@ class contrail::controller {
}
}
Neutron_config <||> ~>
service { 'neutron-server':
ensure => running,
enable => true,
require => [Package['neutron-server'],
Package['neutron-plugin-contrail'],
],
subscribe => [File['/etc/neutron/plugins/opencontrail/ContrailPlugin.ini'],
File['/etc/neutron/plugin.ini'],
],
subscribe => [Package['neutron-server'],Package['neutron-plugin-contrail'],
File['/etc/neutron/plugins/opencontrail/ContrailPlugin.ini'],
File['/etc/neutron/plugin.ini'],
],
}
}

View File

@ -44,8 +44,9 @@ class contrail::database {
service { 'zookeeper':
ensure => running,
enable => true,
require => [Package['zookeeper'],Package['contrail-openstack-database']],
subscribe => [File['/etc/zookeeper/conf/zoo.cfg'],
require => Package['contrail-openstack-database'],
subscribe => [Package['zookeeper'],
File['/etc/zookeeper/conf/zoo.cfg'],
File['/etc/zookeeper/conf/myid'],
],
}
@ -70,8 +71,8 @@ class contrail::database {
service { 'kafka':
ensure => running,
enable => true,
require => Package['kafka'],
subscribe => [File['/usr/share/kafka/config/log4j.properties'],
subscribe => [Package['kafka'],
File['/usr/share/kafka/config/log4j.properties'],
File['/usr/share/kafka/config/server.properties'],
File['/tmp/kafka-logs/meta.properties'],
],
@ -104,8 +105,8 @@ class contrail::database {
service { 'contrail-database':
ensure => running,
enable => true,
require => [File[$contrail::cassandra_path],Package['contrail-openstack-database']],
subscribe => [
require => File[$contrail::cassandra_path],
subscribe => [Package['contrail-openstack-database'],
File['/etc/cassandra/cassandra.yaml'],
File['/etc/cassandra/cassandra-env.sh'],
],

View File

@ -0,0 +1,22 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-compute.pp')
include contrail
Package <| tag == 'install' |> { ensure => latest }
Package <| tag == 'delete' |> { ensure => purged }
class { 'contrail::compute::vrouter': }

View File

@ -0,0 +1,23 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-config.pp')
include contrail
Package <||> { ensure => latest }
class { 'contrail::config': }
class { 'contrail::analytics': }
class { 'contrail::webui': }

View File

@ -0,0 +1,21 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-control.pp')
include contrail
Package <||> { ensure => latest }
class { 'contrail::control': }

View File

@ -0,0 +1,21 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-controller.pp')
include contrail
Package <||> { ensure => latest }
class { 'contrail::controller': }

View File

@ -0,0 +1,21 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-db.pp')
include contrail
Package <||> { ensure => latest }
class { 'contrail::database': }

View File

@ -0,0 +1,20 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-post.pp')
# Workaround for the bug https://bugs.launchpad.net/juniperopenstack/+bug/1506634
file {'/usr/sbin/policy-rc.d':
ensure => absent,
}

View File

@ -0,0 +1,23 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-pre.pp')
# Workaround for the bug https://bugs.launchpad.net/juniperopenstack/+bug/1506634
file {'/usr/sbin/policy-rc.d':
ensure => file,
mode => '0755',
content => '#!/bin/sh
exit 101',
}

View File

@ -0,0 +1,20 @@
# Copyright 2016 Mirantis, Inc.
#
# 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.
notice('MODULAR: contrail/upgrade-contrail-stop.pp')
# Stop cfgm and collector
service {['supervisor-config','supervisor-analytics']:
ensure => stopped,
}

137
upgrade.sh Executable file
View File

@ -0,0 +1,137 @@
#!/bin/sh
# This script provides the functions to upgrade the contrail packages and config files
# for existing Mirantis OpenStack environment deployed wth Fuel Contrail Plugin.
# It makes use of puppet manifests located in deployment_scripts/upgrade folder
# and contrail puppet module shipped within plugin.
#
# Upgrade steps
# 1. Upgrade contrail plugin to version 3.0.1+
# 2. Copy Contrail distribution packages to plugin folder on master node.
# 3. Run ./install.sh to populate the repositories with new packages.
# 4. Start the upgrade of control plane with ./upgrade.sh controllers.
# 5. After control plane has been upgraded, run ./upgrade.sh computes.
#
# Please note, that neutron operations will be unavailable during the process
# of contrail nodes upgrade (15-20 min window).
# The instances on compute nodes will lose network connectivity during the vrouter
# upgrade on particular compute node (upto 5 min).
# Functions
# Returns a list of nodes with role defined in argument, which are in 'ready' state,
# or a list of all ready nodes if no argument supplied
get_nodes_list () {
local _role=$1
if [ -z "$_role" ]; then
local _nodes=$(fuel node 2>/dev/null | grep 'ready' | cut -d "|" -f 1,7 | awk '{printf $1 ","}' | sed -e 's|,$||')
elif [ "$_role" == "compute" ]; then
local _nodes=$(fuel node 2>/dev/null | grep 'ready' | cut -d "|" -f 1,7 | grep $_role | grep -v vmware | awk '{printf $1 ","}' | sed -e 's|,$||')
else
local _nodes=$(fuel node 2>/dev/null | grep 'ready' | cut -d "|" -f 1,7 | grep $_role | awk '{printf $1 ","}' | sed -e 's|,$||')
fi
echo $_nodes
}
# Run the task on particular node
start_task_on_node () {
local _nodes=$1
local _tasks=$2
fuel node --node-id $_nodes --task $_tasks 2>/dev/null
}
# Wait for task to complete or fail
wait_for_tasks () {
local _timeout=60
local _status
while true ; do
_status=$(fuel task 2>/dev/null | sort -n | tail -1 | cut -d "|" -f 2 | tr -d " ")
case $_status in
ready)
break
;;
error)
exit 1
;;
*)
sleep $_timeout
;;
esac
done
}
# Steps
# Check the args, exit if none
[ $# -eq 0 ] && { echo "Usage: $0 <controllers|computes>"; exit 1; }
# Add the upgrade tasks to plugins deployment_tasks as skipped
grep -q "# Contrail upgrade tasks" deployment_tasks.yaml || cat upgrade_tasks.yaml >> deployment_tasks.yaml
# Sync the deployment tasks
fuel plugins --sync 2>/dev/null
# Rsync the plugins manifests
nodes=$(get_nodes_list)
start_task_on_node $nodes rsync_core_puppet
wait_for_tasks
# Run the upgrade tasks
case $1 in
controllers*)
# Start the pre-upgrade tasks on contrail nodes
nodes=$(get_nodes_list contrail)
start_task_on_node $nodes upgrade-contrail-pre
wait_for_tasks
# Stop the contrail collector and config services
nodes=$(get_nodes_list contrail-config)
start_task_on_node $nodes upgrade-contrail-stop
wait_for_tasks
# Start the upgrade tasks on database nodes
nodes=$(get_nodes_list contrail-db)
start_task_on_node $nodes upgrade-contrail-db
wait_for_tasks
# Start the upgrade tasks on config nodes
nodes=$(get_nodes_list contrail-config)
start_task_on_node $nodes upgrade-contrail-config
wait_for_tasks
# Start the upgrade tasks on control nodes, one by one
nodes=$(get_nodes_list contrail-control)
for node in ${nodes//,/ }
do
start_task_on_node $node upgrade-contrail-control
wait_for_tasks
done
# Start the post-upgrade tasks on contrail nodes
nodes=$(get_nodes_list contrail)
start_task_on_node $nodes upgrade-contrail-post
wait_for_tasks
# Start the upgrade tasks on config nodes
nodes=$(get_nodes_list controller)
start_task_on_node $nodes upgrade-contrail-controller
wait_for_tasks
;;
computes*)
# Start the repo tasks on compute nodes
nodes=$(get_nodes_list compute)
start_task_on_node $nodes contrail-repository
wait_for_tasks
# Start the upgrade tasks on compute nodes, one by one
nodes=$(get_nodes_list compute)
for node in ${nodes//,/ }
do
start_task_on_node $node upgrade-contrail-compute
wait_for_tasks
done
;;
*)
echo "Incorrect args specified"; exit 1
;;
esac

94
upgrade_tasks.yaml Normal file
View File

@ -0,0 +1,94 @@
# Contrail upgrade tasks
# DO NOT MODIFY THE FOLLOWING LINES
- id: upgrade-contrail-pre
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-db, contrail-db,
primary-contrail-config,contrail-config,
primary-contrail-control,contrail-control]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-pre.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-stop
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-config,contrail-config]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-stop.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-db
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-db, contrail-db]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-db.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-config
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-config,contrail-config]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-config.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-control
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-control,contrail-control]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-control.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-post
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-contrail-db, contrail-db,
primary-contrail-config,contrail-config,
primary-contrail-control,contrail-control]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-post.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-controller
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [primary-controller,controller]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-controller.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: upgrade-contrail-compute
skipped: true
type: puppet
required_for: [post_deployment_end]
requires: [post_deployment_start]
role: [compute]
parameters:
puppet_manifest: puppet/upgrade/upgrade-contrail-compute.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720