Browse Source

Pre-cleanup migration resources and fix validation

This patch avoids the duplication/conflict of resources
(pre-migration and post-migration) if the migration was stopped
by an error and it's retried.

Also makes sure that a non-working validation will fail.

Change-Id: I5ce17e23ee52e936aeee78f64fb0df127816b1bd
Closes-Bug: #1804477
Miguel Angel Ajo 5 months ago
parent
commit
c2a98b3d90

+ 11
- 3
migration/tripleo_environment/playbooks/roles/post-migration/tasks/main.yml View File

@@ -8,7 +8,6 @@
8 8
   include_role:
9 9
     name: resources/validate
10 10
   vars:
11
-      ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
12 11
       restart_server: true
13 12
   when: validate_migration|bool
14 13
 
@@ -17,14 +16,21 @@
17 16
     name: resources/cleanup
18 17
   tags:
19 18
     - post-migration
20
-  vars:
21
-      ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
22 19
   when: validate_migration|bool
23 20
 
24 21
 #
25 22
 # Create post-migration resources, validate, and then clean up
26 23
 #
27 24
 
25
+# Delete any existing resources to make sure we don't conflict on a second run
26
+- name: Delete any post migration resources (preventive)
27
+  include_role:
28
+    name: resources/cleanup
29
+  vars:
30
+      resource_suffix: "post"
31
+      silent_cleanup: true
32
+  when: validate_migration|bool
33
+
28 34
 - name: Create post-migration resources
29 35
   include_role:
30 36
     name: resources/create
@@ -35,6 +41,8 @@
35 41
 - name: Validate post migration resources
36 42
   include_role:
37 43
     name: resources/validate
44
+  vars:
45
+      resource_suffix: "post"
38 46
   when: validate_migration|bool
39 47
 
40 48
 - name: Delete the post migration resources

+ 8
- 4
migration/tripleo_environment/playbooks/roles/pre-migration/tasks/main.yml View File

@@ -1,13 +1,17 @@
1
+# Delete any existing resources to make sure we don't conflict on a second run
2
+- name: Delete any existing pre migration resources (preventive)
3
+  include_role:
4
+    name: resources/cleanup
5
+  vars:
6
+      silent_cleanup: true
7
+  when: validate_migration|bool
8
+
1 9
 - name: Create the pre migration resource stack
2 10
   include_role:
3 11
     name: resources/create
4
-  vars:
5
-      ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
6 12
   when: validate_migration|bool
7 13
 
8 14
 - name: Validate the pre migration resources
9 15
   include_role:
10 16
     name: resources/validate
11
-  vars:
12
-      ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
13 17
   when: validate_migration|bool

+ 2
- 0
migration/tripleo_environment/playbooks/roles/resources/cleanup/defaults/main.yml View File

@@ -2,3 +2,5 @@
2 2
 
3 3
 cleanup_resource_script: cleanup-resources.sh.j2
4 4
 resource_suffix: "pre"
5
+ovn_migration_temp_dir: "{{ working_dir }}/{{ resource_suffix }}_migration_resources"
6
+silent_cleanup: false

+ 11
- 3
migration/tripleo_environment/playbooks/roles/resources/cleanup/tasks/main.yml View File

@@ -11,8 +11,16 @@
11 11
     dest: "{{ ovn_migration_temp_dir }}/cleanup-resources.sh"
12 12
     mode: 0744
13 13
 
14
-- name: Cleaning up the pre migration resources
14
+- name: Cleaning up the migration resources (verbose)
15 15
   shell: >
16 16
     set -o pipefail &&
17
-    {{ ovn_migration_temp_dir }}/cleanup-resources.sh 2>&1 >
18
-    cleanup-resources.sh.log
17
+    {{ ovn_migration_temp_dir }}/cleanup-resources.sh 2>&1 | tee
18
+    {{ ovn_migration_temp_dir }}/cleanup-resources.sh.log
19
+
20
+  when: not silent_cleanup
21
+
22
+- name: Cleaning up the migration resources (silent)
23
+  shell: >
24
+    {{ ovn_migration_temp_dir }}/cleanup-resources.sh >/dev/null 2>&1
25
+  when: silent_cleanup
26
+

+ 1
- 0
migration/tripleo_environment/playbooks/roles/resources/create/defaults/main.yml View File

@@ -2,3 +2,4 @@
2 2
 
3 3
 create_migration_resource_script: create-resources.sh.j2
4 4
 resource_suffix: "pre"
5
+ovn_migration_temp_dir: "{{ working_dir }}/{{ resource_suffix }}_migration_resources"

+ 1
- 1
migration/tripleo_environment/playbooks/roles/resources/create/tasks/main.yml View File

@@ -18,5 +18,5 @@
18 18
 - name: Creating migration resources
19 19
   shell: >
20 20
     set -o pipefail &&
21
-    {{ ovn_migration_temp_dir }}/create-migration-resources.sh 2>&1 >
21
+    {{ ovn_migration_temp_dir }}/create-migration-resources.sh 2>&1 | tee
22 22
     {{ ovn_migration_temp_dir }}/create-migration-resources.sh.log

+ 2
- 1
migration/tripleo_environment/playbooks/roles/resources/validate/defaults/main.yml View File

@@ -1,4 +1,5 @@
1 1
 validate_resources_script: validate-resources.sh.j2
2 2
 server_user_name: "cirros"
3 3
 restart_server: false
4
-resource_suffix: "pre"
4
+resource_suffix: "pre"
5
+ovn_migration_temp_dir: "{{ working_dir }}/{{ resource_suffix }}_migration_resources"

+ 1
- 1
migration/tripleo_environment/playbooks/roles/resources/validate/tasks/main.yml View File

@@ -7,6 +7,6 @@
7 7
 - name: Run the validation script
8 8
   shell: >
9 9
     set -o pipefail &&
10
-    {{ ovn_migration_temp_dir }}/validate-resources.sh 2>&1 >
10
+    {{ ovn_migration_temp_dir }}/validate-resources.sh 2>&1 | tee
11 11
     {{ ovn_migration_temp_dir }}/validate-resources.sh.log
12 12
 

+ 2
- 0
migration/tripleo_environment/playbooks/roles/resources/validate/templates/validate-resources.sh.j2 View File

@@ -1,6 +1,8 @@
1 1
 #!/bin/bash
2 2
 
3 3
 set -x
4
+set -e
5
+
4 6
 source {{ overcloudrc }}
5 7
 
6 8
 # This script validates the resources create by the resources/create role.

Loading…
Cancel
Save