-
Notifications
You must be signed in to change notification settings - Fork 23
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 PUT /api/v1/metadata/online
#513
Add support for PUT /api/v1/metadata/online
#513
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #513 +/- ##
==========================================
+ Coverage 98.97% 99.09% +0.11%
==========================================
Files 14 14
Lines 588 666 +78
==========================================
+ Hits 582 660 +78
Misses 6 6 ☔ View full report in Codecov by Sentry. |
It's best to test this together with #513 |
0127ee8
to
74c8ddd
Compare
Before merging this pr, lets merge: #514. |
@kairoaraujo it's ready for a review. |
@@ -31,6 +31,25 @@ def post(payload: metadata.MetadataPostPayload): | |||
return metadata.post_metadata(payload) | |||
|
|||
|
|||
@router.put( | |||
"/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be a specific endpoint "/api/v1/metadata/"
Also, I would use the following behavior.
No rolename = bump all online roles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what I mean is to use a more specific endpoint /api/v1/metadata/<choose a name>
I see the /api/v1/metadata
for more generic actions like Update Metadata.
As this description says, "Force a new version of online metadata role(s)." it should have a more specific endpoint
i.e.: /api/v1/metadata/online
. Following our past changes, it is an asynchronous task that could be a POST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a discussion we agreed it will be POST /api/v1/metadata/online/
c89d9f9
to
9d226cb
Compare
@kairoaraujo I did as you suggested if payload is empty I made sure force update on all roles. It's ready for review. |
docs/swagger.json
Outdated
"Metadata" | ||
], | ||
"summary": "Force a new version of online metadata role(s).", | ||
"description": "Force a new version of online metadata role(s). If the roles list is empty all roles will be updated. The new metadata version(s) will have extended expiration which will equal to: today + ROLE_NAME_EXPIRATION number of days, where ROLE_NAME_EXPIRATION is a tuf repository setting. Note: depending on which metadata role you want to update other online roles will likely be updated as well otherwise consistency will be lost.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if datetime.now() + <ROLE_NAME_EXPIRATION number of days>
is less than the current expiration? I think we should either make it impossible or define it more strictly here (like extended or redused - practically it can also be the same, so we can just say "updated").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that this description creates expectations that don't strictly match the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole idea is to be able to redefine current expiration.
For context: the idea of this feature came to life after I implemented PUT /api/v1/config
.
With that API endpoint, you can change the expiration policy for each role.
Still, this policy will be enforced when an online role expires and the automatic job to bump that role is executed.
See: https://github.com/repository-service-tuf/repository-service-tuf-worker/blob/486e98cdbc16dd41c62c0ec8b473e2f94312ee9c/app.py#L139
The idea behind this new endpoint is that after you have called PUT /api/v1/config
you can call this new endpoint PUT /api/v1/metadata
and request a new metadata version of part or all online metadata roles.
For the future I have thought about adding a flag force_new_version
to the PUT /api/v1/config
endpoint which will do the same thing as this new endpoint but for all roles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested by Ivana I added a commit that makes sure we cannot push negative expiration days.
Here is the commit: 8a00f5b
description=( | ||
"Force a new version of online metadata role(s). If the roles list is " | ||
"empty all roles will be updated. The new metadata version(s) will " | ||
"have extended expiration which will equal to: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about "extended" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check my comment to your questions above.
8a00f5b
to
865d89c
Compare
I had to remove my latest changes where I added more requirements to our attributes as there was an issue. |
62cd823
to
4fc3dcc
Compare
PUT /api/v1/metadata
PUT /api/v1/metadata/online
@kairoaraujo I updated the pr by:
I suggest first merging custom target delegation prs and rebasing those on top of them. |
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
Signed-off-by: Martin Vrachev <[email protected]>
4fc3dcc
to
8677271
Compare
Signed-off-by: Martin Vrachev <[email protected]>
61e05da
to
4d1261c
Compare
@kairoaraujo ready to test together with repository-service-tuf/repository-service-tuf-worker#435. The only remaining question that comes to my mind is whether we should keep the API call to |
Description
Add support for
PUT /api/v1/metadata
which will force a new metadata versionof a given set of online roles.
Fixes #399
Types of changes
Additional requirements
Code of Conduct
By submitting this PR, you agree to follow our Code of Conduct.