Enforce TRIPLEO_MINOR_UPDATE to be a string at all times

It can happen that TRIPLEO_MINOR_UPDATE gets interpreted as a boolean
and not as a string. This has the consequence that python
when calling subprocess.run() will call os.fsencode() on the
boolean variable and we can get the following error:

    "error": "Traceback (most recent call last):\n  File \"/tmp/ansible_tripleo_diff_exec_payload__m7cmu0z/ansible_tripleo_diff_exec_payload.zip/ansible/modules/tripleo_diff_exec.py\", line 123, in run\n  File \"/
usr/lib64/python3.6/subprocess.py\", line 423, in run\n    with Popen(*popenargs, **kwargs) as process:\n  File \"/usr/lib64/python3.6/subprocess.py\", line 729, in __init__\n    restore_signals, start_new_session
)\n  File \"/usr/lib64/python3.6/subprocess.py\", line 1275, in _execute_child\n    env_list.append(k + b'=' + os.fsencode(v))\n  File \"/usr/lib64/python3.6/os.py\", line 800, in fsencode\n    filename = fspath(f
ilename)  # Does type-checking of `filename`.\nTypeError: expected str, bytes or os.PathLike object, not bool\n",
    "invocation": {
        "module_args": {
            "command": "/var/lib/container-config-scripts/pacemaker_restart_bundle.sh cinder_volume openstack-cinder-volume openstack-cinder-volume Started",
            "environment": {
                "TRIPLEO_MINOR_UPDATE": true
            },

Let's force it to be a string so we can never hit this.

Tested on the provided reproducer.

Change-Id: Ia4caa36a6edd865b3e1dcdf9254c7f183b64faaf
Closes-Bug: #1918111
(cherry picked from commit bdd2cfe2df)
This commit is contained in:
Michele Baldessari 2021-03-10 09:59:00 +01:00
parent a1b098627c
commit c7c0c5d707
1 changed files with 1 additions and 1 deletions

View File

@ -65,4 +65,4 @@
state_file: "{{ tripleo_ha_wrapper_config_basedir }}/{{ tripleo_ha_wrapper_puppet_config_volume }}.md5sum"
state_file_suffix: "{{ tripleo_ha_wrapper_config_suffix }}"
environment:
TRIPLEO_MINOR_UPDATE: "{{ tripleo_ha_wrapper_minor_update|default('') }}"
TRIPLEO_MINOR_UPDATE: "{{ tripleo_ha_wrapper_minor_update|default('') | string }}"