From 54a922ab500ce8f7f9cf66412f6e012f0a9c6f27 Mon Sep 17 00:00:00 2001 From: Naorem Khogendro Singh Date: Thu, 31 Oct 2024 16:57:14 -0700 Subject: [PATCH] [PLAT-15949] Robustness fix around task percentage reporting on success Summary: Make sure 100% is returned for successful tasks. We still want to record subtasks which were not run. So, they are left intact. Test Plan: Manually modified task_info to test. Also aborted and retried tasks for the freeze part. Reviewers: cwang, vkumar, anijhawan Reviewed By: vkumar, anijhawan Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D39670 --- .../yugabyte/yw/commissioner/tasks/UniverseTaskBase.java | 4 ++-- .../src/main/java/com/yugabyte/yw/models/TaskInfo.java | 6 +++--- managed/src/main/resources/swagger-strict.json | 8 ++++---- managed/src/main/resources/swagger.json | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/managed/src/main/java/com/yugabyte/yw/commissioner/tasks/UniverseTaskBase.java b/managed/src/main/java/com/yugabyte/yw/commissioner/tasks/UniverseTaskBase.java index 5850a8e3cb5c..2cc581023731 100644 --- a/managed/src/main/java/com/yugabyte/yw/commissioner/tasks/UniverseTaskBase.java +++ b/managed/src/main/java/com/yugabyte/yw/commissioner/tasks/UniverseTaskBase.java @@ -1270,12 +1270,12 @@ public Universe lockAndFreezeUniverseForUpdate( if (isFirstTry()) { createFreezeUniverseTask(universeUuid, firstRunTxnCallback) .setSubTaskGroupType(SubTaskGroupType.ValidateConfigurations); - // Run to apply the change first before adding the rest of the subtasks. - getRunnableTask().runSubTasks(); } else { createFreezeUniverseTask(universeUuid) .setSubTaskGroupType(SubTaskGroupType.ValidateConfigurations); } + // Run to apply the change first before adding the rest of the subtasks. + getRunnableTask().runSubTasks(); return Universe.getOrBadRequest(universeUuid); } catch (RuntimeException e) { unlockUniverseForUpdate(universeUuid); diff --git a/managed/src/main/java/com/yugabyte/yw/models/TaskInfo.java b/managed/src/main/java/com/yugabyte/yw/models/TaskInfo.java index 573b1de593a2..9b827c28600a 100644 --- a/managed/src/main/java/com/yugabyte/yw/models/TaskInfo.java +++ b/managed/src/main/java/com/yugabyte/yw/models/TaskInfo.java @@ -400,11 +400,11 @@ public UserTaskDetails getUserTaskDetails(List subTaskInfos, TaskCache */ @JsonIgnore public double getPercentCompleted() { + if (getTaskState() == TaskInfo.State.Success) { + return 100.0; + } int numSubtasks = TaskInfo.find.query().where().eq("parent_uuid", getUuid()).findCount(); if (numSubtasks == 0) { - if (getTaskState() == TaskInfo.State.Success) { - return 100.0; - } return 0.0; } int numSubtasksCompleted = diff --git a/managed/src/main/resources/swagger-strict.json b/managed/src/main/resources/swagger-strict.json index f2fc58a8b277..fecdfbb417b1 100644 --- a/managed/src/main/resources/swagger-strict.json +++ b/managed/src/main/resources/swagger-strict.json @@ -8456,8 +8456,8 @@ "type" : "string" }, "nodeName" : { - "description" : "The node's name", - "example" : "India node", + "description" : "The node's name in a universe", + "example" : "universe_node1", "readOnly" : true, "type" : "string" }, @@ -8509,8 +8509,8 @@ "uniqueItems" : true }, "nodeName" : { - "description" : "Node name", - "example" : "India node", + "description" : "Node name in a universe", + "example" : "universe_node1", "readOnly" : true, "type" : "string" }, diff --git a/managed/src/main/resources/swagger.json b/managed/src/main/resources/swagger.json index 38f8bb0e06f1..07acfaa7fbac 100644 --- a/managed/src/main/resources/swagger.json +++ b/managed/src/main/resources/swagger.json @@ -8507,8 +8507,8 @@ "type" : "string" }, "nodeName" : { - "description" : "The node's name", - "example" : "India node", + "description" : "The node's name in a universe", + "example" : "universe_node1", "readOnly" : true, "type" : "string" }, @@ -8560,8 +8560,8 @@ "uniqueItems" : true }, "nodeName" : { - "description" : "Node name", - "example" : "India node", + "description" : "Node name in a universe", + "example" : "universe_node1", "readOnly" : true, "type" : "string" },