Skip to content

Commit

Permalink
check pg version (#2342)
Browse files Browse the repository at this point in the history
Fixes #1678

Signed-off-by: Jan Jansen <jan.jansen@gdata.de>
  • Loading branch information
farodin91 authored Aug 10, 2023
1 parent 5b310ce commit 7372e91
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ func getJobImage(cronJob *batchv1.CronJob) string {
return cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image
}

func getPgVersion(cronJob *batchv1.CronJob) string {
envs := cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env
for _, env := range envs {
if env.Name == "PG_VERSION" {
return env.Value
}
}
return ""
}

// SameLogicalBackupJob compares Specs of logical backup cron jobs
func SameLogicalBackupJob(cur, new *batchv1.CronJob) (match bool, reason string) {

Expand All @@ -243,6 +253,13 @@ func SameLogicalBackupJob(cur, new *batchv1.CronJob) (match bool, reason string)
newImage, curImage)
}

newPgVersion := getPgVersion(new)
curPgVersion := getPgVersion(cur)
if newPgVersion != curPgVersion {
return false, fmt.Sprintf("new job's env PG_VERSION %q does not match the current one %q",
newPgVersion, curPgVersion)
}

return true, ""
}

Expand Down

0 comments on commit 7372e91

Please sign in to comment.