-
Notifications
You must be signed in to change notification settings - Fork 4
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 corrupted archive with checksum validation, synchronized lock and API enhancement #51
Changes from 1 commit
1ffe209
fb9068e
6c61b70
452b14d
47f9868
dac7f70
c6a9cd9
5ce8feb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…dling
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
|
||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; | ||
import static jakarta.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM; | ||
import static jakarta.ws.rs.core.Response.Status.CONFLICT; | ||
import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; | ||
import static jakarta.ws.rs.core.Response.accepted; | ||
import static jakarta.ws.rs.core.Response.noContent; | ||
|
@@ -74,6 +75,7 @@ public class ArchiveManageResources | |
|
||
@Operation( description = "Generate archive based on tracked content" ) | ||
@APIResponse( responseCode = "202", description = "The archive created request is accepted" ) | ||
@APIResponse( responseCode = "409", description = "The archive created request is conflicted" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if 409 is good response to PNC as this may fail the request. We should let them know if we agree to use this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't add @michalovjan to review, could you help to confirm on this? Also comment on JIRA https://issues.redhat.com/browse/MMENG-4256. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @yma96, I'd rather have just 202 Accepted if that's okay. But if you're keen on having 409, we'd need to add that to repository-driver so that we don't unnecessarily retry requests. It's doable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michalovjan make sense, I'll change to 202 accepted to avoid more code change from PNC. |
||
@RequestBody( description = "The tracked content definition JSON", name = "body", required = true, | ||
content = @Content( mediaType = APPLICATION_JSON, | ||
example = "{" + "\"buildConfigId\": \"XXX\"," + "\"downloads\":" + "[{" | ||
|
@@ -104,11 +106,17 @@ public Uni<Response> create( final @Context UriInfo uriInfo, final InputStream b | |
return fromResponse( message ); | ||
} | ||
|
||
controller.generate( content ); | ||
boolean accepted = controller.generate( content ); | ||
return Uni.createFrom() | ||
.item( accepted().type( MediaType.TEXT_PLAIN ) | ||
.entity( "Archive created request is accepted." ) | ||
.build() ); | ||
.item( accepted ? | ||
accepted().type( MediaType.TEXT_PLAIN ) | ||
.entity( "Archive created request is accepted." ) | ||
.build() : | ||
Response.status( CONFLICT ) | ||
.type( MediaType.TEXT_PLAIN ) | ||
.entity( | ||
"Another generation with same build config ID was already in progress, request is conflicted." ) | ||
.build() ); | ||
} | ||
|
||
@Operation( description = "Get the status of generating archive based on build config Id" ) | ||
|
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.
can we just throw warning to user that there is already process in progress, please try later ? sorry if I miss some requirements. ; -)
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.
@sswguo You mean don't let the coming process wait, just warn to user and return? Not sure whether PNC care the response of archive generation since this should be at the end of build, if that's the point I will comment to confirm.
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.
We can confirm that which case will send two same archive requests in a short time.
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.
@sswguo probably large build with large archive file, since PNC UI doesn't allow concurrent builds with the same config ID, the previous build might be already done but generation with download was still in progress, then another build was in progress and used the same workspace to process download or generation, so we need to know if they want to handle the generation response themselves or just let archive go with the right thing, comment on JIRA and discuss on meeting.