adjust deletion and cronjob conf
This commit is contained in:
parent
2d720c9a2a
commit
dc2f7072c7
|
|
@ -642,6 +642,12 @@ func (c *Cluster) Delete() {
|
|||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
// delete the backup job before the stateful set of the cluster to prevent connections to non-existing pods
|
||||
// deleting the cron job also removes pods and batch jobs it created
|
||||
if err := c.deleteLogicalBackupJob(); err != nil {
|
||||
c.logger.Warningf("could not remove the logical backup k8s cron job; %v", err)
|
||||
}
|
||||
|
||||
if err := c.deleteStatefulSet(); err != nil {
|
||||
c.logger.Warningf("could not delete statefulset: %v", err)
|
||||
}
|
||||
|
|
@ -675,10 +681,6 @@ func (c *Cluster) Delete() {
|
|||
c.logger.Warningf("could not remove leftover patroni objects; %v", err)
|
||||
}
|
||||
|
||||
if err := c.deleteLogicalBackupJob(); err != nil {
|
||||
c.logger.Warningf("could not remove the logical backup k8s cron job; %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//NeedsRepair returns true if the cluster should be included in the repair scan (based on its in-memory status).
|
||||
|
|
|
|||
|
|
@ -1265,6 +1265,10 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
|||
|
||||
c.logger.Debug("Generating logical backup pod template")
|
||||
|
||||
// NB: a cron job creates standard batch jobs according to schedule; these batch jobs manage pods/clean-up
|
||||
|
||||
// configure a pod of a batch job
|
||||
|
||||
defaultResources := c.makeDefaultResources()
|
||||
resourceRequirements, err = generateResourceRequirements(c.Spec.Resources, defaultResources)
|
||||
if err != nil {
|
||||
|
|
@ -1320,11 +1324,17 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
|||
|
||||
podTemplate.Spec.Affinity = &podAffinity
|
||||
|
||||
// affects containers within a pod on the same node
|
||||
// affects containers within a pod
|
||||
// pods of k8s jobs support only "OnFailure" or "Never"
|
||||
podTemplate.Spec.RestartPolicy = "Never"
|
||||
|
||||
jobSpec := batchv1.JobSpec{Template: *podTemplate}
|
||||
// configure a batch job
|
||||
|
||||
jobSpec := batchv1.JobSpec{
|
||||
Template: *podTemplate,
|
||||
}
|
||||
|
||||
// configure a cron job
|
||||
|
||||
jobTemplateSpec := batchv1beta1.JobTemplateSpec{
|
||||
Spec: jobSpec,
|
||||
|
|
@ -1342,8 +1352,9 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
|||
Labels: c.labelsSet(true),
|
||||
},
|
||||
Spec: batchv1beta1.CronJobSpec{
|
||||
Schedule: schedule,
|
||||
JobTemplate: jobTemplateSpec,
|
||||
Schedule: schedule,
|
||||
JobTemplate: jobTemplateSpec,
|
||||
ConcurrencyPolicy: batchv1beta1.ForbidConcurrent,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue