Skip to content

Commit

Permalink
pb-5288: Added changes to read the istio disable config from px-backu…
Browse files Browse the repository at this point in the history
…p-config for delete and maintenance apis.

go
  • Loading branch information
sivakumar subraani committed Jan 28, 2024
1 parent 55fdc82 commit 0a159c3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/drivers/kopiadelete/kopiadelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func addJobLabels(labels map[string]string, jobOpts drivers.JobOpts) map[string]
labels[drivers.DriverNameLabel] = drivers.KopiaDelete
labels[utils.BackupObjectNameKey] = utils.GetValidLabel(jobOpts.BackupObjectName)
labels[utils.BackupObjectUIDKey] = jobOpts.BackupObjectUID
labels = utils.SetDisableIstioLabel(labels)
labels = utils.SetPxBackupDisableIstioLabel(labels)
return labels
}

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 @@ -435,7 +435,7 @@ func addJobLabels(labels map[string]string) map[string]string {
}

labels[drivers.DriverNameLabel] = drivers.KopiaMaintenance
labels = utils.SetDisableIstioLabel(labels)
labels = utils.SetPxBackupDisableIstioLabel(labels)
return labels
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/nfsdelete/nfsdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func addJobLabels(labels map[string]string, jobOpts drivers.JobOpts) map[string]
labels[drivers.DriverNameLabel] = drivers.NFSDelete
labels[utils.BackupObjectNameKey] = jobOpts.BackupObjectName
labels[utils.BackupObjectUIDKey] = jobOpts.BackupObjectUID
labels = utils.SetDisableIstioLabel(labels)
labels = utils.SetPxBackupDisableIstioLabel(labels)
return labels
}

Expand Down
41 changes: 39 additions & 2 deletions pkg/drivers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ import (
)

const (
defaultPXNamespace = "kube-system"
// BackupConfigMap holds any config needs to be provided to job
// from the caller. Eg: executor image name, secret, etc..
BackupConfigMap = "px-backup-config"
// PXBackupNamespace where px backup is running
PxBackupNamespace = "PX_BACKUP_NAMESPACE"
// DefaultInstallNamespace default namespace where px-backup will be installed
DefaultInstallNamespace = "px-backup"
defaultPXNamespace = "kube-system"
// KdmpConfig defines the config map name of kdmp module
KdmpConfig = "kdmp-config"
// TriggeredFromStork - denotes the kopia job is triggered from stork module
Expand Down Expand Up @@ -881,7 +888,7 @@ func IsJobPodMountFailed(job *batchv1.Job, namespace string) bool {
func GetDisableIstioConfig() bool {
kdmpData, err := core.Instance().GetConfigMap(KdmpConfigmapName, KdmpConfigmapNamespace)
if err != nil {
logrus.Tracef("error readig kdmp config map: %v", err)
logrus.Tracef("error reading kdmp config map: %v", err)
return false
}
if disableIstioConfig, ok := kdmpData.Data[drivers.KdmpDisableIstioConfig]; ok && disableIstioConfig == "true" {
Expand All @@ -898,3 +905,33 @@ func SetDisableIstioLabel(labels map[string]string) map[string]string {
}
return labels
}

func GetPxBackupDisableIstioConfig() bool {
kdmpData, err := core.Instance().GetConfigMap(BackupConfigMap, GetPxBackupNamespace())
if err != nil {
logrus.Tracef("error reading pxbackup config map: %v", err)
return false
}
if disableIstioConfig, ok := kdmpData.Data[drivers.KdmpDisableIstioConfig]; ok && disableIstioConfig == "true" {
return true
}

return false
}

func SetPxBackupDisableIstioLabel(labels map[string]string) map[string]string {
disableIstioConfig := GetPxBackupDisableIstioConfig()
if disableIstioConfig {
labels[IstioInjectLabel] = "false"
}
return labels
}

// GetPxBackupNamespace returns namespace of px-backup deployment.
func GetPxBackupNamespace() string {
ns := os.Getenv(PxBackupNamespace)
if ns == "" {
return DefaultInstallNamespace
}
return ns
}

0 comments on commit 0a159c3

Please sign in to comment.