Browse Source

Added missing upgrade-db attributes to cluster

Change-Id: I78e48de4f44921ef4af7b9a6c0f2625f9003101c
Dmitry Nikishov 2 years ago
parent
commit
9158ec52b3

+ 23
- 1
deployment/puppet/octane_tasks/graphs/orig/upgrade-db.yaml View File

@@ -5,6 +5,18 @@
5 5
   fault_tolerance: 0
6 6
 
7 7
 # TASKS
8
+- id: add_hiera_override
9
+  type: upload_file
10
+  version: 2.1.0
11
+  groups: [primary-controller]
12
+  requires: []
13
+  required_for: []
14
+  parameters:
15
+    path: /etc/hiera/override/common.yaml
16
+    data:
17
+      yaql_exp: >
18
+        ({"upgrade" => $.upgrade}.toYaml())
19
+
8 20
 - id: rsync_octane
9 21
   type: sync
10 22
   version: 2.1.0
@@ -20,7 +32,7 @@
20 32
   type: puppet
21 33
   version: 2.1.0
22 34
   groups: [primary-controller]
23
-  requires: [rsync_octane]
35
+  requires: [rsync_octane, add_hiera_override]
24 36
   required_for: []
25 37
   parameters:
26 38
     puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/nova_db_migrate_flavor_data_70.pp
@@ -60,3 +72,13 @@
60 72
     src: /var/tmp/dbs.original.sql.gz.enc
61 73
     dst: rsync://{MASTER_IP}:/octane_data/
62 74
     timeout: 180
75
+
76
+- id: remove_hiera_override
77
+  type: shell
78
+  version: 2.1.0
79
+  groups: [primary-controller]
80
+  requires: [mysqldump_upload_to_master]
81
+  required_for: []
82
+  parameters:
83
+    cmd: rm /etc/hiera/override/common.yaml || true
84
+    timeout: 60

+ 23
- 1
deployment/puppet/octane_tasks/graphs/seed/upgrade-db.yaml View File

@@ -10,6 +10,18 @@
10 10
   fault_tolerance: 0
11 11
 
12 12
 # TASKS
13
+- id: add_hiera_override
14
+  type: upload_file
15
+  version: 2.1.0
16
+  groups: [primary-controller, controller]
17
+  requires: []
18
+  required_for: []
19
+  parameters:
20
+    path: /etc/hiera/override/common.yaml
21
+    data:
22
+      yaql_exp: >
23
+        ({"upgrade" => $.upgrade}.toYaml())
24
+
13 25
 - id: rsync_octane
14 26
   type: sync
15 27
   version: 2.1.0
@@ -38,7 +50,7 @@
38 50
   type: puppet
39 51
   version: 2.1.0
40 52
   groups: [primary-controller, controller]
41
-  requires: [rsync_octane, delete_fuel_resources]
53
+  requires: [rsync_octane, delete_fuel_resources, add_hiera_override]
42 54
   required_for: []
43 55
   parameters:
44 56
     puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/stop_controller_services.pp
@@ -92,3 +104,13 @@
92 104
     puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/neutron_migrations_for_fuel_8.pp
93 105
     puppet_modules:  /etc/fuel/octane/puppet:/etc/puppet/modules
94 106
     timeout: 360
107
+
108
+- id: remove_hiera_override
109
+  type: shell
110
+  version: 2.1.0
111
+  groups: [primary-controller, controller]
112
+  requires: [neutron_migrations_for_fuel_8, stop_controller_services]
113
+  required_for: []
114
+  parameters:
115
+    cmd: rm /etc/hiera/override/common.yaml || true
116
+    timeout: 60

+ 25
- 0
octane/commands/upgrade_db.py View File

@@ -62,8 +62,33 @@ def upgrade_db(orig_id, seed_id, db_role_name):
62 62
         db.cinder_volume_update_host(orig_env, seed_env)
63 63
 
64 64
 
65
+def add_upgrade_attrs_to_settings(orig_env, seed_env):
66
+    upgrade_hash = {
67
+        'relation_info': {
68
+            'orig_cluster_version': orig_env.data['fuel_version'],
69
+            'seed_cluster_version': seed_env.data['fuel_version']
70
+        }
71
+    }
72
+
73
+    orig_attrs = orig_env.get_settings_data()
74
+    orig_upgrade = orig_attrs['editable']['common'].get('upgrade', {})
75
+    orig_upgrade.update(upgrade_hash)
76
+    orig_attrs['editable']['common']['upgrade'] = orig_upgrade
77
+    orig_env.set_settings_data(orig_attrs)
78
+
79
+    seed_attrs = seed_env.get_settings_data()
80
+    seed_upgrade = seed_attrs['editable']['common'].get('upgrade', {})
81
+    seed_upgrade.update(upgrade_hash)
82
+    seed_attrs['editable']['common']['upgrade'] = seed_upgrade
83
+    seed_env.set_settings_data(seed_attrs)
84
+
85
+
65 86
 def upgrade_db_with_graph(orig_id, seed_id):
66 87
     """Upgrade db using deployment graphs."""
88
+    orig_env = environment_obj.Environment(orig_id)
89
+    seed_env = environment_obj.Environment(seed_id)
90
+    add_upgrade_attrs_to_settings(orig_env, seed_env)
91
+
67 92
     # Upload all graphs
68 93
     deploy.upload_graphs(orig_id, seed_id)
69 94
 

+ 6
- 0
octane/tests/test_upgrade_db.py View File

@@ -126,11 +126,17 @@ def test_upgrade_db_with_graph(mocker, calls, graph_names, catch):
126 126
     if catch is not None:
127 127
         expected_exception = results[catch]
128 128
 
129
+    mock_settings_hash = {'editable': {'common': {}}}
129 130
     mocker.patch("octane.util.deployment.upload_graphs")
130 131
     mocker.patch("octane.util.deployment.execute_graph_and_wait",
131 132
                  side_effect=execute_graph)
132 133
     mocker.patch("octane.util.deployment.get_cluster_graph_names",
133 134
                  return_value=graph_names)
135
+    mocker.patch("fuelclient.objects.Environment.get_settings_data",
136
+                 return_value=mock_settings_hash)
137
+    mocker.patch("fuelclient.objects.Environment.set_settings_data")
138
+    mocker.patch("fuelclient.objects.BaseObject.data",
139
+                 return_value=mock_settings_hash)
134 140
 
135 141
     if expected_exception is not None:
136 142
         with pytest.raises(ExecutionError) as excinfo:

Loading…
Cancel
Save