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

Refactor(plugins): Improve thread safety for avdschema #3109

Conversation

ClausHolbechArista
Copy link
Contributor

@ClausHolbechArista ClausHolbechArista commented Aug 25, 2023

Change Summary

Improve thread safety for avdschema

Related Issue(s)

When running schema validation in multiple threads at the same time (only seen with pyavd), the schema tooling fails with errors like:

...
  File "/home/holbech/.local/lib/python3.10/site-packages/pyavd/validate_inputs.py", line 44, in validate_inputs
    return eos_designs_schema_tools.validate_data(inputs)
  File "/home/holbech/.local/lib/python3.10/site-packages/pyavd/avd_schema_tools.py", line 78, in validate_data
    raise exception
pyavd.vendor.errors.errors.AvdSchemaError: dictionary changed size during iteration

This happens because the original schema object was updated with resolved dynamic keys as well as schema references during the validation.

Proposed changes

By preserving the original schema and instead work on local copies the validation becomes more thread safe (more issues may exist).

How to test

Tested with nornir and running validation for all devices across multiple threads at the same time.

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@ClausHolbechArista ClausHolbechArista marked this pull request as ready for review August 25, 2023 11:25
Copy link
Contributor

@Shivani-chourasiya Shivani-chourasiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ClausHolbechArista ClausHolbechArista merged commit d637120 into aristanetworks:devel Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants