Variable supported_policy_files contains mangled filenames under python 3.7

Bug #1851249 reported by Martin Chlumsky
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
kolla-ansible
Fix Released
Medium
Martin Chlumsky
Train
Fix Released
Medium
Martin Chlumsky
Ussuri
Fix Released
Medium
Martin Chlumsky

Bug Description

The variable supported_policy_files gets set here:

https://github.com/openstack/kolla-ansible/blob/master/ansible/roles/horizon/tasks/policy_item.yml#L5

Under python 3.7, it contains mangled filenames that are shown here using the ansible debug module:
TASK [horizon : debug] ************************************************************************************************************************************************************
ok: [server.name.tld] => {
    "supported_policy_files": [
        "nova_policy.yamlnova_",
        "nova_policy.jsonnova_"
    ]
}

This is most likely related to this python issue: https://bugs.python.org/issue32308
See also https://docs.python.org/3/library/re.html#re.sub (See "Changed in version 3.7")

Workaround:
To resolve the issue, change * to + in the line specified above.

Revision history for this message
Mark Goddard (mgoddard) wrote :

Thanks, are you planning to fix this?

Changed in kolla-ansible:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Martin Chlumsky (martin-chlumsky) wrote :

Sure.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (master)

Fix proposed to branch: master
Review: https://review.opendev.org/692855

Changed in kolla-ansible:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (master)

Reviewed: https://review.opendev.org/692855
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=9d0ccad15aa358cdc6dc2f690bf181cb8354d150
Submitter: Zuul
Branch: master

commit 9d0ccad15aa358cdc6dc2f690bf181cb8354d150
Author: Martin Chlumsky <email address hidden>
Date: Mon Nov 4 11:54:58 2019 -0500

    Fix empty match while setting supported_policy_files

    When supported_policy_files gets set under python 3.7 [1], the regex '(.*)'
    matches twice, once for the policy file name and once more for the empty string
    that follows the policy file name. This is new behavior under python
    3.7. [2]

    This leads to the replacement string being written out twice resulting
    in something like this: "nova_policy.yamlnova_".

    This patch changes the regex to '(.+)' ensuring there is no match success
    against the empty string.

    [1]:
    - set_fact:
        supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.*)', '{{ project_name }}_\\1') | list }}"

    [2]: https://docs.python.org/3/library/re.html#re.sub

    Change-Id: Ie5278832e293364c66d53ddb07dff9c5409f0cc6
    Closes-Bug: 1851249

Changed in kolla-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/692989

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/stein)

Reviewed: https://review.opendev.org/692989
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=9df6ee216a30111e744d1a5bce2eea1238b7694f
Submitter: Zuul
Branch: stable/stein

commit 9df6ee216a30111e744d1a5bce2eea1238b7694f
Author: Martin Chlumsky <email address hidden>
Date: Mon Nov 4 11:54:58 2019 -0500

    Fix empty match while setting supported_policy_files

    When supported_policy_files gets set under python 3.7 [1], the regex '(.*)'
    matches twice, once for the policy file name and once more for the empty string
    that follows the policy file name. This is new behavior under python
    3.7. [2]

    This leads to the replacement string being written out twice resulting
    in something like this: "nova_policy.yamlnova_".

    This patch changes the regex to '(.+)' ensuring there is no match success
    against the empty string.

    [1]:
    - set_fact:
        supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.*)', '{{ project_name }}_\\1') | list }}"

    [2]: https://docs.python.org/3/library/re.html#re.sub

    Change-Id: Ie5278832e293364c66d53ddb07dff9c5409f0cc6
    Closes-Bug: 1851249
    (cherry picked from commit 9d0ccad15aa358cdc6dc2f690bf181cb8354d150)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 8.1.0

This issue was fixed in the openstack/kolla-ansible 8.1.0 release.

Revision history for this message
Benjamin FÜHRMANN (fuhrmannb) wrote :

Hi, seems this patch is present in Stein and all releases starting from Ussuri but not in Train version.

Can you include this patch in kolla-ansible Train version too? Thanks.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/c/openstack/kolla-ansible/+/799244

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/train)

Reviewed: https://review.opendev.org/c/openstack/kolla-ansible/+/799244
Committed: https://opendev.org/openstack/kolla-ansible/commit/93e1ed14820f2c41f93ae1c746675f96073bfd57
Submitter: "Zuul (22348)"
Branch: stable/train

commit 93e1ed14820f2c41f93ae1c746675f96073bfd57
Author: Martin Chlumsky <email address hidden>
Date: Mon Nov 4 11:54:58 2019 -0500

    Fix empty match while setting supported_policy_files

    When supported_policy_files gets set under python 3.7 [1], the regex '(.*)'
    matches twice, once for the policy file name and once more for the empty string
    that follows the policy file name. This is new behavior under python
    3.7. [2]

    This leads to the replacement string being written out twice resulting
    in something like this: "nova_policy.yamlnova_".

    This patch changes the regex to '(.+)' ensuring there is no match success
    against the empty string.

    [1]:
    - set_fact:
        supported_policy_files: "{{ supported_policy_format_list | map('regex_replace', '(.*)', '{{ project_name }}_\\1') | list }}"

    [2]: https://docs.python.org/3/library/re.html#re.sub

    Change-Id: Ie5278832e293364c66d53ddb07dff9c5409f0cc6
    Closes-Bug: 1851249
    (cherry picked from commit 9d0ccad15aa358cdc6dc2f690bf181cb8354d150)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible train-eol

This issue was fixed in the openstack/kolla-ansible train-eol release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.