Skip to content

Commit

Permalink
pb-4844: Making changes for delete and maintenance, since they dont u…
Browse files Browse the repository at this point in the history
…se DE CR, need to take value from job options for them

Signed-off-by: root <[email protected]>
  • Loading branch information
root committed Dec 8, 2023
1 parent 57378b5 commit 7cd42f6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/drivers/kopiabackup/kopiabackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func jobFor(
"/data",
}, " ")

cmd = utils.CheckAndAddKopiaDebugModeAnnotationsCommand(cmd, jobOption)
cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption)

if jobOption.Compression != "" {
splitCmd := strings.Split(cmd, " ")
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/kopiadelete/kopiadelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/kopiamaintenance/kopiamaintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/kopiarestore/kopiarestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 13 additions & 4 deletions pkg/drivers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion pkg/executor/kopia/kopiabackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,4 +699,4 @@ func addLogLevelDebugToCommand(kopiaCommand *kopia.Command, logLevelDebug string
kopiaCommand.AddArg("debug")
}
return kopiaCommand
}
}

0 comments on commit 7cd42f6

Please sign in to comment.