diff --git a/pkg/drivers/kopiabackup/kopiabackup.go b/pkg/drivers/kopiabackup/kopiabackup.go index f2df60f61..390814a8c 100644 --- a/pkg/drivers/kopiabackup/kopiabackup.go +++ b/pkg/drivers/kopiabackup/kopiabackup.go @@ -287,6 +287,7 @@ func jobFor( "/data", }, " ") + // Read the config map from the job option and then add the debug level log if required cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) if jobOption.Compression != "" { diff --git a/pkg/drivers/options.go b/pkg/drivers/options.go index 2cd338679..b888a661e 100644 --- a/pkg/drivers/options.go +++ b/pkg/drivers/options.go @@ -396,14 +396,6 @@ func WithVolumeBackupDeleteName(name string) JobOption { } } -// WithKopiaDebugMode is job parameter -func WithKopiaDebugMode(debugMode bool) JobOption { - return func(opts *JobOpts) error { - opts.KopiaDebugMode = debugMode - return nil - } -} - // WithVolumeBackupDeleteNamespace is job parameter. func WithVolumeBackupDeleteNamespace(ns string) JobOption { return func(opts *JobOpts) error { diff --git a/pkg/drivers/utils/utils.go b/pkg/drivers/utils/utils.go index 5ef21f69b..33aa2fc92 100644 --- a/pkg/drivers/utils/utils.go +++ b/pkg/drivers/utils/utils.go @@ -1,7 +1,6 @@ package utils import ( - "context" "errors" "fmt" "os" @@ -13,7 +12,6 @@ import ( storkapi "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1" "github.com/libopenstorage/stork/pkg/k8sutils" "github.com/portworx/kdmp/pkg/drivers" - kdmpops "github.com/portworx/kdmp/pkg/util/ops" "github.com/portworx/kdmp/pkg/version" "github.com/portworx/sched-ops/k8s/apps" "github.com/portworx/sched-ops/k8s/core" @@ -67,6 +65,8 @@ const ( PvcBoundFailedMsg = "pvc not bounded" // KopiaDebugModeEnabled - debug level log messages are enabled for kopia KopiaDebugModeEnabled = "kopia-debug-mode" + // KopiaExecutorDebugModeCMKey - key present in the config maps, which enables debug log level in kopia + KopiaExecutorDebugModeCMKey = "KDMP_KOPIAEXECUTOR_ENABLE_DEBUG_MODE" ) var ( @@ -881,36 +881,14 @@ func IsJobPodMountFailed(job *batchv1.Job, namespace string) bool { return false } -func IsKopiaDebugModeAnnotationsEnabled(jobOption drivers.JobOpts) bool { - // Check for kopia delete and maintenance operations. Since, the debug is passed from job options - // and not from Data Export CR. - 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) - return false - } - - if _, ok := dataExportCR.Annotations[KopiaDebugModeEnabled]; ok { - logrus.Infof("annotation %v found in the data export CR.", KopiaDebugModeEnabled) - return true - } - return false -} - func CheckAndAddKopiaDebugModeEnabled(cmd string, jobOption drivers.JobOpts) string { - if IsKopiaDebugModeAnnotationsEnabled(jobOption) { - cmd = AddKopiaDebugModeCommand(cmd) + // check for the particular key-value pair + isKeyPresent := GetConfigValue(jobOption.JobConfigMap, jobOption.JobConfigMapNs, KopiaExecutorDebugModeCMKey) + if isKeyPresent == "true" { + splitCmd := strings.Split(cmd, " ") + splitCmd = append(splitCmd, "--log-level", "debug") + cmd = strings.Join(splitCmd, " ") } return cmd } -func AddKopiaDebugModeCommand(cmd string) string { - splitCmd := strings.Split(cmd, " ") - splitCmd = append(splitCmd, "--log-level", "debug") - cmd = strings.Join(splitCmd, " ") - return cmd -}