Minor code changes
This commit is contained in:
parent
eb82078f99
commit
a73b986b45
|
|
@ -490,7 +490,8 @@ func compareResoucesAssumeFirstNotNil(a *v1.ResourceRequirements, b *v1.Resource
|
|||
}
|
||||
|
||||
// Update changes Kubernetes objects according to the new specification. Unlike the sync case, the missing object.
|
||||
// (i.e. service) is treated as an error.
|
||||
// (i.e. service) is treated as an error
|
||||
// logical backup cron jobs are an exception: they can be freely created/deleted by users
|
||||
func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
||||
updateFailed := false
|
||||
|
||||
|
|
@ -580,8 +581,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
|
|||
// logical backup job
|
||||
func() {
|
||||
|
||||
// special case: create if not existed before
|
||||
// with all other k8s entities a missing object causes an error during update
|
||||
// create if it did not exist
|
||||
if newSpec.Spec.EnableLogicalBackup && !oldSpec.Spec.EnableLogicalBackup {
|
||||
c.logger.Debugf("creating backup cron job")
|
||||
if err := c.createLogicalBackupJob(); err != nil {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
clientbatchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
|
||||
|
||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policybeta1 "k8s.io/api/policy/v1beta1"
|
||||
apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
|
||||
apiextbeta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
|
||||
|
|
@ -147,6 +147,10 @@ func SamePDB(cur, new *policybeta1.PodDisruptionBudget) (match bool, reason stri
|
|||
return
|
||||
}
|
||||
|
||||
func getJobImage(cronJob *batchv1beta1.CronJob) string {
|
||||
return cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image
|
||||
}
|
||||
|
||||
// SameCronJob compares Specs of logical backup cron jobs
|
||||
func SameCronJob(cur, new *batchv1beta1.CronJob) (match bool, reason string) {
|
||||
|
||||
|
|
@ -155,11 +159,11 @@ func SameCronJob(cur, new *batchv1beta1.CronJob) (match bool, reason string) {
|
|||
new.Spec.Schedule, cur.Spec.Schedule)
|
||||
}
|
||||
|
||||
newImage := new.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image
|
||||
oldImage := cur.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Image
|
||||
if newImage != oldImage {
|
||||
newImage := getJobImage(new)
|
||||
curImage := getJobImage(cur)
|
||||
if newImage != curImage {
|
||||
return false, fmt.Sprintf("new job's image %q doesn't match the current one %q",
|
||||
newImage, oldImage)
|
||||
newImage, curImage)
|
||||
}
|
||||
|
||||
return true, ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue