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

fix: Catch JCloud exceptions again [DHIS2-18212] #18802

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -51,7 +51,9 @@
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.filesystem.reference.FilesystemConstants;
import org.jclouds.http.HttpResponseException;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.s3.reference.S3Constants;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -149,13 +151,32 @@ private Properties configureOverrides(String provider, String endpoint) {
@PostConstruct
public void init() {
Location location = createLocation(fileStoreConfig.provider, fileStoreConfig.location);
blobStoreContext.getBlobStore().createContainerInLocation(location, fileStoreConfig.container);

log.info(
"File store configured with provider: '{}', container: '{}' and location: '{}'.",
fileStoreConfig.provider,
fileStoreConfig.container,
fileStoreConfig.location);
try {
Copy link
Contributor

@david-mackessy david-mackessy Oct 11, 2024

Choose a reason for hiding this comment

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

I think a comment should be added above the try/catch explaining the crucial part it plays for AWS usage (maybe even providing a link to this issue).
Without it, something similar could happen in the future.
We have tests for filesystem & MinIO usage but none for AWS, so a detrimental change to the AWS flow is not easily evident.

blobStoreContext
.getBlobStore()
.createContainerInLocation(location, fileStoreConfig.container);

log.info(
"File store configured with provider: '{}', container: '{}' and location: '{}'.",
fileStoreConfig.provider,
fileStoreConfig.container,
fileStoreConfig.location);
} catch (HttpResponseException ex) {
log.error(
String.format(
"Could not configure file store with provider '%s' and container '%s'.\n"
+ "File storage will not be available.",
fileStoreConfig.provider, fileStoreConfig.container),
ex);
} catch (AuthorizationException ex) {
log.error(
String.format(
"Could not authenticate with file store provider '%s' and container '%s'. "
+ "File storage will not be available.",
fileStoreConfig.provider, fileStoreConfig.location),
ex);
}
}

@PreDestroy
Expand Down
Loading