Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition on the inventory cache file #10

Closed
jouir opened this issue Jun 17, 2022 · 1 comment
Closed

Race condition on the inventory cache file #10

jouir opened this issue Jun 17, 2022 · 1 comment

Comments

@jouir
Copy link
Contributor

jouir commented Jun 17, 2022

Hello,

Since the inventory cache feature, we have notice the following error:

Traceback (most recent call last):
  File "./extra/bastion/sshwrapper.py", line 96, in <module>
    main()
  File "./extra/bastion/sshwrapper.py", line 44, in main
    hostvar = get_hostvars(host)  # dict
  File "/tmp/bwrap_247825_so1sw9v8/awx_247825_ibg2laaa/project/extra/bastion/lib.py", line 113, in get_hostvars
    inventory = get_inventory()
  File "/tmp/bwrap_247825_so1sw9v8/awx_247825_ibg2laaa/project/extra/bastion/lib.py", line 45, in get_inventory
    cache_timeout=int(os.environ.get("BASTION_ANSIBLE_INV_CACHE_TIMEOUT", 60)),
  File "/tmp/bwrap_247825_so1sw9v8/awx_247825_ibg2laaa/project/extra/bastion/lib.py", line 88, in get_inventory_from_cache
    cache = json.load(fd)
  File "/usr/lib64/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 1614071 (char 1614070)

When multiple jobs are running at the same time, we suspect a race condition when writing and reading on the inventory cache file.

wilfriedroset pushed a commit to wilfriedroset/the-bastion-ansible-wrapper that referenced this issue Aug 30, 2022
Merge in SOC/bastion-ansible-wrapper from dev/julien.riou/inventory_cache to master

* commit '10dc34ce65654a09f736e34ef19b228f9e73b937':
  feat: Add Ansible inventory cache (ovh#7)
  feat: Use Python 3 interpreter (ovh#2) (ovh#8)
  fix: Detect hostvars with hostname (ovh#9)
@jouir
Copy link
Contributor Author

jouir commented Nov 24, 2022

Fixed by #13

@jouir jouir closed this as completed Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant