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)
This commit is contained in:
Alex Schultz 2019-09-05 10:04:03 -06:00
parent 8e4592f0df
commit a357740a0b
2 changed files with 23 additions and 5 deletions

View File

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

View File

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