From 2e866113e09ade078010ac98df264c478e9382d0 Mon Sep 17 00:00:00 2001 From: Umberto D'Ovidio Date: Wed, 12 Oct 2022 10:11:29 +0200 Subject: [PATCH 1/3] add test for invalid plugin config file --- .../com/gentics/mesh/plugin/PluginConfigTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/tests-core/src/main/java/com/gentics/mesh/plugin/PluginConfigTest.java b/tests/tests-core/src/main/java/com/gentics/mesh/plugin/PluginConfigTest.java index 250efbece6..d3e2eec7c9 100644 --- a/tests/tests-core/src/main/java/com/gentics/mesh/plugin/PluginConfigTest.java +++ b/tests/tests-core/src/main/java/com/gentics/mesh/plugin/PluginConfigTest.java @@ -6,8 +6,10 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.junit.Before; @@ -52,6 +54,16 @@ public void testWriteConfig() throws Exception { assertEquals(PLUGIN_DIR + "/dummy/storage", plugin.getStorageDir().getPath()); } + @Test(expected = Exception.class) + public void testReadInvalidYamlFile() throws Exception { + DummyPlugin plugin = mockPlugin(); + File file = plugin.getConfigFile(); + FileUtils.writeStringToFile(file, "foo bar", StandardCharsets.UTF_8); + + // this should fail since the yaml format is invalid + plugin.readConfig(DummyPluginConfig.class); + } + @Test public void testReadConfigOverride() throws FileNotFoundException, IOException { DummyPlugin plugin = mockPlugin(); From 5d1d02c65eb6a315fe79e640bb88b9bd9848b4f5 Mon Sep 17 00:00:00 2001 From: Umberto D'Ovidio Date: Fri, 14 Oct 2022 11:20:07 +0200 Subject: [PATCH 2/3] send 503 for requests executed during a backup --- .../resources/i18n/translations_de.properties | 1 + .../resources/i18n/translations_en.properties | 1 + .../gentics/mesh/core/db/CommonDatabase.java | 3 +++ .../rest/error/AbstractRestException.java | 2 +- .../rest/error/BackupInProgressException.java | 20 +++++++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java diff --git a/common/src/main/resources/i18n/translations_de.properties b/common/src/main/resources/i18n/translations_de.properties index c2cfe9d93a..ae259cc0ee 100644 --- a/common/src/main/resources/i18n/translations_de.properties +++ b/common/src/main/resources/i18n/translations_de.properties @@ -244,6 +244,7 @@ import_failed=Import fehlgeschlagen. backup_finished=Backup abgeschlossen. backup_failed=Backup fehlgeschlagen. +backup_in_progress=Zugriff auf Datenbank nicht möglich, Backup läuft. backup_consistency_check_failed=Backup fehlgeschlagen. Der Konsistenzcheck hat {0} Inkonsistenzen gefunden. backup_error_not_supported_in_memory_mode=Backup Operationen können nicht durchgeführt werden wenn der in-memory modus verwendet wird. diff --git a/common/src/main/resources/i18n/translations_en.properties b/common/src/main/resources/i18n/translations_en.properties index 4b8d60f7ed..189a565921 100644 --- a/common/src/main/resources/i18n/translations_en.properties +++ b/common/src/main/resources/i18n/translations_en.properties @@ -243,6 +243,7 @@ import_failed=Import failed. backup_finished=Backup completed. backup_failed=Backup failed. +backup_in_progress=Cannot access database, backup is in progress. backup_consistency_check_failed=Backup failed. Consistency check found {0} inconsistencies. backup_error_not_supported_in_memory_mode=Backup operation can not be run in memory mode. diff --git a/mdm/common/src/main/java/com/gentics/mesh/core/db/CommonDatabase.java b/mdm/common/src/main/java/com/gentics/mesh/core/db/CommonDatabase.java index 6884f743f2..bf77d66331 100644 --- a/mdm/common/src/main/java/com/gentics/mesh/core/db/CommonDatabase.java +++ b/mdm/common/src/main/java/com/gentics/mesh/core/db/CommonDatabase.java @@ -7,6 +7,7 @@ import com.gentics.mesh.Mesh; import com.gentics.mesh.MeshStatus; +import com.gentics.mesh.core.rest.error.BackupInProgressException; import com.gentics.mesh.metric.MetricsService; import io.micrometer.core.instrument.Counter; @@ -48,6 +49,8 @@ protected void checkStatus() { case READY: case STARTING: return; + case BACKUP: + throw new BackupInProgressException(); default: throw new RuntimeException("Mesh is not ready. Current status " + status.name() + ". Aborting transaction."); } diff --git a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java index 8826139668..18205d4621 100644 --- a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java +++ b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/AbstractRestException.java @@ -11,7 +11,7 @@ /** * Abstract class for regular rest exceptions. This class should be used when returning the exception information via a JSON response. */ -@JsonIgnoreProperties({ "suppressed", "cause", "detailMessage", "stackTrace", "localizedMessage" }) +@JsonIgnoreProperties({ "suppressed", "cause", "detailMessage", "stackTrace", "localizedMessage", "logStackTrace" }) public abstract class AbstractRestException extends RuntimeException { private static final long serialVersionUID = 2209919403583173663L; diff --git a/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java new file mode 100644 index 0000000000..1d4f575576 --- /dev/null +++ b/rest-model/src/main/java/com/gentics/mesh/core/rest/error/BackupInProgressException.java @@ -0,0 +1,20 @@ +package com.gentics.mesh.core.rest.error; + +import io.netty.handler.codec.http.HttpResponseStatus; + +/** + * This exception should be thrown when the database is not available due to a backup. + */ +public class BackupInProgressException extends AbstractRestException { + + private static final String TYPE = "backup_in_progress"; + + public BackupInProgressException() { + super(HttpResponseStatus.SERVICE_UNAVAILABLE, "backup_in_progress"); + } + + @Override + public String getType() { + return TYPE; + } +} From df849b86a73b747a81e66fec24c93075dc9d3e8c Mon Sep 17 00:00:00 2001 From: Umberto D'Ovidio Date: Fri, 14 Oct 2022 12:03:06 +0200 Subject: [PATCH 3/3] update changelog --- LTS-CHANGELOG.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LTS-CHANGELOG.adoc b/LTS-CHANGELOG.adoc index 8c3e99a8c4..48e4ee10c0 100644 --- a/LTS-CHANGELOG.adoc +++ b/LTS-CHANGELOG.adoc @@ -17,6 +17,11 @@ include::content/docs/variables.adoc-include[] The LTS changelog lists releases which are only accessible via a commercial subscription. All fixes and changes in LTS releases will be released the next minor release. Changes from LTS 1.4.x will be included in release 1.5.0. +[[v1.8.12]] +== 1.8.12 (TBD) + +icon:check[] OrientDB: previously when a backup was in progress all requests would fail with a 500 status code as an internal error. This has been changed to send a 503 status code with a descriptive message. + [[v1.8.11]] == 1.8.11 (06.10.2022) @@ -74,6 +79,11 @@ enforced in the UI, and is now enforced in the REST API. The check is not perfor icon:check[] Core: When a project was deleted, its associated version purge job were not. This has been fixed. +[[v1.6.36]] +== 1.6.36 (TBD) + +icon:check[] OrientDB: previously when a backup was in progress all requests would fail with a 500 status code as an internal error. This has been changed to send a 503 status code with a descriptive message. + [[v1.6.35]] == 1.6.35 (06.10.2022)