Browse Source

Add exclusions to the unused param warning

This adds the ability for us to specifically exclude some patterns of
parameters from the warning that is generated during the deployment for
unused heat params. The params being added are generated by the
deployment and not necessarily provided by the end user. The params
currently being excluded are:

 * '^(Docker|Container).*Image$' - container image vars
 * '^SwiftFetchDir(Get|Put)Tempurl$' - temp url for ceph
 * '^PythonInterpreter$' - python executable for the deploy

The warning message is also slightly adjusted to try and clarify that
the vars might be valid but not used due to service or deployment
configs.

Conflicts:
	tripleoclient/constants.py
	tripleoclient/workflows/parameters.py
Change-Id: Iad7d97346993b5c95443092b81d056293cdad752
Closes-Bug: #1842754
(cherry picked from commit b25a9a953b)
tags/11.5.1^0
Alex Schultz 2 weeks ago
parent
commit
a357740a0b
2 changed files with 23 additions and 5 deletions
  1. 10
    0
      tripleoclient/constants.py
  2. 13
    5
      tripleoclient/workflows/parameters.py

+ 10
- 0
tripleoclient/constants.py View File

@@ -117,3 +117,13 @@ DEPRECATED_SERVICES = {"OS::TripleO::Services::OpenDaylightApi":
117 117
                        "OpenDaylight to another networking backend. We "
118 118
                        "recommend you understand other networking "
119 119
                        "alternatives such as OVS or OVN. "}
120
+
121
+# regex patterns to exclude when looking for unused params
122
+# - exclude *Image params as they may be unused because the service is not
123
+#   enabled
124
+# - exclude SwiftFetchDir*Tempurl because it's used by ceph and generated by us
125
+# - exclude PythonInterpreter because it's generated by us and only used
126
+#   in some custom scripts
127
+UNUSED_PARAMETER_EXCLUDES_RE = ['^(Docker|Container).*Image$',
128
+                                '^SwiftFetchDir(Get|Put)Tempurl$',
129
+                                '^PythonInterpreter$']

+ 13
- 5
tripleoclient/workflows/parameters.py View File

@@ -9,8 +9,10 @@
9 9
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 10
 # License for the specific language governing permissions and limitations
11 11
 # under the License.
12
+import re
12 13
 import yaml
13 14
 
15
+from tripleoclient.constants import UNUSED_PARAMETER_EXCLUDES_RE
14 16
 from tripleoclient import exceptions
15 17
 from tripleoclient.workflows import base
16 18
 
@@ -126,12 +128,18 @@ def check_deprecated_parameters(clients, container):
126 128
             print('\n'.join(['  {}'.format(param)
127 129
                             for param in deprecated_params]))
128 130
 
131
+        # exclude our known params that may not be used
132
+        ignore_re = re.compile('|'.join(UNUSED_PARAMETER_EXCLUDES_RE))
133
+        unused_params = [p for p in unused_params if not ignore_re.search(p)]
134
+
129 135
         if unused_params:
130
-            print('WARNING: Following parameter(s) are defined but not used '
131
-                  'in plan. Could be possible that parameter is valid but '
132
-                  'currently not used.')
133
-            print('\n'.join(['  {}'.format(param)
134
-                            for param in unused_params]))
136
+            unused_join = ', '.join(
137
+                ['{param}'.format(param=param) for param in unused_params])
138
+            print('WARNING: Following parameter(s) are defined but not '
139
+                  'currently used in the deployment plan. These parameters '
140
+                  'may be valid but not in use due to the service or '
141
+                  'deployment configuration.'
142
+                  ' {unused_join}'.format(unused_join=unused_join))
135 143
 
136 144
         if invalid_role_specific_params:
137 145
             print('WARNING: Following parameter(s) are not supported as '

Loading…
Cancel
Save