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

Add support for force online metadata update #435

Merged
merged 9 commits into from
Apr 18, 2024

Conversation

MVrachev
Copy link
Member

@MVrachev MVrachev commented Jan 5, 2024

Add support for force online metadata update

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

@MVrachev
Copy link
Member Author

MVrachev commented Jan 5, 2024

It's best to test this together with repository-service-tuf/repository-service-tuf-api#513

@MVrachev MVrachev self-assigned this Jan 5, 2024
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (714a29d) to head (0984391).
Report is 25 commits behind head on main.

❗ Current head 0984391 differs from pull request most recent head 5f42b8e. Consider uploading reports for the commit 5f42b8e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #435    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           15        15            
  Lines         1071      1173   +102     
==========================================
+ Hits          1071      1173   +102     

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

@MVrachev MVrachev requested a review from kairoaraujo January 10, 2024 11:07
@MVrachev
Copy link
Member Author

@kairoaraujo it's ready for a review.

@MVrachev
Copy link
Member Author

I invited @fsavoia and @ivanayov for a review.

Copy link
Member

@kairoaraujo kairoaraujo left a comment

Choose a reason for hiding this comment

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

The feature is nice. Thank you @MVrachev.
I'm adding one specific comment.

"message": "No online metadata roles given",
},
)

Copy link
Member

Choose a reason for hiding this comment

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

In the API, we allow users to submit offline roles without checking it (example: Root)

In the Worker, we also don't verify it. It will return a task SUCCESS with status True.
I suggest we verify if the role

Note: We can verify Root and Targets now. We have in the settings/redis a setting if the Targets is offline or online key -- for future feature that allows offline targets.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it and now we only allow online roles and specifically check if targets is an online role.

@MVrachev
Copy link
Member Author

Ready for another review.

@kairoaraujo
Copy link
Member

I'm reviewing it now

settings_repository = get_worker_settings()
settings_repository.reload()
if not settings_repository.get_fresh("TARGETS_ONLINE_KEY", True):
online_roles = [Snapshot.type, Timestamp.type, "bins"]

Choose a reason for hiding this comment

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

Shouldn't bins be excluded as well?
I might be missing some details from the workflow - if so, please ignore to not waste time with the comment.
Otherwise, given that bins are delegates and TARGETS_ONLINE_KEY is False, it looks incorrect to have them in the online roles.

Copy link
Member Author

Choose a reason for hiding this comment

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

Bins could use the online key.
Even though targets could be offline in the future this doesn't mean we are required to use offline keys for all its delegations. The security properties coming from targets utilizing an offline key wouldn't be lost as when adding, removing or downloading artifact information all requires going through targets first which will be cryptographically signed by an offline key.

bootstrap = self._settings.get_fresh("BOOTSTRAP")
if bootstrap is None or "pre-" in bootstrap or "signing-" in bootstrap:
logging.info(
"[automatic_version_bump] Bootstrap not completed, skipping..."
Copy link

@ivanayov ivanayov Jan 25, 2024

Choose a reason for hiding this comment

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

"No bootstrap or not completed, skipping..."?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think Bootstrap not completed could be interpreted by both:

  • not started at all
  • not signed with threshold of keys

It's good that the user have GET /api/v1/bootstrap to understand that bootstrap is in the process of signing: https://github.com/repository-service-tuf/repository-service-tuf-api/blob/277d73b1610a5ec96c4af4d3ccbc8bdbfc69bcf9/repository_service_tuf_api/bootstrap.py#L128
and GET /api/v1/metadata to get the exact content of this bootstrap.

In conclusion, I don't we need to change the message to a longer now.

Copy link
Member

@kairoaraujo kairoaraujo left a comment

Choose a reason for hiding this comment

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

Is it better to merge custom delegated roles and rebase them?

Fail early when bootstrap is not completed instead of relly on
_run_online_roles_bump to catch this.

Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
We handle this case in the API, so there is no need to handle when
payload is empty for force_online_metadata_update().

Signed-off-by: Martin Vrachev <[email protected]>
Make sure the name it's clear it's only used for custom target
delegation.

Signed-off-by: Martin Vrachev <[email protected]>
Use the same method to call update_snapshot() with hash bin delegation
as we do with custom target delegation.

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

@kairoaraujo ready to test together with repository-service-tuf/repository-service-tuf-api#513
Support for pushing a new version of custom target delegation is there.

@@ -1208,6 +1221,116 @@ def bump_online_roles(self, force: Optional[bool] = False) -> bool:

return True

def _run_force_online_metadata_update(self, roles: List[str]) -> List[str]:
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if the metadata_update is the best name here, as it confuses our process of updating the metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well it is actually metadata update...
Hard to get a name correctly...

@kairoaraujo kairoaraujo merged commit b486903 into repository-service-tuf:main Apr 18, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants