From e9b58adb87888787959d437961e2c24b486bc165 Mon Sep 17 00:00:00 2001 From: Andrew Cai Date: Wed, 30 Sep 2020 16:16:13 -0700 Subject: [PATCH] [YW][#5890] Fix nested backup info to include the destination universe in the event of restoring cross-universe. Summary: When restoring to a universe we check the universeUUID of the backupInfo object but universe backups contain nested backupInfo, so the fix is to update the nested objects to match the parent universeUUID. Test Plan: Create universe backup and then try restoring to a different universe from the Backups tabs and selecting a specific backup from the table action. Reviewers: sanketh, arnav Reviewed By: arnav Subscribers: jenkins-bot, yugaware Differential Revision: https://phabricator.dev.yugabyte.com/D9514 --- .../java/com/yugabyte/yw/controllers/BackupsController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/managed/src/main/java/com/yugabyte/yw/controllers/BackupsController.java b/managed/src/main/java/com/yugabyte/yw/controllers/BackupsController.java index 9cedab8d46ac..3b80d1058bb6 100644 --- a/managed/src/main/java/com/yugabyte/yw/controllers/BackupsController.java +++ b/managed/src/main/java/com/yugabyte/yw/controllers/BackupsController.java @@ -67,6 +67,8 @@ public Result restore(UUID customerUUID, UUID universeUUID) { return ApiResponse.error(BAD_REQUEST, errMsg); } + taskParams.universeUUID = universeUUID; + // Change the BackupTableParams in list to be "RESTORE" action type if (taskParams.backupList != null) { for (BackupTableParams subParams: taskParams.backupList) { @@ -78,6 +80,7 @@ public Result restore(UUID customerUUID, UUID universeUUID) { subParams.tableUUID = null; subParams.tableName = null; subParams.keyspace = null; + subParams.universeUUID = universeUUID; subParams.parallelism = taskParams.parallelism;; } } @@ -91,8 +94,6 @@ public Result restore(UUID customerUUID, UUID universeUUID) { return ApiResponse.error(BAD_REQUEST, errMsg); } - taskParams.universeUUID = universeUUID; - Backup newBackup = Backup.create(customerUUID, taskParams); UUID taskUUID = commissioner.submit(TaskType.BackupUniverse, taskParams); LOG.info("Submitted task to restore table backup to {}.{}, task uuid = {}.",