From 2e275ed01c1c9154bdc954d0631defc424761339 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Dec 2023 06:16:43 +0000 Subject: [PATCH] pb-4844: Making changes for delete and maintenance, since they dont use DE CR, need to take value from job options for them Signed-off-by: root --- pkg/drivers/kopiabackup/kopiabackup.go | 2 +- pkg/drivers/kopiadelete/kopiadelete.go | 2 +- .../kopiamaintenance/kopiamaintenance.go | 2 +- pkg/drivers/kopiarestore/kopiarestore.go | 2 +- pkg/drivers/utils/utils.go | 17 +++++++++++++---- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/drivers/kopiabackup/kopiabackup.go b/pkg/drivers/kopiabackup/kopiabackup.go index 5292f7c41..f2df60f61 100644 --- a/pkg/drivers/kopiabackup/kopiabackup.go +++ b/pkg/drivers/kopiabackup/kopiabackup.go @@ -287,7 +287,7 @@ func jobFor( "/data", }, " ") - cmd = utils.CheckAndAddKopiaDebugModeAnnotationsCommand(cmd, jobOption) + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) if jobOption.Compression != "" { splitCmd := strings.Split(cmd, " ") diff --git a/pkg/drivers/kopiadelete/kopiadelete.go b/pkg/drivers/kopiadelete/kopiadelete.go index 4d9ff778c..0837e4cfb 100644 --- a/pkg/drivers/kopiadelete/kopiadelete.go +++ b/pkg/drivers/kopiadelete/kopiadelete.go @@ -201,7 +201,7 @@ func jobFor( jobOption.VolumeBackupDeleteNamespace, }, " ") - cmd = utils.CheckAndAddKopiaDebugModeAnnotationsCommand(cmd, jobOption) + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, diff --git a/pkg/drivers/kopiamaintenance/kopiamaintenance.go b/pkg/drivers/kopiamaintenance/kopiamaintenance.go index d8a6ddfc5..84dfec882 100644 --- a/pkg/drivers/kopiamaintenance/kopiamaintenance.go +++ b/pkg/drivers/kopiamaintenance/kopiamaintenance.go @@ -204,7 +204,7 @@ func jobFor( jobOption.MaintenanceType, }, " ") - cmd = utils.CheckAndAddKopiaDebugModeAnnotationsCommand(cmd, jobOption) + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, diff --git a/pkg/drivers/kopiarestore/kopiarestore.go b/pkg/drivers/kopiarestore/kopiarestore.go index 43b646299..c5ef5929f 100644 --- a/pkg/drivers/kopiarestore/kopiarestore.go +++ b/pkg/drivers/kopiarestore/kopiarestore.go @@ -206,7 +206,7 @@ func jobFor( vb.Status.SnapshotID, }, " ") - cmd = utils.CheckAndAddKopiaDebugModeAnnotationsCommand(cmd, jobOption) + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, diff --git a/pkg/drivers/utils/utils.go b/pkg/drivers/utils/utils.go index f94e159b2..06698134a 100644 --- a/pkg/drivers/utils/utils.go +++ b/pkg/drivers/utils/utils.go @@ -882,6 +882,10 @@ func IsJobPodMountFailed(job *batchv1.Job, namespace string) bool { } func IsKopiaDebugModeAnnotationsEnabled(jobOption drivers.JobOpts) bool { + if jobOption.KopiaDebugMode { + return true + } + dataExportCR, err := kdmpops.Instance().GetDataExport(context.Background(), jobOption.DataExportName, jobOption.Namespace) if err != nil { logrus.Tracef("error reading data export job: %v", err) @@ -895,11 +899,16 @@ func IsKopiaDebugModeAnnotationsEnabled(jobOption drivers.JobOpts) bool { return false } -func CheckAndAddKopiaDebugModeAnnotationsCommand(cmd string, jobOption drivers.JobOpts) string { +func CheckAndAddKopiaDebugModeEnabled(cmd string, jobOption drivers.JobOpts) string { if IsKopiaDebugModeAnnotationsEnabled(jobOption) { - splitCmd := strings.Split(cmd, " ") - splitCmd = append(splitCmd, "--log-level", "debug") - cmd = strings.Join(splitCmd, " ") + cmd = AddKopiaDebugModeCommand(cmd) } return cmd } + +func AddKopiaDebugModeCommand(cmd string) string { + splitCmd := strings.Split(cmd, " ") + splitCmd = append(splitCmd, "--log-level", "debug") + cmd = strings.Join(splitCmd, " ") + return cmd +}