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

fix(forknet): Fix the state parts bucket cleanup logic #12712

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VanBarbascu
Copy link
Contributor

Allow reset command to run without --gcs... parameter.

mirror reset --backup-id start --yes        
Traceback (most recent call last):                                                                                                                                                                                  
  File "/Users/razvan/repos/nearcore/pytest/tests/mocknet/mirror.py", line 772, in <module>                                                                                                                         
    args.func(args, traffic_generator, wanted_nodes)                                                      
  File "/Users/razvan/repos/nearcore/pytest/tests/mocknet/mirror.py", line 381, in reset_cmd
    _clear_state_parts_if_exists(_get_state_parts_location(args), nodes)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                          
  File "/Users/razvan/repos/nearcore/pytest/tests/mocknet/mirror.py", line 280, in _get_state_parts_location
    if args.gcs_state_sync:                                                                               
       ^^^^^^^^^^^^^^^^^^^                       
AttributeError: 'Namespace' object has no attribute 'gcs_state_sync'

@VanBarbascu VanBarbascu requested a review from a team as a code owner January 10, 2025 13:16
@VanBarbascu VanBarbascu requested review from saketh-are, Trisfald, marcelo-gonzalez and Longarithm and removed request for saketh-are January 10, 2025 13:16
logger.info('State dumper node found, cleaning up state parts.')
state_dumper_node.run_cmd(f'gsutil -m rm -r gs://{bucket_name}/chain_id=\*',
state_dumper_node.run_cmd(f'gsutil -m rm -r gs://{bucket_name}/chain_id=*',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Python complains about the \* as it tries to parse it as an escape sequence. It should be safe to pass it here without escaping it.

@@ -253,13 +258,8 @@ def _clear_state_parts_if_exists(location, nodes):
# bucket where it dumped the parts.
bucket_name = location['GCS']['bucket']

state_dumper_node = next(filter(lambda n: n.want_state_dump, nodes), None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you move this block to line 247?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this function _clear_state_parts_if_exists, we want to check if the state parts exist and then clear them.

Previously, we assumed that if we are in a localtest, we always dump the parts, but is not the case.
With this change, we will make it clear to the mirror.py user if the parts were deleted or not.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.63%. Comparing base (f9e403b) to head (01789f1).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12712      +/-   ##
==========================================
- Coverage   70.64%   70.63%   -0.01%     
==========================================
  Files         848      848              
  Lines      173732   173730       -2     
  Branches   173732   173730       -2     
==========================================
- Hits       122725   122713      -12     
- Misses      45875    45883       +8     
- Partials     5132     5134       +2     
Flag Coverage Δ
backward-compatibility 0.16% <ø> (ø)
db-migration 0.16% <ø> (ø)
genesis-check 1.36% <ø> (+<0.01%) ⬆️
linux 69.23% <ø> (+0.01%) ⬆️
linux-nightly 70.23% <ø> (+<0.01%) ⬆️
pytests 1.66% <ø> (+<0.01%) ⬆️
sanity-checks 1.47% <ø> (+<0.01%) ⬆️
unittests 70.46% <ø> (-0.01%) ⬇️
upgradability 0.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@Trisfald Trisfald left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants