aboutsummaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-01-18 11:14:19 +0000
committerMichael Morris <michael.morris@est.tech>2022-01-20 14:19:30 +0000
commit1c1cdcec2863be20400ca43b3c63f8b8c0a85ee2 (patch)
tree07f56ff1ba05ff37570000fb7deb48e51b6ac31b /common-be/src
parent93f24e4b3ffc331befc5bcdcffd361d77f5ecadd (diff)
Improve error logging in MinIo client
Change-Id: I50b558be2825f59672ffae85518f351ae7a38c84 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3849
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java26
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageCsarSizeReducer.java16
2 files changed, 32 insertions, 10 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java
index 850b4e1dda..54a71d9b2a 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageArtifactStorageManager.java
@@ -74,6 +74,8 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
.build()
);
} catch (final Exception e) {
+ LOGGER.error("Failed to retrieve uploaded artifact with bucket '{}' and name '{}' while persisting", minioObjectTemp.getBucket(),
+ minioObjectTemp.getObjectName(), e);
throw new ArtifactStorageException(
String.format("Failed to retrieve uploaded artifact with bucket '%s' and name '%s' while persisting",
minioObjectTemp.getBucket(), minioObjectTemp.getObjectName()), e);
@@ -84,6 +86,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
moveFile(minioObjectTemp, vspId, versionId);
} catch (final Exception e) {
rollback(minioObjectTemp, vspId, versionId);
+ LOGGER.error("Could not persist artifact for bucket '{}', object '{}'", vspId, versionId, e);
final var errorMsg = String.format("Could not persist artifact for VSP '%s', version '%s'", vspId, versionId);
throw new ArtifactStorageException(errorMsg, e);
}
@@ -111,6 +114,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
put(vspId, name, fileToUpload);
} catch (final Exception e) {
+ LOGGER.error("Failed to upload artifact - bucket: '{}', object: '{}'", vspId, name, e);
throw new ArtifactStorageException("Failed to upload artifact", e);
}
@@ -128,6 +132,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
.build()
);
} catch (final Exception e) {
+ LOGGER.error("Failed to put - bucket: '{}', object: '{}'", vspId, name, e);
throw new ArtifactStorageException("Failed to upload artifact", e);
}
}
@@ -143,6 +148,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
try {
return get(minioObject.getBucket(), minioObject.getObjectName());
} catch (final Exception e) {
+ LOGGER.error("Failed to get - bucket: '{}', object: '{}'", minioObject.getBucket(), minioObject.getObjectName(), e);
throw new ArtifactStorageException("Failed to get Object", e);
}
}
@@ -155,6 +161,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
.object(objectID)
.build());
} catch (final Exception e) {
+ LOGGER.error("Failed to get - bucket: '{}', object: '{}'", bucketID, objectID, e);
throw new ArtifactStorageException("Failed to get Object", e);
}
}
@@ -169,6 +176,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
.bypassGovernanceMode(true)
.build());
} catch (final Exception e) {
+ LOGGER.error("Failed to delete - bucket: '{}', object: '{}'", minioObject.getBucket(), minioObject.getObjectName(), e);
throw new ArtifactStorageException(String.format("Failed to delete '%s'", minioObject.getObjectName()), e);
}
@@ -180,6 +188,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
try {
copy(vspId, tempName, versionId);
} catch (final Exception e) {
+ LOGGER.error("Failed to copy - bucket: '{}', object: '{}'", vspId, versionId, e);
return Optional.empty();
}
@@ -205,6 +214,7 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
try {
copy(vspId, versionId, minioObject.getObjectName());
} catch (final Exception e) {
+ LOGGER.error("Failed to copy - bucket: '{}', object: '{}'", vspId, versionId, e);
throw new ArtifactStorageException("Failed to move", e);
}
delete(minioObject);
@@ -228,19 +238,23 @@ public class MinIoStorageArtifactStorageManager implements ArtifactStorageManage
final Map<String, Object> endpoint = commonConfigurationManager.getConfigValue(EXTERNAL_CSAR_STORE, "endpoint", null);
final Map<String, Object> credentials = commonConfigurationManager.getConfigValue(EXTERNAL_CSAR_STORE, "credentials", null);
final String tempPath = commonConfigurationManager.getConfigValue(EXTERNAL_CSAR_STORE, "tempPath", null);
- LOGGER.info("ArtifactConfig.endpoint: '{}'", endpoint);
- LOGGER.info("ArtifactConfig.credentials: '{}'", credentials);
- LOGGER.info("ArtifactConfig.tempPath: '{}'", tempPath);
if (endpoint == null) {
- throw new RuntimeException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("endpoint"));
+ LOGGER.error(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("endpoint"));
+ throw new ArtifactStorageException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("endpoint"));
}
if (credentials == null) {
- throw new RuntimeException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("credentials"));
+ LOGGER.error(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("credentials"));
+ throw new ArtifactStorageException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("credentials"));
}
if (tempPath == null) {
- throw new RuntimeException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("tempPath"));
+ LOGGER.error(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("tempPath"));
+ throw new ArtifactStorageException(EXTERNAL_CSAR_STORE_CONFIGURATION_FAILURE_MISSING.formatMessage("tempPath"));
}
+ LOGGER.info("ArtifactConfig.endpoint: '{}'", endpoint);
+ LOGGER.info("ArtifactConfig.credentials: '{}'", credentials);
+ LOGGER.info("ArtifactConfig.tempPath: '{}'", tempPath);
+
final String host = (String) endpoint.getOrDefault("host", null);
final int port = (int) endpoint.getOrDefault("port", 0);
final boolean secure = (boolean) endpoint.getOrDefault("secure", false);
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageCsarSizeReducer.java b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageCsarSizeReducer.java
index 3181b088c0..98c54988a0 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageCsarSizeReducer.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/csar/storage/MinIoStorageCsarSizeReducer.java
@@ -76,6 +76,7 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
zf.entries().asIterator().forEachRemaining(zipProcessingFunction.getProcessZipConsumer(csarPackagePath, zf, zos));
} catch (final IOException ex1) {
rollback(reducedCsarPath);
+ LOGGER.error("Could not read ZIP stream '{}'", csarPackagePath.toString(), ex1);
final var errorMsg = String.format(UNEXPECTED_PROBLEM_HAPPENED_WHILE_READING_THE_CSAR, csarPackagePath);
throw new CsarSizeReducerException(errorMsg, ex1);
}
@@ -87,12 +88,14 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
reducedCsarBytes = Files.readAllBytes(csarPackagePath);
}
} catch (final IOException e) {
+ LOGGER.error("Could not read bytes of file '{}'", csarPackagePath, e);
final var errorMsg = String.format("Could not read bytes of file '%s'", csarPackagePath);
throw new CsarSizeReducerException(errorMsg, e);
}
try {
Files.delete(reducedCsarPath);
} catch (final IOException e) {
+ LOGGER.error("Could not delete temporary file '{}'", reducedCsarPath, e);
final var errorMsg = String.format("Could not delete temporary file '%s'", reducedCsarPath);
throw new CsarSizeReducerException(errorMsg, e);
}
@@ -107,7 +110,8 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
final var entryName = zipEntry.getName();
try {
if (totalEntryArchive.getAndIncrement() > thresholdEntries) {
- // too much entries in this archive, can lead to inodes exhaustion of the system
+ LOGGER.warn("too many entries in this archive, can lead to inodes exhaustion of the system");
+ // too many entries in this archive, can lead to inodes exhaustion of the system
final var errorMsg = String.format("Failed to extract '%s' from zip '%s'", entryName, csarPackagePath);
throw new CsarSizeReducerException(errorMsg);
}
@@ -124,6 +128,7 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
}
zos.closeEntry();
} catch (final IOException ei) {
+ LOGGER.error("Failed to extract '{}' from zip '{}'", entryName, csarPackagePath, ei);
final var errorMsg = String.format("Failed to extract '%s' from zip '%s'", entryName, csarPackagePath);
throw new CsarSizeReducerException(errorMsg, ei);
}
@@ -136,7 +141,8 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
return zipEntry -> {
final var entryName = zipEntry.getName();
if (totalEntryArchive.getAndIncrement() > thresholdEntries) {
- // too much entries in this archive, can lead to inodes exhaustion of the system
+ LOGGER.warn("too many entries in this archive, can lead to inodes exhaustion of the system");
+ // too many entries in this archive, can lead to inodes exhaustion of the system
final var errorMsg = String.format("Failed to extract '%s' from zip '%s'", entryName, csarPackagePath);
throw new CsarSizeReducerException(errorMsg);
}
@@ -153,6 +159,7 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
}
zos.closeEntry();
} catch (final IOException ei) {
+ LOGGER.error("Failed to extract '{}' from zip '{}'", entryName, csarPackagePath, ei);
final var errorMsg = String.format("Failed to extract '%s' from zip '%s'", entryName, csarPackagePath);
throw new CsarSizeReducerException(errorMsg, ei);
}
@@ -163,8 +170,8 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
if (Files.exists(reducedCsarPath)) {
try {
Files.delete(reducedCsarPath);
- } catch (final Exception ex2) {
- LOGGER.warn("Could not delete temporary file '{}'", reducedCsarPath, ex2);
+ } catch (final Exception e) {
+ LOGGER.warn("Could not delete temporary file '{}'", reducedCsarPath, e);
}
}
}
@@ -183,6 +190,7 @@ public class MinIoStorageCsarSizeReducer implements PackageSizeReducer {
.map(ZipEntry::getName).map(Path::of)
.collect(Collectors.toList());
} catch (final IOException e) {
+ LOGGER.error("Failed to read ZipFile '{}'", csarPackagePath.toString(), e);
final var errorMsg = String.format(UNEXPECTED_PROBLEM_HAPPENED_WHILE_READING_THE_CSAR, csarPackagePath);
throw new CsarSizeReducerException(errorMsg, e);
}