From 56c9cc9ab476d9ddd394c8992d93345d632ab886 Mon Sep 17 00:00:00 2001 From: Vipul Bansal Date: Tue, 17 Sep 2024 14:37:56 +0000 Subject: [PATCH] [PLAT-15282]: fix NPE on k8s operator backup/restore status update Summary: If any failed backup/restore exists in k8s operator resource, then status update for other b/r restore is failed with NPE as old failed resource does not have status. Test Plan: Tested manually by creating failed backup which does not have status and veridfied the issue but after this change, b/r status were updated correctly as failed one are skipped. Reviewers: anijhawan, vkumar Reviewed By: vkumar Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D38125 --- .../yw/common/operator/KubernetesOperatorStatusUpdater.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/managed/src/main/java/com/yugabyte/yw/common/operator/KubernetesOperatorStatusUpdater.java b/managed/src/main/java/com/yugabyte/yw/common/operator/KubernetesOperatorStatusUpdater.java index eba86363d639..4971794cb508 100644 --- a/managed/src/main/java/com/yugabyte/yw/common/operator/KubernetesOperatorStatusUpdater.java +++ b/managed/src/main/java/com/yugabyte/yw/common/operator/KubernetesOperatorStatusUpdater.java @@ -101,7 +101,8 @@ public void updateRestoreJobStatus(String message, UUID taskUUID) { for (RestoreJob restoreJob : kubernetesClient.resources(RestoreJob.class).inNamespace(namespace).list().getItems()) { - if (restoreJob.getStatus().getTaskUUID().equals(taskUUID.toString())) { + if (restoreJob.getStatus() != null + && restoreJob.getStatus().getTaskUUID().equals(taskUUID.toString())) { // Found our Restore. log.info("Found RestoreJob {} task {} ", restoreJob, taskUUID); RestoreJobStatus status = restoreJob.getStatus(); @@ -143,7 +144,8 @@ public void updateBackupStatus( for (Backup backupCr : kubernetesClient.resources(Backup.class).inNamespace(namespace).list().getItems()) { - if (backupCr.getStatus().getTaskUUID().equals(taskUUID.toString())) { + if (backupCr.getStatus() != null + && backupCr.getStatus().getTaskUUID().equals(taskUUID.toString())) { // Found our backup. log.info("Found Backup {} task {} ", backupCr, taskUUID); BackupStatus status = backupCr.getStatus();