Browse Source

Merge "Graph for osd-upgrade procedure"

changes/66/389566/1
Jenkins 2 years ago
parent
commit
bd90c017c8

+ 45
- 0
deployment/puppet/octane_tasks/graphs/orig/upgrade-osd-post.yaml View File

@@ -0,0 +1,45 @@
1
+# GROUPS
2
+- id: ceph-osd
3
+  type: group
4
+  role: [ceph-osd]
5
+  fault_tolerance: 0
6
+
7
+# TASKS
8
+- id: restart_ceph_osd
9
+  type: puppet
10
+  version: 2.1.0
11
+  groups: [ceph-osd]
12
+  requires: [upgrade_ceph_packages]
13
+  cross-depends:
14
+    - name: upgrade_ceph_packages
15
+      role: ceph-osd
16
+  required_for: []
17
+  parameters:
18
+    puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/restart_ceph_osd.pp
19
+    puppet_modules: /etc/fuel/octane/puppet
20
+    timeout: 600
21
+
22
+- id: unset_noout
23
+  type: puppet
24
+  version: 2.1.0
25
+  groups: [ceph-osd]
26
+  requires: [restart_ceph_osd]
27
+  cross-depends:
28
+    - name: restart_ceph_osd
29
+      role: ceph-osd
30
+  required_for: []
31
+  parameters:
32
+    puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/unset_noout.pp
33
+    puppet_modules: /etc/fuel/octane/puppet
34
+    timeout: 600
35
+
36
+- id: remove_hiera_override
37
+  type: shell
38
+  version: 2.1.0
39
+  groups: [ceph-osd]
40
+  requires: [unset_noout]
41
+  required_for: []
42
+  parameters:
43
+    cmd: rm /etc/hiera/override/common.yaml || true
44
+    timeout: 60
45
+

+ 73
- 0
deployment/puppet/octane_tasks/graphs/orig/upgrade-osd-pre.yaml View File

