From 0101b463873d84e32f758113b43666eb98790534 Mon Sep 17 00:00:00 2001
From: Mike Fedosin <mfedosin@redhat.com>
Date: Wed, 28 Nov 2018 15:59:53 +0100
Subject: [PATCH] Allow to skip docker reconfiguration during stack update

When installing OpenShift by means of TripleO, after
the initial docker configuration, openshift-ansible
also adds several parameters there.

Then, if we want to remove a single node, then a stack
update is performed, which returns the configuration
to its original state. In other words, it removes all
parameters added by openshift-ansible, which breaks OpenShift.

This commit adds the ability to disable reconfiguration of
docker at the time of stack update for all roles associated
with OpenShift.

Closes-Bug: #1804790

Depends-On: I0bcaeea9cd24ab35a81d8c3d6fc3a384c1e4c3c2
Change-Id: If202be5d27d81672e39cbe21867459d277220e23
---
 puppet/services/docker.yaml  | 22 ++++++++++++++++++++++
 roles/OpenShiftAllInOne.yaml |  1 +
 roles/OpenShiftInfra.yaml    |  1 +
 roles/OpenShiftMaster.yaml   |  1 +
 roles/OpenShiftWorker.yaml   |  1 +
 5 files changed, 26 insertions(+)

diff --git a/puppet/services/docker.yaml b/puppet/services/docker.yaml
index b6d29698dd..84ca549974 100644
--- a/puppet/services/docker.yaml
+++ b/puppet/services/docker.yaml
@@ -68,6 +68,12 @@ parameters:
     default: ''
     description: User added to the docker group in order to use container commands.
     type: string
+  DockerSkipUpdateReconfiguration:
+    default: false
+    type: boolean
+    description: Flag to disable docker reconfiguration during stack update.
+    tags:
+      - role_specific
 parameter_groups:
 - label: deprecated
   description: |
@@ -78,6 +84,21 @@ parameter_groups:
   parameters:
   - DockerAdditionalSockets
 
+resources:
+  # Merging role-specific parameters (RoleParameters) with the default parameters.
+  # RoleParameters will have the precedence over the default parameters.
+  RoleParametersValue:
+    type: OS::Heat::Value
+    properties:
+      type: json
+      value:
+        map_replace:
+          - map_replace:
+            - DockerSkipUpdateReconfiguration: DockerSkipUpdateReconfiguration
+            - values: {get_param: [RoleParameters]}
+          - values:
+              DockerSkipUpdateReconfiguration: {get_param: DockerSkipUpdateReconfiguration}
+
 conditions:
   insecure_registry_is_empty: {equals : [{get_param: DockerInsecureRegistryAddress}, []]}
   service_debug_unset: {equals : [{get_param: DockerDebug}, '']}
@@ -109,6 +130,7 @@ outputs:
                   - {get_param: DockerInsecureRegistryAddress}
               container_registry_mirror: {get_param: DockerRegistryMirror}
               container_registry_network_options: {get_param: DockerNetworkOptions}
+              container_registry_skip_reconfiguration: {get_attr: [RoleParametersValue, value, DockerSkipUpdateReconfiguration]}
           - include_role:
               name: container-registry
               tasks_from: docker
diff --git a/roles/OpenShiftAllInOne.yaml b/roles/OpenShiftAllInOne.yaml
index 1399f0dd0c..69520b1765 100644
--- a/roles/OpenShiftAllInOne.yaml
+++ b/roles/OpenShiftAllInOne.yaml
@@ -7,6 +7,7 @@
   CountDefault: 1
   RoleParametersDefault:
     OpenShiftNodeGroupName: 'node-config-all-in-one'
+    DockerSkipUpdateReconfiguration: true
   tags:
     - primary
     - controller
diff --git a/roles/OpenShiftInfra.yaml b/roles/OpenShiftInfra.yaml
index 3ff645cd54..3781fe450f 100644
--- a/roles/OpenShiftInfra.yaml
+++ b/roles/OpenShiftInfra.yaml
@@ -7,6 +7,7 @@
   CountDefault: 1
   RoleParametersDefault:
     OpenShiftNodeGroupName: 'node-config-infra'
+    DockerSkipUpdateReconfiguration: true
   tags:
     - openshift
   networks:
diff --git a/roles/OpenShiftMaster.yaml b/roles/OpenShiftMaster.yaml
index eee9b011fd..c16302aa79 100644
--- a/roles/OpenShiftMaster.yaml
+++ b/roles/OpenShiftMaster.yaml
@@ -7,6 +7,7 @@
   CountDefault: 1
   RoleParametersDefault:
     OpenShiftNodeGroupName: 'node-config-master'
+    DockerSkipUpdateReconfiguration: true
   tags:
     - primary
     - controller
diff --git a/roles/OpenShiftWorker.yaml b/roles/OpenShiftWorker.yaml
index 2d5c9ddc6b..3c4bd2fb1b 100644
--- a/roles/OpenShiftWorker.yaml
+++ b/roles/OpenShiftWorker.yaml
@@ -7,6 +7,7 @@
   CountDefault: 1
   RoleParametersDefault:
     OpenShiftNodeGroupName: 'node-config-compute'
+    DockerSkipUpdateReconfiguration: true
   tags:
     - openshift
   networks: