Molecule: anyconfig breaks molecule on centos-8

Created on 13 Nov 2019  路  5Comments  路  Source: ansible-community/molecule

Issue Type

  • Bug report

Molecule and Ansible details

Initiall seen at https://zuul.opendev.org/t/openstack/build/236553c6a6d84d0788518f449f89bb18/log/job-output.txt

File "/home/zuul/test-python/lib/python3.6/site-packages/anyconfig/backends.py", line 44, in <module>
import anyconfig.backend.configobj

I am not yet sure which version of anyconfig caused this but because this is the 2nd breaking bug in two weeks and because anyconfig is solely used in a single place in order to us its dictionary-merge strategy, I wonder if it would not be better to drop it as a dependency.

bug critical

All 5 comments

I vote for replacing the anyconfig library with a simple recursive merge function. When I was tracking the configuration building, it just obfuscated the merge process.

Feel free to make a PR here.

I started adding a bit more tests for the merge_dicts function in order to get a clear idea on how anyconfig merge worked and I already found something interesting:

@pytest.mark.parametrize('a,b,x', [
    (dict(key={}), dict(key=2), dict(key=2)),
    (dict(key=1), dict(key={}), dict(key={})),
])
def test_merge_dicts(a, b, x):
    assert x == util.merge_dicts(a, b)

The merge fails in the first scenario (TypeError, int is not iterable) but goes through in the second one. And merge being asymmetric does not feel right. Any suggestions on how to proceed here? Should we always fail if only one of the values is dict? Should we simply replace the value in this case? Or should we keep the (in my honest opinion useless) existing behavior?

This issue seems very similar to Ansible hash_behaviour feature so I would be inclined to look at how Ansible does it and to reuse its implementation if possible. We can even document that we are using Ansible logic and avoid extra maintenance on the subject.

I prepared some code at #2437.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asg1612 picture asg1612  路  4Comments

decentral1se picture decentral1se  路  3Comments

brucellino picture brucellino  路  4Comments

Xiol picture Xiol  路  3Comments

surfer190 picture surfer190  路  3Comments