Skip to content

Commit

Permalink
Adapt properties to required pattern (#5249)
Browse files Browse the repository at this point in the history
* Add tests that checks properties pattern matching

* Update config properties to match the required pattern

* Fixed artifact-version deletion config property name

---------

Co-authored-by: Eric Wittmann <[email protected]>
  • Loading branch information
carlesarnal and EricWittmann authored Sep 26, 2024
1 parent 1f56715 commit f4919d5
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ public class PersistenceExceptionLivenessCheck extends AbstractErrorCounterHealt
* Maximum number of exceptions raised by artifactStore implementation, as captured by this interceptor,
* before the liveness check fails.
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceExceptionLivenessCheck.errorThreshold", defaultValue = "1")
@ConfigProperty(name = "apicurio.metrics.persistence-exception-liveness-check.error-threshold", defaultValue = "1")
@Info(category = "health", description = "Error threshold of persistence liveness check", availableSince = "1.0.2.Final")
Integer configErrorThreshold;

/**
* The counter is reset after some time without errors. i.e. to fail the check after 2 errors in a minute,
* set the threshold to 1 and this configuration option to 60. TODO report the absolute count as a metric?
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceExceptionLivenessCheck.counterResetWindowDuration.seconds", defaultValue = "60")
@ConfigProperty(name = "apicurio.metrics.persistence-exception-liveness-check.counter-reset-window-duration.seconds", defaultValue = "60")
@Info(category = "health", description = "Counter reset window duration of persistence liveness check", availableSince = "1.0.2.Final")
Integer configCounterResetWindowDurationSec;

/**
* If set to a positive value, reset the liveness status after this time window passes without any further
* errors.
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceExceptionLivenessCheck.statusResetWindowDuration.seconds", defaultValue = "300")
@ConfigProperty(name = "apicurio.metrics.persistence-exception-liveness-check.status-reset-window-duration.seconds", defaultValue = "300")
@Info(category = "health", description = "Status reset window duration of persistence liveness check", availableSince = "1.0.2.Final")
Integer configStatusResetWindowDurationSec;

@ConfigProperty(name = "apicurio.metrics.PersistenceExceptionLivenessCheck.logging.disabled", defaultValue = "false")
@ConfigProperty(name = "apicurio.metrics.persistence-exception-liveness-check.logging.disabled", defaultValue = "false")
@Info(category = "health", description = "Disable logging of persistence liveness check", availableSince = "2.0.0.Final")
Boolean disableLogging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ public class ResponseErrorLivenessCheck extends AbstractErrorCounterHealthCheck
* Maximum number of HTTP 5xx errors returned to the user as captured by
* {@link io.apicurio.registry.rest.RegistryExceptionMapper} before the liveness check fails.
*/
@ConfigProperty(name = "apicurio.metrics.ResponseErrorLivenessCheck.errorThreshold", defaultValue = "1")
@ConfigProperty(name = "apicurio.metrics.response-error-liveness-check.error-threshold", defaultValue = "1")
@Info(category = "health", description = "Error threshold of response liveness check", availableSince = "1.0.2.Final")
Integer configErrorThreshold;

/**
* The counter is reset after some time without errors. i.e. to fail the check after 2 errors in a minute,
* set the threshold to 1 and this configuration option to 60. TODO report the absolute count as a metric?
*/
@ConfigProperty(name = "apicurio.metrics.ResponseErrorLivenessCheck.counterResetWindowDuration.seconds", defaultValue = "60")
@ConfigProperty(name = "apicurio.metrics.resonse-error-liveness-check.counter-reset-window-duration.seconds", defaultValue = "60")
@Info(category = "health", description = "Counter reset window duration of response liveness check", availableSince = "1.0.2.Final")
Integer configCounterResetWindowDurationSec;

/**
* If set to a positive value, reset the liveness status after this time window passes without any further
* errors.
*/
@ConfigProperty(name = "apicurio.metrics.ResponseErrorLivenessCheck.statusResetWindowDuration.seconds", defaultValue = "300")
@ConfigProperty(name = "apicurio.metrics.response-error-liveness-check.status-reset-window-duration.seconds", defaultValue = "300")
@Info(category = "health", description = "Status reset window duration of response liveness check", availableSince = "1.0.2.Final")
Integer configStatusResetWindowDurationSec;

@ConfigProperty(name = "apicurio.metrics.ResponseErrorLivenessCheck.logging.disabled", defaultValue = "false")
@ConfigProperty(name = "apicurio.metrics.response-error-liveness-check.disabled", defaultValue = "false")
@Info(category = "health", description = "Disable logging of response liveness check", availableSince = "2.0.0.Final")
Boolean disableLogging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ public class PersistenceTimeoutReadinessCheck extends AbstractErrorCounterHealth
/**
* Maximum number of timeouts as captured by this interceptor, before the readiness check fails.
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceTimeoutReadinessCheck.errorThreshold", defaultValue = "5")
@ConfigProperty(name = "apicurio.metrics.persistence-timeout-readiness-check.error-threshold", defaultValue = "5")
@Info(category = "health", description = "Error threshold of persistence readiness check", availableSince = "1.0.2.Final")
Integer configErrorThreshold;

/**
* The counter is reset after some time without errors. i.e. to fail the check after 2 errors in a minute,
* set the threshold to 1 and this configuration option to 60. TODO report the absolute count as a metric?
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceTimeoutReadinessCheck.counterResetWindowDuration.seconds", defaultValue = "60")
@ConfigProperty(name = "apicurio.metrics.response-error-liveness-check.counter-reset-window-duration.seconds", defaultValue = "60")
@Info(category = "health", description = "Counter reset window duration of persistence readiness check", availableSince = "1.0.2.Final")
Integer configCounterResetWindowDurationSec;

/**
* If set to a positive value, reset the readiness status after this time window passes without any
* further errors.
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceTimeoutReadinessCheck.statusResetWindowDuration.seconds", defaultValue = "300")
@ConfigProperty(name = "apicurio.metrics.persitence-timeout-readiness-check.status-reset-window-duration.seconds", defaultValue = "300")
@Info(category = "health", description = "Status reset window duration of persistence readiness check", availableSince = "1.0.2.Final")
Integer configStatusResetWindowDurationSec;

/**
* Set the operation duration in seconds, after which it's considered an error.
*/
@ConfigProperty(name = "apicurio.metrics.PersistenceTimeoutReadinessCheck.timeout.seconds", defaultValue = "15")
@ConfigProperty(name = "apicurio.metrics.persistence-timeout-readiness-check.timeout.seconds", defaultValue = "15")
@Info(category = "health", description = "Timeout of persistence readiness check", availableSince = "1.0.2.Final")
Integer configTimeoutSec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@ public class ResponseTimeoutReadinessCheck extends AbstractErrorCounterHealthChe
* Maximum number of requests taking more than {@link ResponseTimeoutReadinessCheck#configTimeoutSec}
* seconds, before the readiness check fails.
*/
@ConfigProperty(name = "apicurio.metrics.ResponseTimeoutReadinessCheck.errorThreshold", defaultValue = "1")
@ConfigProperty(name = "apicurio.metrics.response-timeout-readiness-check.error-threshold", defaultValue = "1")
@Info(category = "health", description = "Error threshold of response readiness check", availableSince = "1.0.2.Final")
Instance<Integer> configErrorThreshold;

/**
* The counter is reset after some time without errors. i.e. to fail the check after 2 errors in a minute,
* set the threshold to 1 and this configuration option to 60. TODO report the absolute count as a metric?
*/
@ConfigProperty(name = "apicurio.metrics.ResponseTimeoutReadinessCheck.counterResetWindowDuration.seconds", defaultValue = "60")
@ConfigProperty(name = "apicurio.metrics.response-timeout-readiness-check.counter-reset-window-duration.seconds", defaultValue = "60")
@Info(category = "health", description = "Counter reset window duration of response readiness check", availableSince = "1.0.2.Final")
Instance<Integer> configCounterResetWindowDurationSec;

/**
* If set to a positive value, reset the readiness status after this time window passes without any
* further errors.
*/
@ConfigProperty(name = "apicurio.metrics.ResponseTimeoutReadinessCheck.statusResetWindowDuration.seconds", defaultValue = "300")
@ConfigProperty(name = "apicurio.metrics.response-timeout-rediness-check.status-reset-window-duration.seconds", defaultValue = "300")
@Info(category = "health", description = "Status reset window duration of response readiness check", availableSince = "1.0.2.Final")
Instance<Integer> configStatusResetWindowDurationSec;

/**
* Set the request duration in seconds, after which it's considered an error. TODO This may be expected on
* some endpoints. Add a way to ignore those.
*/
@ConfigProperty(name = "apicurio.metrics.ResponseTimeoutReadinessCheck.timeout.seconds", defaultValue = "10")
@ConfigProperty(name = "apicurio.metrics.response-timeout-readiness-check.timeout.seconds", defaultValue = "10")
@Info(category = "health", description = "Timeout of response readiness check", availableSince = "1.0.2.Final")
Instance<Integer> configTimeoutSec;

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/io/apicurio/registry/rest/RestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
@Singleton
public class RestConfig {

@ConfigProperty(name = "apicurio.rest.artifact.download.maxSize.bytes", defaultValue = "1000000")
@ConfigProperty(name = "apicurio.rest.artifact.download.max-size.bytes", defaultValue = "1000000")
@Info(category = "rest", description = "Max size of the artifact allowed to be downloaded from URL", availableSince = "2.2.6-SNAPSHOT")
int downloadMaxSize;

@ConfigProperty(name = "apicurio.rest.artifact.download.sslValidation.disabled", defaultValue = "false")
@ConfigProperty(name = "apicurio.rest.artifact.download.ssl-validation.disabled", defaultValue = "false")
@Info(category = "rest", description = "Skip SSL validation when downloading artifacts from URL", availableSince = "2.2.6-SNAPSHOT")
boolean downloadSkipSSLValidation;

Expand All @@ -29,7 +29,7 @@ public class RestConfig {
Supplier<Boolean> artifactDeletionEnabled;

@Dynamic(label = "Delete artifact version", description = "When selected, users are permitted to delete artifact versions.")
@ConfigProperty(name = "apicurio.rest.deletion.artifactVersion.enabled", defaultValue = "false")
@ConfigProperty(name = "apicurio.rest.deletion.artifact-version.enabled", defaultValue = "false")
@Info(category = "rest", description = "Enables artifact version deletion", availableSince = "2.4.2-SNAPSHOT")
Supplier<Boolean> artifactVersionDeletionEnabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Singleton
public class ImportExportConfigProperties {

@ConfigProperty(name = "apicurio.import.workDir")
@ConfigProperty(name = "apicurio.import.work-dir")
@Info(category = "import", description = "Temporary work directory to use when importing data.", availableSince = "3.0.0")
public String workDir;

Expand Down
28 changes: 14 additions & 14 deletions app/src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Readiness and Liveness
apicurio.metrics.PersistenceExceptionLivenessCheck.errorThreshold=5
apicurio.metrics.PersistenceExceptionLivenessCheck.counterResetWindowDuration.seconds=30
apicurio.metrics.PersistenceExceptionLivenessCheck.statusResetWindowDuration.seconds=60
apicurio.metrics.ResponseErrorLivenessCheck.errorThreshold=5
apicurio.metrics.ResponseErrorLivenessCheck.counterResetWindowDuration.seconds=30
apicurio.metrics.ResponseErrorLivenessCheck.statusResetWindowDuration.seconds=60
apicurio.metrics.persistence-exception-liveness-check.error-threshold=5
apicurio.metrics.persistence-exception-liveness-check.counter-reset-window-duration.seconds=30
apicurio.metrics.persistence-exception-liveness-check.status-reset-window-duration.seconds=60
apicurio.metrics.response-error-liveness-check.error-threshold=5
apicurio.metrics.resonse-error-liveness-check.counter-reset-window-duration.seconds=30
apicurio.metrics.response-error-liveness-check.status-reset-window-duration.seconds=60

apicurio.metrics.PersistenceTimeoutReadinessCheck.errorThreshold=5
apicurio.metrics.PersistenceTimeoutReadinessCheck.counterResetWindowDuration.seconds=30
apicurio.metrics.PersistenceTimeoutReadinessCheck.statusResetWindowDuration.seconds=60
apicurio.metrics.PersistenceTimeoutReadinessCheck.timeout.seconds=10
apicurio.metrics.ResponseTimeoutReadinessCheck.errorThreshold=5
apicurio.metrics.ResponseTimeoutReadinessCheck.counterResetWindowDuration.seconds=30
apicurio.metrics.ResponseTimeoutReadinessCheck.statusResetWindowDuration.seconds=60
apicurio.metrics.ResponseTimeoutReadinessCheck.timeout.seconds=20
apicurio.metrics.persistence-timeout-readiness-check.error-threshold=5
apicurio.metrics.response-error-liveness-check.counter-reset-window-duration.seconds=30
apicurio.metrics.persitence-timeout-readiness-check.status-reset-window-duration.seconds=60
apicurio.metrics.persistence-timeout-readiness-check.timeout.seconds=10
apicurio.metrics.response-timeout-readiness-check.error-threshold=5
apicurio.metrics.response-timeout-readiness-check.counter-reset-window-duration.seconds=30
apicurio.metrics.response-timeout-rediness-check.status-reset-window-duration.seconds=60
apicurio.metrics.response-timeout-readiness-check.timeout.seconds=20

apicurio.liveness.errors.ignored=

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ quarkus.test.flat-class-path=true
apicurio.events.kafka.config.bootstrap.servers=localhost:9092

# Metrics
apicurio.metrics.ResponseTimeoutReadinessCheck.errorThreshold=10000
apicurio.metrics.ResponseErrorLivenessCheck.errorThreshold=10000
apicurio.metrics.ResponseErrorLivenessCheck.logging.disabled=true
apicurio.metrics.PersistenceTimeoutReadinessCheck.errorThreshold=10000
apicurio.metrics.PersistenceExceptionLivenessCheck.errorThreshold=10000
apicurio.metrics.PersistenceExceptionLivenessCheck.logging.disabled=true
apicurio.metrics.response-timeout-readiness-check.error-threshold=10000
apicurio.metrics.response-error-liveness-check.error-threshold=10000
apicurio.metrics.response-error-liveness-check.disabled=true
apicurio.metrics.persistence-timeout-readiness-check.error-threshold=10000
apicurio.metrics.persistence-exception-liveness-check.error-threshold=10000
apicurio.metrics.persistence-exception-liveness-check.logging.disabled=true

#Log config
apicurio.logconfigjob.every=1s
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ apicurio.config.dynamic.allow-all=true
apicurio.auth.owner-only-authorization.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.auth.owner-only-authorization.limit-group-access.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.auth.anonymous-read-access.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.authn.basic-client-credentials.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.ccompat.legacy-id-mode.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.ccompat.use-canonical-hash.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.ccompat.max-subjects.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.download.href.ttl.seconds.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.ui.features.read-only.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.storage.read-only.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.authn.basic-client-credentials.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.rest.deletion.group.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.rest.deletion.artifact.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.rest.deletion.artifactVersion.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.rest.deletion.artifact-version.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.semver.validation.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.semver.branching.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.semver.branching.coerce.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.storage.read-only.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}
apicurio.ui.features.read-only.enabled.dynamic.allow=${apicurio.config.dynamic.allow-all}

# Error
apicurio.api.errors.include-stack-in-response=false
Expand All @@ -150,8 +150,8 @@ apicurio.redirects.enabled=true
apicurio.redirects.root=/,/apis

# Rest
apicurio.rest.artifact.download.maxSize.bytes=1000000
apicurio.rest.artifact.download.sslValidation.disabled=false
apicurio.rest.artifact.download.max-size.bytes=1000000
apicurio.rest.artifact.download.ssl-validation.disabled=false
apicurio.rest.artifact.deletion.enabled=false
# Api date format
apicurio.apis.v2.date-format=yyyy-MM-dd'T'HH:mm:ss'Z'
Expand All @@ -160,7 +160,7 @@ apicurio.apis.v2.date-format-timezone=UTC
# Storage
apicurio.storage.kind=sql
apicurio.storage.snapshot.location=${java.io.tmpdir}
apicurio.import.workDir=${java.io.tmpdir}
apicurio.import.work-dir=${java.io.tmpdir}

## SQL Storage
apicurio.storage.sql.kind=h2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.apicurio.registry.noprofile.config;

import io.apicurio.registry.AbstractResourceTestBase;
import io.quarkus.test.junit.QuarkusTest;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.stream.StreamSupport;

@QuarkusTest
public class ConfigTest extends AbstractResourceTestBase {

@Test
public void configurationTest() {
Iterable<String> propertyNamesIterable = ConfigProvider.getConfig().getPropertyNames();

List<String> offendingProperties = StreamSupport.stream(propertyNamesIterable.spliterator(), false)
.filter(propertyName -> propertyName.startsWith("apicurio")
|| propertyName.startsWith("registry"))
.filter(this::propertyDontMatchPattern).peek(System.out::println).toList();

Assertions.assertEquals(0, offendingProperties.size());
}

private boolean propertyDontMatchPattern(String propertyName) {
boolean hasUpperCase = propertyName.chars().anyMatch(Character::isUpperCase);
boolean hasUnderscore = propertyName.chars().anyMatch(c -> c == '_');
return hasUpperCase || hasUnderscore;
}
}
Loading

0 comments on commit f4919d5

Please sign in to comment.