diff --git a/service/src/main/java/org/jboss/sbomer/service/feature/sbom/features/generator/AbstractController.java b/service/src/main/java/org/jboss/sbomer/service/feature/sbom/features/generator/AbstractController.java index 22d1769fb..900473bb1 100644 --- a/service/src/main/java/org/jboss/sbomer/service/feature/sbom/features/generator/AbstractController.java +++ b/service/src/main/java/org/jboss/sbomer/service/feature/sbom/features/generator/AbstractController.java @@ -34,6 +34,7 @@ import java.util.stream.Stream; import org.cyclonedx.model.Bom; +import org.jboss.sbomer.core.errors.ApplicationException; import org.jboss.sbomer.core.features.sbom.enums.GenerationResult; import org.jboss.sbomer.core.features.sbom.utils.MDCUtils; import org.jboss.sbomer.core.features.sbom.utils.SbomUtils; @@ -354,26 +355,38 @@ protected UpdateControl reconcileFinished( log.debug("Reconcile FINISHED for '{}'...", generationRequest.getName()); // Store files in S3 - CompletableFuture.runAsync(() -> s3LogHandler.storeFiles(generationRequest)); + CompletableFuture storeLogs = CompletableFuture.runAsync(() -> s3LogHandler.storeFiles(generationRequest)) + .exceptionally((e) -> { + // This is not fatal + log.warn("Storing files in S3 failed", e); + return null; + }); List sboms = sbomRepository.findSbomsByGenerationRequest(generationRequest.getId()); - CompletableFuture.runAsync(() -> { + CompletableFuture publishToUmb = CompletableFuture.runAsync(() -> { try { notificationService.notifyCompleted(sboms); } catch (FeatureDisabledException e) { log.warn(e.getMessage(), e); } + }).exceptionally((e) -> { + throw new ApplicationException("UMB notification failed", e); }); - CompletableFuture.runAsync(() -> { + CompletableFuture uploadToAtlas = CompletableFuture.runAsync(() -> { try { atlasHandler.upload(sboms); } catch (FeatureDisabledException e) { log.warn(e.getMessage(), e); } + }).exceptionally((e) -> { + throw new ApplicationException("Uploading manifests to Atlas failed", e); }); + // Wait for all tasks to be done + CompletableFuture.allOf(storeLogs, publishToUmb, uploadToAtlas).join(); + // At this point al the work is finished and we can clean up the GenerationRequest Kubernetes resource. cleanupFinishedGenerationRequest(generationRequest);