Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 4565983

Browse files
aslicerhkittylyst
andauthored
Fix egg logging and make sure PROD doesn't drop the database. (#122)
* WIP * Fix logging issues. --------- Co-authored-by: Ben Evans <benjamin.john.evans@gmail.com>
1 parent 89ed212 commit 4565983

4 files changed

Lines changed: 26 additions & 30 deletions

File tree

events/src/main/java/com/redhat/runtimes/inventory/events/ArchiveAnnouncement.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class ArchiveAnnouncement {
4343

4444
public ArchiveAnnouncement() {}
4545

46-
// The is_runtimes field in the platform_metadata in stage
46+
// For egg uploads, we identify them via the is_runtimes field in the platform_metadata
4747
public boolean isRuntimes() {
4848
if (platformMetadata == null) {
4949
return false;
@@ -52,6 +52,19 @@ public boolean isRuntimes() {
5252
return isRuntimes == "true" ? true : false;
5353
}
5454

55+
// For egg we need to look in the platform_metadata for the URL
56+
public String getUrl() {
57+
if (platformMetadata == null) {
58+
return url;
59+
}
60+
return String.valueOf(platformMetadata.get("url"));
61+
}
62+
63+
@JsonProperty("url")
64+
public void setUrl(String url) {
65+
this.url = url;
66+
}
67+
5568
////////////////////////////////////////////////////////////////////////
5669

5770
@JsonProperty("version")
@@ -114,16 +127,6 @@ public void setRequestId(String requestId) {
114127
this.requestId = requestId;
115128
}
116129

117-
@JsonProperty("url")
118-
public String getUrl() {
119-
return url;
120-
}
121-
122-
@JsonProperty("url")
123-
public void setUrl(String url) {
124-
this.url = url;
125-
}
126-
127130
@JsonProperty("content_type")
128131
public String getContentType() {
129132
return contentType;

events/src/main/java/com/redhat/runtimes/inventory/events/EventConsumer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public CompletionStage<Void> processMainFlow(Message<String> message) {
8585
// Parse JSON using Jackson
8686
var announce = jsonParser.fromJsonString(payload);
8787
if (announce.getContentType().equals(VALID_CONTENT_TYPE)) {
88-
Log.infof("Processing our Kafka message %s", payload);
88+
Log.debugf("Processing our Kafka message %s", payload);
8989

9090
// Get data back from S3
9191
Log.debugf("Processed message URL: %s", announce.getUrl());
@@ -148,9 +148,8 @@ public CompletionStage<Void> processEggFlow(Message<String> message) {
148148

149149
// Parse JSON using Jackson
150150
var announce = jsonParser.fromJsonString(payload);
151-
// FIXME
152151
if (VALID_CONTENT_TYPE.equals(announce.getContentType()) || announce.isRuntimes()) {
153-
Log.infof("Processing our Kafka message from egg %s", payload);
152+
Log.debugf("Processing our Kafka message from egg %s", payload);
154153

155154
var url = announce.getUrl();
156155
// FIXME I think that we'll need to do more JSON spelunking to get the S3 URL

events/src/main/resources/application.properties

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,16 @@ mp.messaging.incoming.egg.connector=smallrye-kafka
2727
mp.messaging.incoming.egg.topic=platform.inventory.events
2828
mp.messaging.incoming.egg.group.id=runtimes-java-general
2929

30-
# configure your datasource
31-
#quarkus.datasource.db-kind=postgresql
32-
#quarkus.datasource.username=postgres
33-
#quarkus.datasource.password=postgres
34-
#quarkus.datasource.jdbc.url=jdbc:postgresql://127.0.0.1:5432/runtimes
35-
#quarkus.datasource.jdbc.driver=io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
36-
3730
# Verbose logging of SQL statements - disable in production
3831
quarkus.hibernate-orm.log.sql=false
3932
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQLDialect
4033
quarkus.hibernate-orm.physical-naming-strategy=com.redhat.runtimes.inventory.models.SnakeCasePhysicalNamingStrategy
4134

42-
# Do we need this in staging?
35+
# Do we need this only in staging?
4336
quarkus.flyway.migrate-at-start=true
44-
# Flyway must NOT clean the DB when the 'prod' profile is active ?
45-
%stage.quarkus.flyway.clean-at-start=true
46-
# FIXME: Does this option allow us to change the 1.0.0 schema?
47-
#%test.quarkus.flyway.migrate-at-start=true
37+
# Flyway must NOT drop & recreate the DB when the 'prod' profile is active
38+
%stage.quarkus.flyway.clean-at-start=false
39+
%prod.quarkus.flyway.clean-at-start=false
4840

4941
%stage.quarkus.hibernate-orm.database.generation=none
5042
%stage.quarkus.hibernate-orm.sql-load-script=no-file
@@ -56,7 +48,7 @@ quarkus.http.access-log.category=access_log
5648
quarkus.http.access-log.pattern=combined
5749
quarkus.log.category."com.redhat.cloud.notifications".level=INFO
5850

59-
%test.quarkus.http.access-log.category=info
51+
%prod.quarkus.http.access-log.category=info
6052

6153
# IT User service
6254
# these entries are needed because of a bug in quarkus: https://github.com/quarkusio/quarkus/issues/8384
@@ -86,7 +78,8 @@ quarkus.log.cloudwatch.log-group=placeholder
8678
quarkus.log.cloudwatch.access-key-id=placeholder
8779
quarkus.log.cloudwatch.access-key-secret=placeholder
8880

89-
quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=DEBUG
81+
%stage.quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=DEBUG
82+
%prod.quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=INFO
9083

9184
quarkus.rest-client.ob.url=https://bridge.acme.org
9285
quarkus.rest-client.kc.url=https://keycloak.acme.org

rest/src/main/resources/application.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ quarkus.http.access-log.category=access_log
2424
quarkus.http.access-log.pattern=combined
2525
quarkus.log.category."com.redhat.cloud.notifications".level=INFO
2626

27-
%test.quarkus.http.access-log.category=info
27+
%prod.quarkus.http.access-log.category=info
2828

2929
# IT User service
3030
# these entries are needed because of a bug in quarkus: https://github.com/quarkusio/quarkus/issues/8384
@@ -54,7 +54,8 @@ quarkus.log.cloudwatch.log-group=placeholder
5454
quarkus.log.cloudwatch.access-key-id=placeholder
5555
quarkus.log.cloudwatch.access-key-secret=placeholder
5656

57-
quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=DEBUG
57+
%stage.quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=DEBUG
58+
%prod.quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalChecker".level=INFO
5859

5960
quarkus.rest-client.ob.url=https://bridge.acme.org
6061
quarkus.rest-client.kc.url=https://keycloak.acme.org

0 commit comments

Comments
 (0)