Browse Source

Add support for cinder-backup service

Partially-implements: blueprint chef-cinder-backup
Change-Id: I961d8875e35c26efa2ff9e7be0bb576cb8e345fa
Lan Qi song 4 years ago
parent
commit
cba98483b2

+ 17
- 0
README.md View File

@@ -211,6 +211,23 @@ The following attributes are defined in attributes/default.rb of the common cook
211 211
 * `openstack['endpoints']['block-storage-api-bind']['port']` - The port to bind the api service to
212 212
 * `openstack['endpoints']['block-storage-api-bind']['bind_interface']` - The interface name to bind the api service to
213 213
 
214
+### Backup service attributes ###
215
+* `openstack['block-storage']['backup']['enabled']` - Whether to enable cinder backup service or not.
216
+* `openstack['block-storage']['backup']['driver']` - The driver for cinder backup service.
217
+* `openstack['block-storage']['backup']['swift']['url']` - The URL of Swift endpoint.
218
+* `openstack['block-storage']['backup']['swift']['catalog_info']` - Info to match when looking for swift in the service catalog.
219
+* `openstack['block-storage']['backup']['swift']['auth']` - Swift authentication mechanism.
220
+* `openstack['block-storage']['backup']['swift']['auth_version']` - Swift authentication version.
221
+* `openstack['block-storage']['backup']['swift']['user']` - Swift user name.
222
+* `openstack['block-storage']['backup']['swift']['tenant']` - Swift tenant/account name. Required when connecting.
223
+* `openstack['block-storage']['backup']['swift']['key']` - Swift key for authentication.
224
+* `openstack['block-storage']['backup']['swift']['container']` - The default Swift container to use.
225
+* `openstack['block-storage']['backup']['swift']['object_size']` - The size in bytes of Swift backup objects.
226
+* `openstack['block-storage']['backup']['swift']['block_size']` - The size in bytes that changes are tracked for incremental backups.
227
+* `openstack['block-storage']['backup']['swift']['retry_attempts']` - The number of retries to make for Swift operations.
228
+* `openstack['block-storage']['backup']['swift']['retry_backoff']` - The backoff time in seconds between Swift retries.
229
+* `openstack['block-storage']['backup']['swift']['enable_progress_timer']` - Enable or Disable the timer to send the periodic progress notifications to Ceilometer when backing up the volume to the Swift backend storage.
230
+
214 231
 If the value of the 'bind_interface' attribute is non-nil, then the block-storage service will be bound to the first IP address on that interface.  If the value of the 'bind_interface' attribute is nil, then the block-storage service will be bound to the IP address specified in the host attribute.
215 232
 
216 233
 Testing

+ 40
- 0
attributes/default.rb View File

@@ -63,6 +63,9 @@ default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messa
63 63
 # This is the name of the Chef role that will install the Keystone Service API
64 64
 default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone'
65 65
 
66
+# Whether to enable cinder-backup service or not
67
+default['openstack']['block-storage']['backup']['enabled'] = false
68
+
66 69
 # Keystone PKI signing directory
67 70
 default['openstack']['block-storage']['api']['auth']['cache_dir'] = '/var/cache/cinder/api'
68 71
 
@@ -335,6 +338,8 @@ when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
335 338
     'cinder_volume_service' => 'openstack-cinder-volume',
336 339
     'cinder_scheduler_packages' => [],
337 340
     'cinder_scheduler_service' => 'openstack-cinder-scheduler',
341
+    'cinder_backup_packages' => [],
342
+    'cinder_backup_service' => 'openstack-cinder-backup',
338 343
     'cinder_iscsitarget_packages' => ['targetcli'],
339 344
     'cinder_iscsitarget_service' => 'target',
340 345
     'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
@@ -356,6 +361,8 @@ when 'suse'
356 361
     'cinder_client_packages' => ['python-cinderclient'],
357 362
     'cinder_scheduler_packages' => ['openstack-cinder-scheduler'],
358 363
     'cinder_scheduler_service' => 'openstack-cinder-scheduler',
364
+    'cinder_backup_packages' => ['openstack-cinder-backup'],
365
+    'cinder_backup_service' => 'openstack-cinder-backup',
359 366
     'cinder_volume_packages' => ['openstack-cinder-volume', 'qemu-img'],
360 367
     'cinder_volume_service' => 'openstack-cinder-volume',
361 368
     'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
@@ -380,6 +387,8 @@ when 'debian'
380 387
     'cinder_volume_service' => 'cinder-volume',
