aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <valerij92@gmail.com>2021-04-26 13:17:17 +0200
committerValerij Fredriksen <valerij92@gmail.com>2021-04-26 13:17:17 +0200
commit115b9e1575c666354276bf9bbc6d06fbea54ea2a (patch)
tree8e179e0d8153039ca47c9082429b735f0c3fa64d
parent08b0fc3c1cdde7bb5a7222b8761bee5a3922e4ae (diff)
Expose notification level in API
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java17
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java11
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json3
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json4
4 files changed, 30 insertions, 5 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
index 7a4052367c6..299ef3ef50d 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
@@ -50,12 +50,25 @@ public class Notification {
'}';
}
+ public enum Level {
+ warning, error;
+ }
+
public enum Type {
/** Warnings about usage of deprecated features in application package */
- APPLICATION_PACKAGE_WARNING,
+ APPLICATION_PACKAGE_WARNING(Level.warning),
/** Failure to deploy application package */
- DEPLOYMENT_FAILURE
+ DEPLOYMENT_FAILURE(Level.error);
+
+ private final Level level;
+ Type(Level level) {
+ this.level = level;
+ }
+
+ public Level level() {
+ return level;
+ }
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index e5ec3f324ad..9a358f63293 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -496,6 +496,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
private static void toSlime(Cursor cursor, Notification notification) {
cursor.setLong("at", notification.at().toEpochMilli());
+ cursor.setString("level", notificatioLevelAsString(notification.type().level()));
cursor.setString("type", notificationTypeAsString(notification.type()));
Cursor messagesArray = cursor.setArray("messages");
notification.messages().forEach(messagesArray::addString);
@@ -507,7 +508,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
cursor.setString("region", zoneId.region().value());
});
notification.source().clusterId().ifPresent(clusterId -> cursor.setString("clusterId", clusterId.value()));
- notification.source().jobType().ifPresent(jobType -> cursor.setString("jobType", jobType.jobName()));
+ notification.source().jobType().ifPresent(jobType -> cursor.setString("jobName", jobType.jobName()));
notification.source().runNumber().ifPresent(runNumber -> cursor.setLong("runNumber", runNumber));
}
@@ -519,6 +520,14 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
}
}
+ private static String notificatioLevelAsString(Notification.Level level) {
+ switch (level) {
+ case warning: return "warning";
+ case error: return "error";
+ default: throw new IllegalArgumentException("No serialization defined for notification level " + level);
+ }
+ }
+
private HttpResponse applications(String tenantName, Optional<String> applicationName, HttpRequest request) {
TenantName tenant = TenantName.from(tenantName);
if (controller.tenants().get(tenantName).isEmpty())
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json
index 7f583a7d803..ab8262e26bd 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json
@@ -2,13 +2,14 @@
"notifications": [
{
"at": "(ignore)",
+ "level": "error",
"type": "DEPLOYMENT_FAILURE",
"messages": [
"Failed to deploy: Out of capacity"
],
"application": "app2",
"instance": "instance1",
- "jobType": "system-test",
+ "jobName": "system-test",
"runNumber": 12
}
]
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json
index 0ed8e9201a0..2b2c03bb75a 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json
@@ -2,6 +2,7 @@
"notifications": [
{
"at": "(ignore)",
+ "level": "warning",
"type": "APPLICATION_PACKAGE_WARNING",
"messages": [
"Something something deprecated..."
@@ -10,13 +11,14 @@
},
{
"at": "(ignore)",
+ "level": "error",
"type": "DEPLOYMENT_FAILURE",
"messages": [
"Failed to deploy: Out of capacity"
],
"application": "app2",
"instance": "instance1",
- "jobType": "system-test",
+ "jobName": "system-test",
"runNumber": 12
}
]