diff --git a/go.mod b/go.mod index 020db00835..f053c762f9 100644 --- a/go.mod +++ b/go.mod @@ -333,7 +333,7 @@ replace ( github.com/libopenstorage/autopilot-api => github.com/libopenstorage/autopilot-api v0.6.1-0.20210301232050-ca2633c6e114 github.com/libopenstorage/openstorage => github.com/libopenstorage/openstorage v0.0.0-20230511212757-41751b27d69f github.com/libopenstorage/secrets => github.com/libopenstorage/secrets v0.0.0-20220413195519-57d1c446c5e9 - github.com/portworx/kdmp => github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 + github.com/portworx/kdmp => github.com/portworx/kdmp v0.4.1-0.20231210172248-55ce29ec9310 github.com/portworx/sched-ops => github.com/portworx/sched-ops v1.20.4-rc1.0.20230930052008-186afa1e82c4 github.com/portworx/torpedo => github.com/portworx/torpedo v0.0.0-20231013194137-84e2957806f0 gopkg.in/fsnotify.v1 v1.4.7 => github.com/fsnotify/fsnotify v1.4.7 diff --git a/go.sum b/go.sum index 3f7a72e9cb..c7be1841c6 100644 --- a/go.sum +++ b/go.sum @@ -2446,13 +2446,12 @@ github.com/libopenstorage/openstorage v0.0.0-20230511212757-41751b27d69f/go.mod github.com/libopenstorage/openstorage-sdk-clients v0.109.0/go.mod h1:vo0c/nLG2HIyQva4Avwx61U1kWcw4HGQh3sjzV2DEEs= github.com/libopenstorage/operator v0.0.0-20230323034810-8853b151f594/go.mod h1:0S4k1ouTScuVS3rxPukfEFvc5bMasmI1wpAAM0NejWQ= github.com/libopenstorage/operator v0.0.0-20230801044606-e27dec4914d4/go.mod h1:Lc0sagIlgkrXHn+vwR9JfZkAkSsdedtbrRx42qF0vMc= -github.com/libopenstorage/operator v0.0.0-20230814210648-7843b18f6ab0/go.mod h1:rzxe/bUCAJVZM41Xza6fqHw6T7gXkCnkbVGMlRITmPQ= github.com/libopenstorage/operator v0.0.0-20231004002935-494c2edc384a h1:RIw6gTpw0wbYHxTM2sB/LYgtRP0TLPQSJvPVGy07Lw4= github.com/libopenstorage/operator v0.0.0-20231004002935-494c2edc384a/go.mod h1:pMNY6LzUPynOLB+CEKksLTm8UvvCfeBFN0Leu8evN7U= github.com/libopenstorage/secrets v0.0.0-20220413195519-57d1c446c5e9 h1:pZQ5uaWky7KerHX2saBO971ti+IBDJRorHwcHwc+0aM= github.com/libopenstorage/secrets v0.0.0-20220413195519-57d1c446c5e9/go.mod h1:gE8rSd6lwLNXNbiW3DrRZjFMs+y4fDHy/6uiOO9cdzY= github.com/libopenstorage/stork v1.4.1-0.20230610103146-72cf75320066/go.mod h1:Yst+fnOYjWk6SA5pXZBKm19wtiinjxQ/vgYTXI3k80Q= -github.com/libopenstorage/stork v1.4.1-0.20231003165010-29f495ef07e2/go.mod h1:ccfbJni2ECyq6ukcs9Q1d4wN5u2+zngRl/FVTk6Lcsw= +github.com/libopenstorage/stork v1.4.1-0.20231129051608-5cf733dbfd9e/go.mod h1:wowq0fd8NQyqDvLiKmGky+C2GtN8m7hjixOrQpYLtok= github.com/libopenstorage/systemutils v0.0.0-20160208220149-44ac83be3ce1 h1:5vqfYYWm4b+lbkMtvvWtWBiqLbmLN6dNvWaa7wVsz/Q= github.com/libopenstorage/systemutils v0.0.0-20160208220149-44ac83be3ce1/go.mod h1:xwNGC7xiz/BQ/wbMkvHujL8Gjgseg+x41xMek7sKRRQ= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= @@ -2894,8 +2893,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v1.0.5/go.mod h1:APVvOesVSAnne5SClsPxPdfvZTVDojXh1/G3qb5wjGI= github.com/portworx/dcos-secrets v0.0.0-20180616013705-8e8ec3f66611/go.mod h1:4hklRW/4DQpLqkcXcjtNprbH2tz/sJaNtqinfPWl/LA= -github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 h1:9UBxkJyCz+UzsUMa+dAYhThmQ0T9nShQJePVQrDEKpk= -github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972/go.mod h1:mMZUDNoAfslBw6DxEXKN2KSEt14l/HIGtt1CzgOghp0= +github.com/portworx/kdmp v0.4.1-0.20231210172248-55ce29ec9310 h1:MwwOAH8nMn6TKmn1nqPn00MNUJDb07GQE5fhuvvgKZM= +github.com/portworx/kdmp v0.4.1-0.20231210172248-55ce29ec9310/go.mod h1:ifabdOPy5LT/PbsNJOIp3+bwszLDj9Iw8I4XrKN0O7I= github.com/portworx/kvdb v0.0.0-20190105022415-cccaa09abfc9/go.mod h1:Q8YyrNDvPp3DVF96BDcQuaC7fAYUCuUX+l58S7OnD2M= github.com/portworx/kvdb v0.0.0-20200723230726-2734b7f40194/go.mod h1:Q8YyrNDvPp3DVF96BDcQuaC7fAYUCuUX+l58S7OnD2M= github.com/portworx/kvdb v0.0.0-20200929023115-b312c7519467/go.mod h1:Q8YyrNDvPp3DVF96BDcQuaC7fAYUCuUX+l58S7OnD2M= diff --git a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiabackup/kopiabackup.go b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiabackup/kopiabackup.go index 1c29b69288..f2df60f618 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiabackup/kopiabackup.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiabackup/kopiabackup.go @@ -287,6 +287,8 @@ func jobFor( "/data", }, " ") + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) + if jobOption.Compression != "" { splitCmd := strings.Split(cmd, " ") splitCmd = append(splitCmd, "--compression", jobOption.Compression) @@ -507,7 +509,7 @@ func roleFor(live bool) *rbacv1.Role { Rules: []rbacv1.PolicyRule{ { APIGroups: []string{"kdmp.portworx.com"}, - Resources: []string{"volumebackups"}, + Resources: []string{"volumebackups", "dataexports"}, Verbs: []string{rbacv1.VerbAll}, }, }, diff --git a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiadelete/kopiadelete.go b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiadelete/kopiadelete.go index 7ee70c20f4..0837e4cfb1 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiadelete/kopiadelete.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiadelete/kopiadelete.go @@ -201,6 +201,8 @@ func jobFor( jobOption.VolumeBackupDeleteNamespace, }, " ") + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) + kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, jobOption.KopiaImageExecutorSourceNs, diff --git a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiamaintenance/kopiamaintenance.go b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiamaintenance/kopiamaintenance.go index 8bb46e4d20..84dfec882d 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiamaintenance/kopiamaintenance.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiamaintenance/kopiamaintenance.go @@ -204,6 +204,8 @@ func jobFor( jobOption.MaintenanceType, }, " ") + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) + kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, jobOption.KopiaImageExecutorSourceNs, diff --git a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiarestore/kopiarestore.go b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiarestore/kopiarestore.go index ba0b7c7e30..c5ef5929fd 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/kopiarestore/kopiarestore.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/kopiarestore/kopiarestore.go @@ -206,6 +206,8 @@ func jobFor( vb.Status.SnapshotID, }, " ") + cmd = utils.CheckAndAddKopiaDebugModeEnabled(cmd, jobOption) + kopiaExecutorImage, imageRegistrySecret, err := utils.GetExecutorImageAndSecret(drivers.KopiaExecutorImage, jobOption.KopiaImageExecutorSource, jobOption.KopiaImageExecutorSourceNs, @@ -369,7 +371,7 @@ func roleFor() *rbacv1.Role { }, { APIGroups: []string{"kdmp.portworx.com"}, - Resources: []string{"volumebackups"}, + Resources: []string{"volumebackups", "dataexports"}, Verbs: []string{rbacv1.VerbAll}, }, }, diff --git a/vendor/github.com/portworx/kdmp/pkg/drivers/options.go b/vendor/github.com/portworx/kdmp/pkg/drivers/options.go index 61d597c866..2cd3386799 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/options.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/options.go @@ -19,6 +19,7 @@ type JobOpts struct { VolumeBackupName string VolumeBackupNamespace string VolumeBackupDeleteName string + KopiaDebugMode bool VolumeBackupDeleteNamespace string DataExportName string SnapshotID string @@ -395,6 +396,14 @@ 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/vendor/github.com/portworx/kdmp/pkg/drivers/utils/utils.go b/vendor/github.com/portworx/kdmp/pkg/drivers/utils/utils.go index 170ab9efd3..5ef21f69b1 100644 --- a/vendor/github.com/portworx/kdmp/pkg/drivers/utils/utils.go +++ b/vendor/github.com/portworx/kdmp/pkg/drivers/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "context" "errors" "fmt" "os" @@ -12,6 +13,7 @@ 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" @@ -63,6 +65,8 @@ const ( PvcBoundSuccessMsg = "pvc bounded successfully" // PvcBoundFailedMsg pvc not bounded msg PvcBoundFailedMsg = "pvc not bounded" + // KopiaDebugModeEnabled - debug level log messages are enabled for kopia + KopiaDebugModeEnabled = "kopia-debug-mode" ) var ( @@ -876,3 +880,37 @@ 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) + } + return cmd +} + +func AddKopiaDebugModeCommand(cmd string) string { + splitCmd := strings.Split(cmd, " ") + splitCmd = append(splitCmd, "--log-level", "debug") + cmd = strings.Join(splitCmd, " ") + return cmd +} diff --git a/vendor/modules.txt b/vendor/modules.txt index af856480a7..bf295ce35b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1041,7 +1041,7 @@ github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 ## explicit github.com/pmezard/go-difflib/difflib -# github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 => github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 +# github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 => github.com/portworx/kdmp v0.4.1-0.20231210172248-55ce29ec9310 ## explicit; go 1.21 github.com/portworx/kdmp/pkg/apis/kdmp github.com/portworx/kdmp/pkg/apis/kdmp/v1alpha1 @@ -2479,7 +2479,7 @@ sigs.k8s.io/yaml # github.com/libopenstorage/autopilot-api => github.com/libopenstorage/autopilot-api v0.6.1-0.20210301232050-ca2633c6e114 # github.com/libopenstorage/openstorage => github.com/libopenstorage/openstorage v0.0.0-20230511212757-41751b27d69f # github.com/libopenstorage/secrets => github.com/libopenstorage/secrets v0.0.0-20220413195519-57d1c446c5e9 -# github.com/portworx/kdmp => github.com/portworx/kdmp v0.4.1-0.20231130175942-e8a1e0c64972 +# github.com/portworx/kdmp => github.com/portworx/kdmp v0.4.1-0.20231210172248-55ce29ec9310 # github.com/portworx/sched-ops => github.com/portworx/sched-ops v1.20.4-rc1.0.20230930052008-186afa1e82c4 # github.com/portworx/torpedo => github.com/portworx/torpedo v0.0.0-20231013194137-84e2957806f0 # gopkg.in/fsnotify.v1 v1.4.7 => github.com/fsnotify/fsnotify v1.4.7