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 update_snapshot & _run_online_roles_bump #432

Merged
merged 5 commits into from
Jan 5, 2024

Conversation

MVrachev
Copy link
Member

@MVrachev MVrachev commented Dec 19, 2023

The goal of the "update_snapshot" refactoring is to:

  1. make a better separation between the two usages of "update_snapshot"
  • the first is to update snapshot and all roles that were given with the "targets_roles" argument
  • the second is to update snapshot and ALL bin target roles In the end, I wanted to be able to call "update_snapshot" with "bump_all" without having to pass the "targets_roles" argument.
  1. fix a bug where when calling "update_snapshot" the resulting new snapshot meta didn't contain updated information for targets.json This resulted in a bug that when calling "_run_online_roles_bump", which updated targets.json, we saved the new targets.json, but the new snapshot.json didn't reference it.

The second part of this refactoring is about "_run_online_roles_bump". Again there were two goals of this refactoring:

  1. make sure we call "update_snapshot" correctly. This means when we force an update of all target bins we shouldn't also pass the "targets_roles" list.
  2. make it clearer how we use the "force" argument:
  • when "force = True" we force a bump of all bins and targets.json
  • when "force = False" we bump only those bins and targets.json which have expired.

Finally, I did some small tweaks on our tests with the idea to improve our asserts and checks.

Besides unit tests, it was tested locally with a worker instance and triggered the automatic online roles bump.

Signed-off-by: Martin Vrachev [email protected]

@MVrachev MVrachev marked this pull request as ready for review December 19, 2023 12:26
@MVrachev MVrachev self-assigned this Dec 19, 2023
@MVrachev MVrachev requested a review from kairoaraujo December 19, 2023 13:14
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (08e5b40) 100.00% compared to head (bcd785a) 100.00%.

❗ Current head bcd785a differs from pull request most recent head 8aede98. Consider uploading reports for the commit 8aede98 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #432   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1001      1015   +14     
=========================================
+ Hits          1001      1015   +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MVrachev
Copy link
Member Author

I am planning to use the changes of this pr when I prepare the worker changes required for: repository-service-tuf/repository-service-tuf-api#399

@MVrachev
Copy link
Member Author

@kairoaraujo, the pr is ready for review.

MVrachev and others added 5 commits January 4, 2024 15:08
The goal of the "update_snapshot" refactoring is to:
1. make a better separation between the two usages of "update_snapshot"
- the first is to update snapshot and all roles that were given with the
"targets_roles" argument
- the second is to update snapshot and ALL bin target roles
In the end, I wanted to be able to call "update_snapshot" with
"bump_all" without having to pass the "targets_roles" argument.
2. fix a bug where when calling "update_snapshot" the resulting new
snapshot meta didn't contain updated information for targets.json
This resulted in a bug that when calling "_run_online_roles_bump", which
updated targets.json, we saved the new targets.json, but the new
snapshot.json didn't reference it.

The second part of this refactoring is about "_run_online_roles_bump".
Again there were two goals of this refactoring:
1. make sure we call "update_snapshot" correctly. This means when we
force an update of all target bins we shouldn't also pass the
"targets_roles" list.
2. make it clearer how we use the "force" argument:
- when "force = True" we force a bump of all bins and targets.json
- when "force = False" we bump only those bins and targets.json which
have expired.

Finally, I did some small tweaks on our tests with the idea to improve
them our asserts and checks.

Signed-off-by: Martin Vrachev <[email protected]>
In this specific "if" check we don't need to check the value of the
"force" argument as that case is already handled from a previous
check where if "force" is True we call update_snapshot with "bump_all".

Signed-off-by: Martin Vrachev <[email protected]>
Currently, if the check if snapshot expiration is below a certain
timedelta and "force" are True we wouldn't taken into account the
value of force.
With this fix, this is changed.

Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
We decided that it's best to not handle a StorageError exception
and instead allow the test to fail. Fast API will fail if there is an
exception from the worker and given that the StorageError exception
has enough details there is no need for us to handle it.

Additionally, this allowed us to remove the boolean return value
from _run_online_roles_bump and bump_snapshot.

Signed-off-by: Martin Vrachev <[email protected]>
@MVrachev
Copy link
Member Author

MVrachev commented Jan 4, 2024

This time for real @kairoaraujo, the pr is ready for review.

@kairoaraujo kairoaraujo merged commit 0463b08 into repository-service-tuf:main Jan 5, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants