address 2nd part of code review
This commit is contained in:
parent
6dc97d6fc1
commit
587ff74bdd
|
|
@ -344,7 +344,7 @@ The operator logs reasons for a rolling update with the `info` level and a diff
|
||||||
|
|
||||||
## Logical backups
|
## Logical backups
|
||||||
|
|
||||||
The operator can manage k8s cron jobs to run logical backups of Postgres clusters. The cron job periodically spawns a batch job that runs a single pod. The backup script within this pod's container can connect to a DB for a logical backup. The operator updates cron jobs during Sync if the job schedule changes; the job name acts as the job identifier. Notes:
|
The operator can manage k8s cron jobs to run logical backups of Postgres clusters. The cron job periodically spawns a batch job that runs a single pod. The backup script within this pod's container can connect to a DB for a logical backup. The operator updates cron jobs during Sync if the job schedule changes; the job name acts as the job identifier. These jobs are to be enabled for each indvidual Postgres cluster by setting `enableLogicalBackup: true` in its manifest. Notes:
|
||||||
|
|
||||||
1. The provided `registry.opensource.zalan.do/acid/logical-backup` image implements the backup via `pg_dumpall` and upload of (compressed) results to an S3 bucket; `pg_dumpall` requires a `superuser` access to a DB and runs on the replica when possible.
|
1. The provided `registry.opensource.zalan.do/acid/logical-backup` image implements the backup via `pg_dumpall` and upload of (compressed) results to an S3 bucket; `pg_dumpall` requires a `superuser` access to a DB and runs on the replica when possible.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ type OperatorConfigurationUsers struct {
|
||||||
type Duration time.Duration
|
type Duration time.Duration
|
||||||
|
|
||||||
type OperatorLogicalBackupConfiguration struct {
|
type OperatorLogicalBackupConfiguration struct {
|
||||||
Enable bool `json:"enable_logical_backup,omitempty"`
|
|
||||||
Schedule string `json:"logical_backup_schedule,omitempty"`
|
Schedule string `json:"logical_backup_schedule,omitempty"`
|
||||||
DockerImage string `json:"logical_backup_docker_image,omitempty"`
|
DockerImage string `json:"logical_backup_docker_image,omitempty"`
|
||||||
S3Bucket string `json:"logical_backup_s3_bucket,omitempty"`
|
S3Bucket string `json:"logical_backup_s3_bucket,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,12 @@ func (c *Cluster) syncLogicalBackupJob() error {
|
||||||
return fmt.Errorf("could not generate the desired logical backup job state: %v", err)
|
return fmt.Errorf("could not generate the desired logical backup job state: %v", err)
|
||||||
}
|
}
|
||||||
if match, reason := k8sutil.SameLogicalBackupJob(job, desiredJob); !match {
|
if match, reason := k8sutil.SameLogicalBackupJob(job, desiredJob); !match {
|
||||||
c.logLogicalBackupJobChanges(job, desiredJob, reason)
|
c.logger.Infof("logical job %q is not in the desired state and needs to be updated",
|
||||||
|
c.getLogicalBackupJobName(),
|
||||||
|
)
|
||||||
|
if reason != "" {
|
||||||
|
c.logger.Infof("reason: %s", reason)
|
||||||
|
}
|
||||||
if err = c.patchLogicalBackupJob(desiredJob); err != nil {
|
if err = c.patchLogicalBackupJob(desiredJob); err != nil {
|
||||||
return fmt.Errorf("could not update logical backup job to match desired state: %v", err)
|
return fmt.Errorf("could not update logical backup job to match desired state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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"
|
||||||
|
|
@ -484,13 +483,3 @@ func (c *Cluster) GetSpec() (*acidv1.Postgresql, error) {
|
||||||
func (c *Cluster) patroniUsesKubernetes() bool {
|
func (c *Cluster) patroniUsesKubernetes() bool {
|
||||||
return c.OpConfig.EtcdHost == ""
|
return c.OpConfig.EtcdHost == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getLogicalBackupJobName(),
|
|
||||||
)
|
|
||||||
if reason != "" {
|
|
||||||
c.logger.Infof("reason: %s", reason)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,6 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||||
result.ScalyrCPULimit = fromCRD.Scalyr.ScalyrCPULimit
|
result.ScalyrCPULimit = fromCRD.Scalyr.ScalyrCPULimit
|
||||||
result.ScalyrMemoryLimit = fromCRD.Scalyr.ScalyrMemoryLimit
|
result.ScalyrMemoryLimit = fromCRD.Scalyr.ScalyrMemoryLimit
|
||||||
|
|
||||||
result.EnableLogicalBackup = fromCRD.LogicalBackup.Enable
|
|
||||||
result.LogicalBackupSchedule = fromCRD.LogicalBackup.Schedule
|
result.LogicalBackupSchedule = fromCRD.LogicalBackup.Schedule
|
||||||
result.LogicalBackupDockerImage = fromCRD.LogicalBackup.DockerImage
|
result.LogicalBackupDockerImage = fromCRD.LogicalBackup.DockerImage
|
||||||
result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket
|
result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ type Scalyr struct {
|
||||||
|
|
||||||
// LogicalBackup
|
// LogicalBackup
|
||||||
type LogicalBackup struct {
|
type LogicalBackup struct {
|
||||||
EnableLogicalBackup bool `name:"enable_logical_backup" default:"false"`
|
|
||||||
LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"`
|
LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"`
|
||||||
LogicalBackupDockerImage string `name:"logical_backup_docker_image" default:"registry.opensource.zalan.do/acid/logical-backup"`
|
LogicalBackupDockerImage string `name:"logical_backup_docker_image" default:"registry.opensource.zalan.do/acid/logical-backup"`
|
||||||
LogicalBackupS3Bucket string `name:"logical_backup_s3_bucket" default:""`
|
LogicalBackupS3Bucket string `name:"logical_backup_s3_bucket" default:""`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue