Skip to content

Commit 7372e91

Browse files
authored
check pg version (#2342)
Fixes #1678 Signed-off-by: Jan Jansen <[email protected]>
1 parent 5b310ce commit 7372e91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/util/k8sutil/k8sutil.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ func getJobImage(cronJob *batchv1.CronJob) string {
228228
return cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image
229229
}
230230

231+
func getPgVersion(cronJob *batchv1.CronJob) string {
232+
envs := cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env
233+
for _, env := range envs {
234+
if env.Name == "PG_VERSION" {
235+
return env.Value
236+
}
237+
}
238+
return ""
239+
}
240+
231241
// SameLogicalBackupJob compares Specs of logical backup cron jobs
232242
func SameLogicalBackupJob(cur, new *batchv1.CronJob) (match bool, reason string) {
233243

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

256+
newPgVersion := getPgVersion(new)
257+
curPgVersion := getPgVersion(cur)
258+
if newPgVersion != curPgVersion {
259+
return false, fmt.Sprintf("new job's env PG_VERSION %q does not match the current one %q",
260+
newPgVersion, curPgVersion)
261+
}
262+
246263
return true, ""
247264
}
248265

0 commit comments

Comments
 (0)