From 8d2d37064ee643d8c5830eedea08194e606c1896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Wed, 30 Sep 2020 17:37:57 +0200
Subject: [PATCH] Control Neutron migrations

Since [1] and [2] merged, K-A has to control Neutron migrations
to migrate all required projects.

This patch additionally fixes the other observed issue.

[1] https://review.opendev.org/750075
[2] https://review.opendev.org/753543

Change-Id: I09e1b421e9066890b50bd82331a3050de252464f
Closes-Bug: #1894380
Depends-On: https://review.opendev.org/755346
---
 ansible/roles/neutron/defaults/main.yml       | 18 ++++++++++++-
 .../roles/neutron/tasks/bootstrap_service.yml | 27 +------------------
 .../roles/neutron/tasks/rolling_upgrade.yml   |  5 ----
 .../notes/bug-1894380-01897f17dd35190c.yaml   |  7 +++++
 4 files changed, 25 insertions(+), 32 deletions(-)
 create mode 100644 releasenotes/notes/bug-1894380-01897f17dd35190c.yaml

diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml
index af3fd83343..442bafa499 100644
--- a/ansible/roles/neutron/defaults/main.yml
+++ b/ansible/roles/neutron/defaults/main.yml
@@ -383,6 +383,17 @@ neutron_l3_agent_host_ipv6_neigh_gc_thresh1: "{{ neutron_l3_agent_host_ipv4_neig
 neutron_l3_agent_host_ipv6_neigh_gc_thresh2: "{{ neutron_l3_agent_host_ipv4_neigh_gc_thresh2 }}"
 neutron_l3_agent_host_ipv6_neigh_gc_thresh3: "{{ neutron_l3_agent_host_ipv4_neigh_gc_thresh3 }}"
 
+####################
+# Subprojects
+####################
+neutron_subprojects:
+  - name: "networking-sfc"
+    enabled: "{{ enable_neutron_sfc | bool }}"
+  - name: "neutron-dynamic-routing"
+    enabled: "{{ enable_neutron_bgp_dragent | bool }}"
+  - name: "neutron-vpnaas"
+    enabled: "{{ enable_neutron_vpnaas | bool }}"
+
 ####################
 # Mechanism drivers
 ####################
@@ -419,11 +430,16 @@ extension_drivers:
 
 neutron_extension_drivers: "{{ extension_drivers | selectattr('enabled', 'equalto', true) | list }}"
 
+####################
+# Neutron bootstrap
+####################
+neutron_bootstrap_services: "{{ neutron_subprojects | selectattr('enabled') | map(attribute='name') | list }}"
+
 ####################
 # Neutron upgrade
 ####################
 neutron_enable_rolling_upgrade: "yes"
-neutron_rolling_upgrade_services: ["neutron", "neutron-vpnaas"]
+neutron_rolling_upgrade_services: "{{ neutron_subprojects | selectattr('enabled') | map(attribute='name') | list }}"
 
 ####################
 # Service Plugins
diff --git a/ansible/roles/neutron/tasks/bootstrap_service.yml b/ansible/roles/neutron/tasks/bootstrap_service.yml
index 62c9e6374a..6c212bd690 100644
--- a/ansible/roles/neutron/tasks/bootstrap_service.yml
+++ b/ansible/roles/neutron/tasks/bootstrap_service.yml
@@ -10,6 +10,7 @@
     environment:
       KOLLA_BOOTSTRAP:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+      NEUTRON_BOOTSTRAP_SERVICES: "{{ neutron_bootstrap_services | join(' ') }}"
     image: "{{ neutron_server.image }}"
     labels:
       BOOTSTRAP:
@@ -18,29 +19,3 @@
     volumes: "{{ neutron_server.volumes }}"
   run_once: True
   delegate_to: "{{ groups[neutron_server.group][0] }}"
-  when: (kolla_action == "deploy")
-        or (not neutron_enable_rolling_upgrade | bool)
-
-- name: Running Neutron sfc bootstrap container
-  vars:
-    neutron_server: "{{ neutron_services['neutron-server'] }}"
-  become: true
-  kolla_docker:
-    action: "start_container"
-    common_options: "{{ docker_common_options }}"
-    detach: False
-    environment:
-      NEUTRON_SFC_BOOTSTRAP:
-      KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
-    image: "{{ neutron_server.image }}"
-    labels:
-      BOOTSTRAP:
-    name: "bootstrap_neutron_sfc"
-    restart_policy: no
-    volumes: "{{ neutron_server.volumes }}"
-  when:
-    - enable_neutron_sfc | bool
-    - neutron_server.enabled | bool
-    - neutron_server.host_in_groups | bool
-  run_once: True
-  delegate_to: "{{ groups[neutron_server.group][0] }}"
diff --git a/ansible/roles/neutron/tasks/rolling_upgrade.yml b/ansible/roles/neutron/tasks/rolling_upgrade.yml
index 27fd413f6f..f3512c25d3 100644
--- a/ansible/roles/neutron/tasks/rolling_upgrade.yml
+++ b/ansible/roles/neutron/tasks/rolling_upgrade.yml
@@ -30,11 +30,6 @@
   run_once: True
   delegate_to: "{{ groups['neutron-server'][0] }}"
 
-- include_tasks: bootstrap_service.yml
-  vars:
-    neutron_server: "{{ neutron_services['neutron-server'] }}"
-  when: (enable_neutron_sfc | bool and neutron_server.enabled | bool)
-
 - name: Flush Handlers
   meta: flush_handlers
 
diff --git a/releasenotes/notes/bug-1894380-01897f17dd35190c.yaml b/releasenotes/notes/bug-1894380-01897f17dd35190c.yaml
new file mode 100644
index 0000000000..14e82f9b6d
--- /dev/null
+++ b/releasenotes/notes/bug-1894380-01897f17dd35190c.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Fixes some Neutron subprojects not using the rolling upgrade scheme.
+    SFC forcibly used the legacy scheme and dynamic routing was not migrated
+    at all.
+    `LP#1894380 <https://launchpad.net/bugs/1894380>`__
-- 
GitLab