blob: bc252daa906370ede1a3bcaa583d5098e89a88d8 [file] [log] [blame]
Oleksandr Bryndzii30397e92019-05-06 15:59:30 +03001/**
2 * Upgrade RabbitMQ packages on msg nodes.
3 * Update packages on given nodes
4 *
5 * Expected parameters:
6 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
7 * SALT_MASTER_URL Full Salt API address [http://10.10.10.15:6969].
8 * OS_DIST_UPGRADE Upgrade system packages including kernel (apt-get dist-upgrade)
9 * OS_UPGRADE Upgrade all installed applications (apt-get upgrade)
10 * TARGET_SERVERS Comma separated list of salt compound definitions to upgrade.
11 * INTERACTIVE Ask interactive questions during pipeline run (bool).
12 *
13**/
14
15def common = new com.mirantis.mk.Common()
16def salt = new com.mirantis.mk.Salt()
17def python = new com.mirantis.mk.Python()
18def debian = new com.mirantis.mk.Debian()
19def openstack = new com.mirantis.mk.Openstack()
20
21def interactive = INTERACTIVE.toBoolean()
22def LinkedHashMap upgradeStageMap = [:]
23
24upgradeStageMap.put('Pre upgrade',
25 [
26 'Description': 'Only non destructive actions will be applied during this phase. Basic service verification will be performed.',
27 'Status': 'NOT_LAUNCHED',
28 'Expected behaviors': '''
29 * No service downtime
30 * No workload downtime''',
31 'Launched actions': '''
Oleksandr Pidrepnyi217efc02019-07-18 16:06:57 +030032 * Refresh pillars on the target nodes.
33 * Apply the 'linux.system.repo' state on the target nodes.
Oleksandr Bryndzii30397e92019-05-06 15:59:30 +030034 * Verify API, perform basic CRUD operations for services.
35 * Verify rabbitmq is running and operational.''',
36 'State result': 'Basic checks around services API are passed.'
37 ])
38
39upgradeStageMap.put('Stop RabbitMQ service',
40 [
41 'Description': 'All rabbitmq services will be stopped on All TARGET_SERVERS nodes.',
42 'Status': 'NOT_LAUNCHED',
43 'Expected behaviors': '''
44 * RabbitMQ services are stopped.
45 * OpenStack APIs are not accessible from this point.
46 * No workload downtime''',
47 'Launched actions': '''
48 * Stop RabbitMQ services''',
49 'State result': 'RabbitMQ service is stopped',
50 ])
51
52upgradeStageMap.put('Upgrade OS',
53 [
54 'Description': 'Optional step. OS packages will be upgraded during this phase, depending on the job parameters dist-upgrade might be called. And reboot of node executed.',
55 'Status': 'NOT_LAUNCHED',
56 'Expected behaviors': '''
57 * No workload downtime
58 * The nodes might be rebooted''',
59 'Launched actions': '''
60 * Install new version of system packages
61 * If doing dist-upgrade new kernel might be installed and node rebooted
62 * System packages are updated
63 * Node might be rebooted
64'''
65 ])
66
67upgradeStageMap.put('Upgrade RabbitMQ server',
68 [
69 'Description': 'RabbitMQ and Erlang code will be upgraded during this stage. No workload downtime is expected.',
70 'Status': 'NOT_LAUNCHED',
71 'Expected behaviors': '''
72 * OpenStack services loose connection to rabbitmq-server
73 * No workload downtime''',
74 'Launched actions': '''
75 * Install new version of RabbitMQ and Erlang packages
76 * Render version of configs''',
77 'State result': '''
78 * RabbitMQ packages are upgraded''',
79 ])
80
81upgradeStageMap.put('Start RabbitMQ service',
82 [
83 'Description': 'All rabbitmq services will be running on All TARGET_SERVERS nodes.',
84 'Status': 'NOT_LAUNCHED',
85 'Expected behaviors': '''
86 * RabbitMQ service is running.
87 * OpenStack API are accessible from this point.
88 * No workload downtime''',
89 'Launched actions': '''
90 * Start RabbitMQ service''',
91 'State result': 'RabbitMQ service is running',
92 ])
93
94def env = "env"
95timeout(time: 12, unit: 'HOURS') {
96 node() {
97
98 stage('Setup virtualenv for Pepper') {
99 python.setupPepperVirtualenv(env, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
100 }
101
102 def upgradeTargets = salt.getMinionsSorted(env, TARGET_SERVERS)
103
104 if (upgradeTargets.isEmpty()) {
105 error("No servers for upgrade matched by ${TARGET_SERVERS}")
106 }
107
108 def stopTargets = upgradeTargets.reverse()
109
110 common.printStageMap(upgradeStageMap)
111 if (interactive){
112 input message: common.getColorizedString(
113 "Above you can find detailed info this pipeline will execute.\nThe info provides brief description of each stage, actions that will be performed and service/workload impact during each stage.\nPlease read it carefully.", "yellow")
114 }
115
116 for (target in upgradeTargets){
117 common.stageWrapper(upgradeStageMap, "Pre upgrade", target, interactive) {
118 openstack.runOpenStackUpgradePhase(env, target, 'pre')
Oleksandr Pidrepnyi217efc02019-07-18 16:06:57 +0300119 salt.runSaltProcessStep(env, target, 'saltutil.refresh_pillar', [], null, true)
120 salt.enforceState(env, target, 'linux.system.repo')
Oleksandr Bryndzii30397e92019-05-06 15:59:30 +0300121 openstack.runOpenStackUpgradePhase(env, target, 'verify')
122 }
123 }
124
125 for (target in stopTargets) {
126 common.stageWrapper(upgradeStageMap, "Stop RabbitMQ service", target, interactive) {
127 openstack.runOpenStackUpgradePhase(env, target, 'service_stopped')
128 }
129 }
130
131 for (target in upgradeTargets) {
132 common.stageWrapper(upgradeStageMap, "Upgrade OS", target, interactive) {
133 if (OS_DIST_UPGRADE.toBoolean() == true){
134 upgrade_mode = 'dist-upgrade'
135 } else if (OS_UPGRADE.toBoolean() == true){
136 upgrade_mode = 'upgrade'
137 }
138 if (OS_DIST_UPGRADE.toBoolean() == true || OS_UPGRADE.toBoolean() == true) {
139 debian.osUpgradeNode(env, target, upgrade_mode, false)
140 }
141 }
142 }
143
144 for (target in upgradeTargets) {
145 common.stageWrapper(upgradeStageMap, "Upgrade RabbitMQ server", target, interactive) {
146 openstack.runOpenStackUpgradePhase(env, target, 'pkgs_latest')
147 openstack.runOpenStackUpgradePhase(env, target, 'render_config')
148 }
149 }
150
151 for (target in upgradeTargets) {
152 common.stageWrapper(upgradeStageMap, "Start RabbitMQ service", target, interactive) {
153 openstack.runOpenStackUpgradePhase(env, target, 'service_running')
154 openstack.applyOpenstackAppsStates(env, target)
155 openstack.runOpenStackUpgradePhase(env, target, 'verify')
156 }
157 }
158 }
159}