381 388
     'cinder_scheduler_packages' => ['cinder-scheduler'],
382 389
     'cinder_scheduler_service' => 'cinder-scheduler',
390
+    'cinder_backup_packages' => ['cinder-backup'],
391
+    'cinder_backup_service' => 'cinder-backup',
383 392
     'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
384 393
     'cinder_iscsitarget_packages' => ['tgt'],
385 394
     'cinder_iscsitarget_service' => 'tgt',
@@ -391,3 +400,34 @@ when 'debian'
391 400
     'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
392 401
   }
393 402
 end
403
+
404
+# Attributes for cinder-backup service
405
+default['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
406
+
407
+# Swift support
408
+# The URL of Swift endpoint (string value)
409
+default['openstack']['block-storage']['backup']['swift']['url'] = nil
410
+# Info to match when looking for swift in the service catalog
411
+default['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'object-store:swift:publicURL'
412
+# Swift authentication mechanism (string value)
413
+default['openstack']['block-storage']['backup']['swift']['auth'] = 'per_user'
414
+# Swift authentication version
415
+default['openstack']['block-storage']['backup']['swift']['auth_version'] = 1
416
+# Swift user name
417
+default['openstack']['block-storage']['backup']['swift']['user'] = nil
418
+# Swift tenant/account name. Required when connecting
419
+default['openstack']['block-storage']['backup']['swift']['tenant'] = nil
420
+# Swift key for authentication (string value)
421
+default['openstack']['block-storage']['backup']['swift']['key'] = nil
422
+# The default Swift container to use
423
+default['openstack']['block-storage']['backup']['swift']['container'] = 'volumebackups'
424
+# The size in bytes of Swift backup objects
425
+default['openstack']['block-storage']['backup']['swift']['object_size'] = 52428800
426
+# The size in bytes that changes are tracked for incremental backups
427
+default['openstack']['block-storage']['backup']['swift']['block_size'] = 32768
428
+# The number of retries to make for Swift operations
429
+default['openstack']['block-storage']['backup']['swift']['retry_attempts'] = 3
430
+# The backoff time in seconds between Swift retries
431
+default['openstack']['block-storage']['backup']['swift']['retry_backoff'] = 2
432
+# Enable or Disable the timer to send the periodic progress notifications to Ceilometer when backing up the volume to the Swift backend storage.
433
+default['openstack']['block-storage']['backup']['swift']['enable_progress_timer'] = 'True'

+ 2
- 1
metadata.rb View File

@@ -5,7 +5,7 @@ maintainer_email 'opscode-chef-openstack@googlegroups.com'
5 5
 license          'Apache 2.0'
6 6
 description      'The OpenStack Advanced Volume Management service Cinder.'
7 7
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
8
-version          '11.0.0'
8
+version          '11.1.0'
9 9
 
10 10
 recipe           'openstack-block-storage::api', 'Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone'
11 11
 recipe           'openstack-block-storage::client', 'Install packages required for cinder client'
@@ -13,6 +13,7 @@ recipe           'openstack-block-storage::common', 'Defines the common pieces o
13 13
 recipe           'openstack-block-storage::keystone_registration', 'Registers cinder service/user/endpoints in keystone'
14 14
 recipe           'openstack-block-storage::scheduler', 'Installs the cinder-scheduler service'
15 15
 recipe           'openstack-block-storage::volume', 'Installs the cinder-volume service and sets up the iscsi helper'
16
+recipe           'openstack-block-storage::backup', 'Installs the cinder-backup service'
16 17
 
17 18
 %w{ ubuntu fedora redhat centos suse }.each do |os|
18 19
   supports os

+ 44
- 0
recipes/backup.rb View File

@@ -0,0 +1,44 @@
1
+# encoding: UTF-8
2
+#
3
+# Cookbook Name:: openstack-block-storage
4
+# Recipe:: backup
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License");
7
+# you may not use this file except in compliance with the License.
8
+# You may obtain a copy of the License at
9
+#
10
+#     http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS,
14
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+# See the License for the specific language governing permissions and
16
+# limitations under the License.
17
+#
18
+
19
+return unless node['openstack']['block-storage']['backup']['enabled']
20
+
21
+include_recipe 'openstack-block-storage::cinder-common'
22
+
23
+platform_options = node['openstack']['block-storage']['platform']
24
+
25
+platform_options['cinder_backup_packages'].each do |pkg|
26
+  package pkg do
27
+    options platform_options['package_overrides']
28
+    action :upgrade
29
+  end
30
+end
31
+
32
+db_type = node['openstack']['db']['block-storage']['service_type']
33
+node['openstack']['db']['python_packages'][db_type].each do |pkg|
34
+  package pkg do
35
+    action :upgrade
36
+  end
37
+end
38
+
39
+service 'cinder-backup' do
40
+  service_name platform_options['cinder_backup_service']
41
+  supports status: true, restart: true
42
+  action [:enable, :start]
43
+  subscribes :restart, 'template[/etc/cinder/cinder.conf]'
44
+end

+ 48
- 0
spec/backup-redhat_spec.rb View File

@@ -0,0 +1,48 @@
1
+# encoding: UTF-8
2
+#
3
+# Cookbook Name:: openstack-block-storage
4
+
5
+require_relative 'spec_helper'
6
+
7
+describe 'openstack-block-storage::backup' do
8
+  describe 'redhat' do
9
+    let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
10
+    let(:node) { runner.node }
11
+    let(:chef_run) { runner.converge(described_recipe) }
12
+
13
+    include_context 'block-storage-stubs'
14
+
15
+    describe 'enable cinder backup service' do
16
+      before do
17
+        node.set['openstack']['block-storage']['backup']['enabled'] = true
18
+      end
19
+
20
+      it 'starts cinder backup' do
21
+        expect(chef_run).to start_service 'openstack-cinder-backup'
22
+      end
23
+
24
+      it 'starts cinder backup on boot' do
25
+        expect(chef_run).to enable_service 'openstack-cinder-backup'
26
+      end
27
+
28
+      it 'upgrades mysql python package' do
29
+        expect(chef_run).to upgrade_package 'MySQL-python'
30
+      end
31
+
32
+      it 'upgrades db2 python packages if explicitly told' do
33
+        node.set['openstack']['db']['block-storage']['service_type'] = 'db2'
34
+
35
+        ['python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
36
+          expect(chef_run).to upgrade_package pkg
37
+        end
38
+      end
39
+
40
+      it 'upgrades postgresql python packages if explicitly told' do
41
+        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
42
+
43
+        expect(chef_run).to upgrade_package 'python-psycopg2'
44
+        expect(chef_run).not_to upgrade_package 'MySQL-python'
45
+      end
46
+    end
47
+  end
48
+end

+ 43
- 0
spec/backup-suse_spec.rb View File

@@ -0,0 +1,43 @@
1
+# encoding: UTF-8
2
+#
3
+# Cookbook Name:: openstack-block-storage
4
+
5
+require_relative 'spec_helper'
6
+
7
+describe 'openstack-block-storage::backup' do
8
+  describe 'suse' do
9
+    let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10
+    let(:node) { runner.node }
11
+    let(:chef_run) { runner.converge(described_recipe) }
12
+
13
+    include_context 'block-storage-stubs'
14
+
15
+    describe 'enable cinder backup service' do
16
+      before do
17
+        node.set['openstack']['block-storage']['backup']['enabled'] = true
18
+      end
19
+      it 'upgrades cinder backup package' do
20
+        expect(chef_run).to upgrade_package 'openstack-cinder-backup'
21
+      end
22
+
23
+      it 'starts cinder backup' do
24
+        expect(chef_run).to start_service 'openstack-cinder-backup'
25
+      end
26
+
27
+      it 'starts cinder backup on boot' do
28
+        expect(chef_run).to enable_service 'openstack-cinder-backup'
29
+      end
30
+
31
+      it 'upgrades mysql python package' do
32
+        expect(chef_run).to upgrade_package 'python-mysql'
33
+      end
34
+
35
+      it 'upgrades postgresql python packages if explicitly told' do
36
+        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
37
+
38
+        expect(chef_run).to upgrade_package 'python-psycopg2'
39
+        expect(chef_run).not_to upgrade_package 'python-mysql'
40
+      end
41
+    end
42
+  end
43
+end

+ 80
- 0
spec/backup_spec.rb View File

@@ -0,0 +1,80 @@
1
+# encoding: UTF-8
2
+#
3
+# Cookbook Name:: openstack-block-storage
4
+
5
+require_relative 'spec_helper'
6
+
7
+describe 'openstack-block-storage::backup' do
8
+  describe 'ubuntu' do
9
+    let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
10
+    let(:node) { runner.node }
11
+    let(:chef_run) { runner.converge(described_recipe) }
12
+
13
+    include_context 'block-storage-stubs'
14
+
15
+    describe 'enable cinder backup service' do
16
+      before do
17
+        node.set['openstack']['block-storage']['backup']['enabled'] = true
18
+      end
19
+      it 'upgrades cinder backup package' do
20
+        expect(chef_run).to upgrade_package 'cinder-backup'
21
+      end
22
+
23
+      it 'starts cinder backup' do
24
+        expect(chef_run).to start_service 'cinder-backup'
25
+      end
26
+
27
+      it 'starts cinder backup on boot' do
28
+        expect(chef_run).to enable_service 'cinder-backup'
29
+      end
30
+
31
+      it 'subscribes to the template change' do
32
+        expect(chef_run.service('cinder-backup')).to subscribe_to('template[/etc/cinder/cinder.conf]')
33
+      end
34
+
35
+      it 'upgrades mysql python package' do
36
+        expect(chef_run).to upgrade_package 'python-mysqldb'
37
+      end
38
+
39
+      it 'upgrades postgresql python packages if explicitly told' do
40
+        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
41
+
42
+        expect(chef_run).to upgrade_package 'python-psycopg2'
43
+        expect(chef_run).not_to upgrade_package 'python-mysqldb'
44
+      end
45
+    end
46
+
47
+    describe 'disable cinder backup service' do
48
+      before do
49
+        node.set['openstack']['block-storage']['backup']['enabled'] = false
50
+      end
51
+      it 'not to upgrades cinder backup package' do
52
+        expect(chef_run).not_to upgrade_package 'cinder-backup'
53
+      end
54
+
55
+      it 'not to starts cinder backup' do
56
+        expect(chef_run).not_to start_service 'cinder-backup'
57
+      end
58
+
59
+      it 'not to starts cinder backup on boot' do
60
+        expect(chef_run).not_to enable_service 'cinder-backup'
61
+      end
62
+
63
+      it 'not to subscribes to the template change' do
64
+        expect(chef_run.service('cinder-backup')).not_to subscribe_to('template[/etc/cinder/cinder.conf]')
65
+      end
66
+
67
+      it 'not to upgrades mysql python package' do
68
+        expect(chef_run).not_to upgrade_package 'python-mysqldb'
69
+      end
70
+
71
+      it 'not to upgrades postgresql python packages if explicitly told' do
72
+        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
73
+
74
+        expect(chef_run).not_to upgrade_package 'python-psycopg2'
75
+        expect(chef_run).not_to upgrade_package 'python-mysqldb'
76
+      end
77
+    end
78
+
79
+  end
80
+end

+ 44
- 0
spec/cinder_common_spec.rb View File

@@ -180,6 +180,50 @@ describe 'openstack-block-storage::cinder-common' do
180 180
           end
181 181
         end
182 182
 
183
+        context 'backup swift backend contents' do
184
+          before do
185
+            node.set['openstack']['block-storage']['backup']['enabled'] = true
186
+            node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
187
+          end
188
+
189
+          it 'has default attributes' do
190
+            %w(swift_catalog_info=object-store:swift:publicURL
191
+               backup_swift_auth=per_user
192
+               backup_swift_auth_version=1
193
+               backup_swift_container=volumebackups
194
+               backup_swift_object_size=52428800
195
+               backup_swift_block_size=32768
196
+               backup_swift_retry_attempts=3
197
+               backup_swift_retry_backoff=2
198
+               backup_swift_enable_progress_timer=True).each do |attr|
199
+              expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
200
+            end
201
+          end
202
+
203
+          it 'has override attributes' do
204
+            %w(url
205
+               auth
206
+               auth_version
207
+               tenant
208
+               user
209
+               key
210
+               container
211
+               object_size
212
+               block_size
213
+               retry_attempts
214
+               retry_backoff
215
+               enable_progress_timer).each do |attr|
216
+              node.set['openstack']['block-storage']['backup']['swift'][attr] = "backup_swift_#{attr}"
217
+              expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^backup_swift_#{attr}=backup_swift_#{attr}$/)
218
+            end
219
+          end
220
+
221
+          it 'has a custom catalog_info' do
222
+            node.set['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'swift_catalog_info'
223
+            expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^swift_catalog_info=swift_catalog_info$/)
224
+          end
225
+        end
226
+
183 227
         context 'rdb driver' do
184 228
           # FIXME(galstrom21): this block needs to check all of the default
185 229
           #   rdb_* configuration options

+ 75
- 0
templates/default/cinder.conf.erb View File

@@ -269,6 +269,81 @@ osapi_volume_workers=<%= node["openstack"]["block-storage"]["osapi_volume_worker
269 269
 #### (BoolOpt) make deprecations fatal
270 270
 
271 271
 
272
+######## defined in cinder.backup.manager ########
273
+<% if node['openstack']['block-storage']['backup']['enabled'] %>
274
+backup_driver=<%= node['openstack']['block-storage']['backup']['driver'] %>
275
+<% if node['openstack']['block-storage']['backup']['driver'] == 'cinder.backup.drivers.swift' %>
276
+######## defined in cinder.backup.driver.swift ########
277
+# The URL of the Swift endpoint (string value)
278
+<% if node['openstack']['block-storage']['backup']['swift']['url'] %>
279
+backup_swift_url=<%= node['openstack']['block-storage']['backup']['swift']['url'] %>
280
+<% else %>
281
+# backup_swift_url=<None>
282
+<% end %>
283
+
284
+# Info to match when looking for swift in the service catalog.
285
+# Format is: separated values of the form:
286
+# <service_type>:<service_name>:<endpoint_type> - Only used if
287
+# backup_swift_url is unset (string value)
288
+swift_catalog_info=<%= node['openstack']['block-storage']['backup']['swift']['catalog_info'] %>
289
+
290
+# Swift authentication mechanism (string value)
291
+backup_swift_auth=<%= node['openstack']['block-storage']['backup']['swift']['auth'] %>
292
+
293
+# Swift authentication version. Specify "1" for auth 1.0, or
294
+# "2" for auth 2.0 (string value)
295
+backup_swift_auth_version=<%= node['openstack']['block-storage']['backup']['swift']['auth_version'] %>
296
+
297
+# Swift tenant/account name. Required when connecting to an
298
+# auth 2.0 system (string value)
299
+<% if node['openstack']['block-storage']['backup']['swift']['tenant'] %>
300
+backup_swift_tenant=<%= node['openstack']['block-storage']['backup']['swift']['tenant'] %>
301
+<% else %>
302
+# backup_swift_tenant=<None>
303
+<% end %>
304
+
305
+# Swift user name (string value)
306
+<% if node['openstack']['block-storage']['backup']['swift']['user'] %>
307
+backup_swift_user=<%= node['openstack']['block-storage']['backup']['swift']['user'] %>
308
+<% else %>
309
+# backup_swift_user=<None>
310
+<% end %>
311
+
312
+# Swift key for authentication (string value)
313
+<% if node['openstack']['block-storage']['backup']['swift']['key'] %>
314
+backup_swift_key=<%= node['openstack']['block-storage']['backup']['swift']['key'] %>
315
+<% else %>
316
+# backup_swift_key=<None>
317
+<% end %>
318
+
319
+# The default Swift container to use (string value)
320
+backup_swift_container=<%= node['openstack']['block-storage']['backup']['swift']['container'] %>
321
+
322
+# The size in bytes of Swift backup objects (integer value)
323
+backup_swift_object_size=<%= node['openstack']['block-storage']['backup']['swift']['object_size'] %>
324
+
325
+# The size in bytes that changes are tracked for incremental
326
+# backups. backup_swift_object_size has to be multiple of
327
+# backup_swift_block_size. (integer value)
328
+backup_swift_block_size=<%= node['openstack']['block-storage']['backup']['swift']['block_size'] %>
329
+
330
+# The number of retries to make for Swift operations (integer
331
+# value)
332
+backup_swift_retry_attempts=<%= node['openstack']['block-storage']['backup']['swift']['retry_attempts'] %>
333
+
334
+# The backoff time in seconds between Swift retries (integer
335
+# value)
336
+backup_swift_retry_backoff=<%= node['openstack']['block-storage']['backup']['swift']['retry_backoff'] %>
337
+
338
+# Enable or Disable the timer to send the periodic progress
339
+# notifications to Ceilometer when backing up the volume to
340
+# the Swift backend storage. The default value is True to
341
+# enable the timer. (boolean value)
342
+backup_swift_enable_progress_timer=<%= node['openstack']['block-storage']['backup']['swift']['enable_progress_timer'] %>
343
+
344
+<% end %>
345
+<% end %>
346
+
272 347
 ######## defined in cinder.db.api ########
273 348
 
274 349
 # enable_new_services=true

Loading…
Cancel
Save