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

Catch exception of historical folo record and exit #83

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface TrackingService
{
@GET
@Path( "/{id}/artifactRecord/{path: (.*)}" )
Response recordArtificat( final @PathParam( "id" ) String id, final @PathParam( "path" ) String path,
Response recordArtifact( final @PathParam( "id" ) String id, final @PathParam( "path" ) String path,
final @QueryParam( "packageType" ) String packageType,
final @QueryParam( "type" ) String type, final @QueryParam( "name" ) String name,
final @QueryParam( "originalUrl" ) String originalUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.commonjava.util.sidecar.services;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.Startup;
import io.quarkus.vertx.ConsumeEvent;
import io.vertx.core.json.JsonObject;
Expand Down Expand Up @@ -101,6 +102,7 @@ private void loadReport( String path )

@ConsumeEvent( value = FOLO_BUILD )
public void storeTrackedDownload( JsonObject message )
throws Exception
{
String trackingPath = message.getString( TRACKING_PATH );
String trackingId = message.getString( TRACKING_ID );
Expand All @@ -119,12 +121,31 @@ public void storeTrackedDownload( JsonObject message )
return;
}
String originalUrl = entryDTO.getOriginUrl() == null ? "" : entryDTO.getOriginUrl();
Response response = trackingService.recordArtificat( trackingId, trackingPath, storeKey.getPackageType(),
storeKey.getType().name(), storeKey.getName(), originalUrl,
entryDTO.getSize(), entryDTO.getMd5(), entryDTO.getSha1(),
entryDTO.getSha256() );
logger.debug( "Finished consuming folo record seal event for path:{}, trackingId:{}, rep code: {}, body: {}",
trackingPath, trackingId, response.getStatus(), response.getStatusInfo().getReasonPhrase() );
boolean exception = false;
try
{
Response response = trackingService.recordArtifact( trackingId, trackingPath, storeKey.getPackageType(),
storeKey.getType().name(), storeKey.getName(),
originalUrl, entryDTO.getSize(), entryDTO.getMd5(),
entryDTO.getSha1(), entryDTO.getSha256() );
logger.debug(
"Finished consuming folo record seal event for path:{}, trackingId:{}, rep code: {}, body: {}",
trackingPath, trackingId, response.getStatus(), response.getStatusInfo().getReasonPhrase() );
}
catch ( Exception e )
{
exception = true;
throw new Exception( "Sidecar failed to record folo for historical entry, will stop.", e );
}
finally
{
if ( exception )
{
// exit with default code -1
Quarkus.asyncExit();
}
}

}

}
Loading