remove unnecessary pointer
This commit is contained in:
parent
e2a4876ce4
commit
65b87d1c53
|
|
@ -12,7 +12,6 @@ import (
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"k8s.io/api/apps/v1beta1"
|
"k8s.io/api/apps/v1beta1"
|
||||||
batchv1beta1 "k8s.io/api/batch/v1beta1"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
policybeta1 "k8s.io/api/policy/v1beta1"
|
policybeta1 "k8s.io/api/policy/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
@ -84,7 +83,6 @@ type Cluster struct {
|
||||||
processMu sync.RWMutex // protects the current operation for reporting, no need to hold the master mutex
|
processMu sync.RWMutex // protects the current operation for reporting, no need to hold the master mutex
|
||||||
specMu sync.RWMutex // protects the spec for reporting, no need to hold the master mutex
|
specMu sync.RWMutex // protects the spec for reporting, no need to hold the master mutex
|
||||||
|
|
||||||
logicalBackupJob *batchv1beta1.CronJob // periodical logical backups independent from WAL archiving
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type compareStatefulsetResult struct {
|
type compareStatefulsetResult struct {
|
||||||
|
|
@ -1066,6 +1064,5 @@ func (c *Cluster) deleteLogicalBackupJob() error {
|
||||||
|
|
||||||
c.logger.Debug("removing the logical backup job")
|
c.logger.Debug("removing the logical backup job")
|
||||||
|
|
||||||
c.logicalBackupJob = nil
|
|
||||||
return c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Delete(c.getLogicalBackupJobName(), c.deleteOptions)
|
return c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Delete(c.getLogicalBackupJobName(), c.deleteOptions)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -614,17 +614,16 @@ func (c *Cluster) createLogicalBackupJob() (err error) {
|
||||||
|
|
||||||
c.setProcessName("creating a k8s cron job for logical backups")
|
c.setProcessName("creating a k8s cron job for logical backups")
|
||||||
|
|
||||||
cronJobSpec, err := c.generateLogicalBackupJob()
|
logicalBackupJobSpec, err := c.generateLogicalBackupJob()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not generate k8s cron job spec: %v", err)
|
return fmt.Errorf("could not generate k8s cron job spec: %v", err)
|
||||||
}
|
}
|
||||||
c.logger.Debugf("Generated cronJobSpec: %v", cronJobSpec)
|
c.logger.Debugf("Generated cronJobSpec: %v", logicalBackupJobSpec)
|
||||||
|
|
||||||
cronJob, err := c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Create(cronJobSpec)
|
_, err = c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Create(logicalBackupJobSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create k8s cron job: %v", err)
|
return fmt.Errorf("could not create k8s cron job: %v", err)
|
||||||
}
|
}
|
||||||
c.logicalBackupJob = cronJob
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -638,14 +637,13 @@ func (c *Cluster) patchLogicalBackupJob(newJob *batchv1beta1.CronJob) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the backup job spec
|
// update the backup job spec
|
||||||
job, err := c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Patch(
|
_, err = c.KubeClient.CronJobsGetter.CronJobs(c.Namespace).Patch(
|
||||||
c.logicalBackupJob.Name,
|
c.getLogicalBackupJobName(),
|
||||||
types.MergePatchType,
|
types.MergePatchType,
|
||||||
patchData, "")
|
patchData, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not patch logical backup job: %v", err)
|
return fmt.Errorf("could not patch logical backup job: %v", err)
|
||||||
}
|
}
|
||||||
c.logicalBackupJob = job
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ func (c *Cluster) patroniUsesKubernetes() bool {
|
||||||
func (c *Cluster) logLogicalBackupJobChanges(old, new *batchv1beta1.CronJob, reason string) {
|
func (c *Cluster) logLogicalBackupJobChanges(old, new *batchv1beta1.CronJob, reason string) {
|
||||||
|
|
||||||
c.logger.Infof("logical job %q is not in the desired state and needs to be updated",
|
c.logger.Infof("logical job %q is not in the desired state and needs to be updated",
|
||||||
c.logicalBackupJob.Name,
|
c.getLogicalBackupJobName(),
|
||||||
)
|
)
|
||||||
if reason != "" {
|
if reason != "" {
|
||||||
c.logger.Infof("reason: %s", reason)
|
c.logger.Infof("reason: %s", reason)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue