From f04a8820402221a9ba2207574bcf237a2565e5d0 Mon Sep 17 00:00:00 2001 From: Ola Aunronning Date: Thu, 22 Jun 2023 12:08:07 +0200 Subject: [PATCH] Remove hardcoded datetime --- .../restapi/changemanagement/ChangeManagementApiHandler.java | 5 ++++- .../restapi/changemanagement/responses/initial.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java index 6d19316efd77..a72e0fdfe522 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java @@ -27,6 +27,8 @@ import com.yahoo.yolean.Exceptions; import java.io.IOException; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -36,6 +38,7 @@ public class ChangeManagementApiHandler extends AuditLoggingRequestHandler { private final ChangeManagementAssessor assessor; private final Controller controller; + private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneOffset.UTC); public ChangeManagementApiHandler(ThreadedHttpRequestHandler.Context ctx, Controller controller) { super(ctx, controller.auditLogger()); @@ -164,7 +167,7 @@ private HttpResponse doAssessment(List hostNames) { Cursor assessmentCursor = root.setObject("assessment"); // Updated gives clue to if the assessment is old - assessmentCursor.setString("updated", "2021-03-12:12:12:12Z"); + assessmentCursor.setString("updated", formatter.format(controller.clock().instant())); // Assessment on the cluster level Cursor clustersCursor = assessmentCursor.setArray("clusters"); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/responses/initial.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/responses/initial.json index 1fb8ad8be173..d9ffa9feaf90 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/responses/initial.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/responses/initial.json @@ -1,6 +1,6 @@ { "assessment": { - "updated": "2021-03-12:12:12:12Z", + "updated": "2020-09-13T12:26:40Z", "clusters": [ { "app": "mytenant:myapp:default",