@@ -0,0 +1,73 @@
1
+# GROUPS
2
+- id: ceph-osd
3
+  type: group
4
+  role: [ceph-osd]
5
+  fault_tolerance: 0
6
+
7
+# TASKS
8
+- id: rsync_octane
9
+  type: sync
10
+  version: 2.1.0
11
+  groups: [ceph-osd]
12
+  requires: []
13
+  required_for: []
14
+  parameters:
15
+    src: rsync://{MASTER_IP}:/octane_code/puppet
16
+    dst: /etc/fuel/octane/
17
+    timeout: 180
18
+
19
+- id: remove_hiera_section_repo_setup
20
+  type: shell
21
+  version: 2.1.0
22
+  groups: [ceph-osd]
23
+  requires: [rsync_octane]
24
+  required_for: []
25
+  parameters:
26
+    cmd: python /etc/fuel/octane/puppet/octane_tasks/files/delete_section.py /etc/astute.yaml repo_setup repos
27
+    timeout: 60
28
+
29
+- id: override_repos_in_hiera
30
+  type: upload_file
31
+  version: 2.1.0
32
+  groups: [ceph-osd]
33
+  requires: []
34
+  required_for: []
35
+  parameters:
36
+    path: /etc/hiera/override/common.yaml
37
+    data:
38
+      yaql_exp: >
39
+        ({"repo_setup" => {"repos" => $.repo_setup.upgrade_osd}}.toYaml())
40
+
41
+- id: cleanup_existing_repos
42
+  type: shell
43
+  version: 2.1.0
44
+  groups: [ceph-osd]
45
+  requires: []
46
+  required_for: []
47
+  parameters:
48
+    cmd: >
49
+      tar zcf /root/sources.list.d-backup-$(date +%F-%H%M).tar.gz /etc/apt/sources.list.d;
50
+      rm /etc/apt/sources.list.d/*.list || true
51
+    timeout: 60
52
+
53
+- id: rsync_latest_puppet
54
+  type: sync
55
+  version: 2.1.0
56
+  groups: [ceph-osd]
57
+  requires: []
58
+  required_for: []
59
+  parameters:
60
+    src: rsync://{MASTER_IP}:/puppet/modules/
61
+    dst: /etc/fuel/octane/latest_modules
62
+    timeout: 180
63
+
64
+- id: setup_new_repositories
65
+  type: puppet
66
+  version: 2.1.0
67
+  groups: [ceph-osd]
68
+  requires: [cleanup_existing_repos, rsync_latest_puppet, override_repos_in_hiera, remove_hiera_section_repo_setup]
69
+  required_for: []
70
+  parameters:
71
+    puppet_manifest: /etc/fuel/octane/latest_modules/osnailyfacter/modular/fuel_pkgs/setup_repositories.pp
72
+    puppet_modules: /etc/fuel/octane/latest_modules
73
+    timeout: 600

+ 62
- 0
deployment/puppet/octane_tasks/graphs/seed/upgrade-osd.yaml View File

@@ -0,0 +1,62 @@
1
+# GROUPS
2
+- id: primary-controller
3
+  type: group
4
+  role: [primary-controller]
5
+  fault_tolerance: 0
6
+
7
+# TASKS
8
+- id: rsync_octane
9
+  type: sync
10
+  version: 2.1.0
11
+  groups: [primary-controller]
12
+  requires: []
13
+  required_for: []
14
+  parameters:
15
+    src: rsync://{MASTER_IP}:/octane_code/puppet
16
+    dst: /etc/fuel/octane/
17
+    timeout: 180
18
+
19
+- id: ceph_osd_hiera
20
+  type: upload_file
21
+  version: 2.1.0
22
+  groups: [primary-controller]
23
+  requires: []
24
+  required_for: []
25
+  parameters:
26
+    path: /etc/hiera/override/common.yaml
27
+    data:
28
+      yaql_exp: >
29
+        ({"ceph_upgrade_release" => $.ceph_upgrade_release,
30
+          "ceph_upgrade_hostnames" => $.ceph_upgrade_hostnames}.toYaml())
31
+
32
+- id: set_noout
33
+  type: puppet
34
+  version: 2.1.0
35
+  groups: [primary-controller]
36
+  requires: [rsync_octane, ceph_osd_hiera]
37
+  required_for: []
38
+  parameters:
39
+    puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/set_noout.pp
40
+    puppet_modules: /etc/fuel/octane/puppet
41
+    timeout: 600
42
+
43
+- id: upgrade_ceph_packages
44
+  type: puppet
45
+  version: 2.1.0
46
+  groups: [primary-controller]
47
+  requires: [set_noout]
48
+  required_for: []
49
+  parameters:
50
+    puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/upgrade_ceph_packages.pp
51
+    puppet_modules: /etc/fuel/octane/puppet:/etc/puppet/modules
52
+    timeout: 600
53
+
54
+- id: remove_hiera_override
55
+  type: shell
56
+  version: 2.1.0
57
+  groups: [primary-controller]
58
+  requires: [upgrade_ceph_packages]
59
+  required_for: []
60
+  parameters:
61
+    cmd: rm /etc/hiera/override/common.yaml || true
62
+    timeout: 60

+ 21
- 0
deployment/puppet/octane_tasks/lib/puppet/parser/functions/ceph_equal_versions.rb View File

@@ -0,0 +1,21 @@
1
+Puppet::Parser::Functions.newfunction(:ceph_equal_versions, :type => :rvalue) do |args|
2
+  require 'json'
3
+
4
+  versions_1 = args[0]
5
+  versions_2 = args[1]
6
+
7
+  # Pre-check all versions for consistency. Each hash MUST contain same
8
+  # versions for all elements.
9
+  v1_equal = versions_1.values.all? {|val| val == versions_1.values[0]}
10
+  v2_equal = versions_2.values.all? {|val| val == versions_2.values[0]}
11
+
12
+  # Either array contains some values, that are not equal. This means, that something
13
+  # went wrong and relevant component has only been partially upgraded. Fail with info message.
14
+  fail "Partial upgrade detected, aborting. Current version layout: #{versions_1}, #{versions_2}" unless v1_equal and v2_equal
15
+
16
+  # Intersection of 2 arrays with any amount of equal elements will yield an
17
+  # array with only one element 
18
+  ret = (versions_1.values & versions_2.values).length == 1
19
+
20
+  ret
21
+end

+ 19
- 0
deployment/puppet/octane_tasks/lib/puppet/parser/functions/ceph_get_version.rb View File

@@ -0,0 +1,19 @@
1
+Puppet::Parser::Functions.newfunction(:ceph_get_version, :type => :rvalue) do |args|
2
+  require 'json'
3
+
4
+  service_type = args[0]
5
+  id = '*'
6
+  versions = {}
7
+
8
+
9
+  version_string = Puppet::Util::Execution.execute("ceph tell #{service_type}.#{id} version -f json")
10
+  version_string.lines.each do |line|
11
+    line = line.strip
12
+    if line.length > 0
13
+      entity, version = line.split(" ", 2)
14
+      entity = entity.tr(":", "")
15
+      versions[entity] = JSON.parse(version)['version']
16
+    end
17
+  end
18
+  versions
19
+end

+ 22
- 0
deployment/puppet/octane_tasks/manifests/restart_ceph_osd.pp View File

@@ -0,0 +1,22 @@
1
+# == class: octane_tasks::restart_ceph_osd
2
+#
3
+# this class restarts ceph osd after package upgrade
4
+#
5
+class octane_tasks::restart_ceph_osd {
6
+  $ceph_mon_versions = ceph_get_version('mon')
7
+  $ceph_osd_versions = ceph_get_version('osd')
8
+
9
+  Exec {
10
+    provider => shell,
11
+  }
12
+
13
+  if ! ceph_equal_versions($ceph_mon_versions, $ceph_osd_versions) {
14
+
15
+    exec { 'restart-ceph-osd':
16
+      command => 'restart ceph-osd-all',
17
+    }
18
+
19
+  } else {
20
+    notice('the version of osd on current node matches mon version, nothing to upgrade.')
21
+  }
22
+}

+ 23
- 0
deployment/puppet/octane_tasks/manifests/set_noout.pp View File

@@ -0,0 +1,23 @@
1
+# == class: octane_tasks::set_noout
2
+#
3
+# this class sets the noout flag for osd pre-upgrade
4
+#
5
+class octane_tasks::set_noout {
6
+  $ceph_mon_versions = ceph_get_version('mon')
7
+  $ceph_osd_versions = ceph_get_version('osd')
8
+
9
+  Exec {
10
+    provider => shell,
11
+  }
12
+
13
+  if ! ceph_equal_versions($ceph_mon_versions, $ceph_osd_versions) {
14
+
15
+    exec { 'set-noout-flag':
16
+      command => 'ceph osd set noout',
17
+      unless  => 'ceph -s | grep -q "noout flag.\+ set"',
18
+    }
19
+
20
+  } else {
21
+    notice('the version of osd on current node matches mon version, nothing to upgrade.')
22
+  }
23
+}

+ 16
- 0
deployment/puppet/octane_tasks/manifests/unset_noout.pp View File

@@ -0,0 +1,16 @@
1
+# == Class: octane_tasks::unset_noout
2
+#
3
+# This class unsets the noout flag for OSD pre-upgrade
4
+#
5
+class octane_tasks::unset_noout {
6
+
7
+  Exec {
8
+    provider => shell,
9
+  }
10
+
11
+  exec { 'unset-noout-flag':
12
+    command => 'ceph osd unset noout',
13
+    onlyif  => 'ceph -s | grep -q "noout flag.\+ set"',
14
+  }
15
+
16
+}

+ 26
- 0
deployment/puppet/octane_tasks/manifests/upgrade_ceph_packages.pp View File

@@ -0,0 +1,26 @@
1
+# == class: octane_tasks::upgrade_ceph_packages
2
+#
3
+# this class upgrades ceph packages on the current node
4
+#
5
+class octane_tasks::upgrade_ceph_packages {
6
+  $ceph_mon_versions = ceph_get_version('mon')
7
+  $ceph_osd_versions = ceph_get_version('osd')
8
+
9
+  $ceph_release = hiera('ceph_upgrade_release')
10
+  $node_hostnames_string = join(hiera('ceph_upgrade_hostnames'), ' ')
11
+
12
+  Exec {
13
+    provider => shell,
14
+  }
15
+
16
+  if ! ceph_equal_versions($ceph_mon_versions, $ceph_osd_versions) {
17
+
18
+    exec { 'upgrade-ceph-packages':
19
+      command => "ceph-deploy install --release ${ceph_release} ${node_hostnames_string}",
20
+    }
21
+
22
+  } else {
23
+    notice('the version of osd on current node matches mon version, nothing to upgrade.')
24
+  }
25
+}
26
+

+ 3
- 0
deployment/puppet/octane_tasks/modular/restart_ceph_osd.pp View File

@@ -0,0 +1,3 @@
1
+notice('MODULAR: octane_tasks::restart_ceph_osd.pp')
2
+
3
+include ::octane_tasks::restart_ceph_osd

+ 3
- 0
deployment/puppet/octane_tasks/modular/set_noout.pp View File

@@ -0,0 +1,3 @@
1
+notice('MODULAR: octane_tasks::set_noout.pp')
2
+
3
+include ::octane_tasks::set_noout

+ 3
- 0
deployment/puppet/octane_tasks/modular/unset_noout.pp View File

@@ -0,0 +1,3 @@
1
+notice('MODULAR: octane_tasks::unset_noout.pp')
2
+
3
+include ::octane_tasks::unset_noout

+ 3
- 0
deployment/puppet/octane_tasks/modular/upgrade_ceph_packages.pp View File

@@ -0,0 +1,3 @@
1
+notice('MODULAR: octane_tasks::upgrade_ceph_packages.pp')
2
+
3
+include ::octane_tasks::upgrade_ceph_packages

Loading…
Cancel
Save