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

Update caching mechanism to allow for concurrent genpolicy runs #113

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

SethHollandsworth
Copy link
Collaborator

This is not a requirement of the tool itself but of the katapolicygen python wrapper used in confcom for writing tests that run in parallel. Previously the layers_cache folder would be concurrently written to and deleted depending on the settings of the tests, resulting in errors.

This PR proposes using temp folders instead of layers_cache and keeping the layer hashes in a central policy.json file that doesn't get deleted after running the tool instead of the .verity files nested in layers_cache. Because of the use of temporary folders, the cleanup process is a little nicer too.

Let me know if anything should be changed, thanks!

@danmihai1
Copy link

Thanks @SethHollandsworth! This change seems very promising at a quick look, but please rebase on the latest branch before we review it more thoroughly.

@SethHollandsworth
Copy link
Collaborator Author

rebased and ready to review, thanks!

@danmihai1
Copy link

Thanks again for the help, Seth! I think we should try to detect if another app/instance is using the cache, and switch to non-cached mode if that's the case. Otherwise we are still racing while modifying the cache from two or more instances.

Copy link

@danmihai1 danmihai1 left a comment

Choose a reason for hiding this comment

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

comment

Copy link

@danmihai1 danmihai1 left a comment

Choose a reason for hiding this comment

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

Please see my comment above.

@SethHollandsworth SethHollandsworth force-pushed the feature/update_caching branch 2 times, most recently from 8009d31 to c698e5a Compare December 1, 2023 20:33
@SethHollandsworth
Copy link
Collaborator Author

This should be merged after #117 . I will rebase and ensure building on Windows works at that point. Thanks for being flexible!

@SethHollandsworth SethHollandsworth force-pushed the feature/update_caching branch 2 times, most recently from 6fdd439 to b97fd54 Compare December 6, 2023 15:20
src/tools/genpolicy/src/registry.rs Outdated Show resolved Hide resolved
src/tools/genpolicy/src/registry.rs Show resolved Hide resolved
src/tools/genpolicy/src/registry.rs Outdated Show resolved Hide resolved
src/tools/genpolicy/src/registry.rs Outdated Show resolved Hide resolved
src/tools/genpolicy/src/registry.rs Outdated Show resolved Hide resolved
Previously the tool would use the layers_cache folder for all instances
and hence delete the cache when it was done, interfereing with other instances.
This change makes it so that each instance of the tool will have its own temp folder to use.

Co-authored-by: Khalil Sayid <[email protected]>
Signed-off-by: Seth Hollandsworth <[email protected]>
Copy link

@danmihai1 danmihai1 left a comment

Choose a reason for hiding this comment

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

Pending test results.

@danmihai1 danmihai1 merged commit 77b5c22 into cc-msft-prototypes Dec 15, 2023
7 of 17 checks passed
@SethHollandsworth SethHollandsworth deleted the feature/update_caching branch December 15, 2023 14:25
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

Successfully merging this pull request may close these issues.

3 participants