postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Option to define the cronjob name for backups pgo 5.0.4

Open Schmaetz opened this issue 2 years ago • 2 comments

Overview

Add an option to set the name of the cronjobs of the backups individually.

Use Case

Since cronjobs are limited to 52 characters in Kubernetes, we have problems with the cronjob name of the backups. For this reason, it would be great if these names could be defined by the user. Adding pgbackrest-REPONAME-BACKUPTYPE provides some additional characters, which then often break the limit :)

Desired Behavior

In the cluster definition, a field could be added which is optional and contains the name of the cronjob to be created when entered.

Environment

Tell us about your environment:

Please provide the following details:

  • Platform: OpenShift
  • Platform Version: 5.0.4
  • PGO Image Tag: (e.g. centos8-5.0.4-0)
  • Postgres Version (e.g. 14): 13, 14

Additional Information

Please provide any additional information that may be helpful.

Schmaetz avatar Mar 01 '22 12:03 Schmaetz

Hello, we're discussing possible solutions to overly long names (and labels), as this is not isolated to cronjob names. In the meantime, we're truncating our cronjob name by dropping the pgbackrest- infix (in this PR), so hopefully those 11 characters help free up some space!

Or have you worked out another workaround and/or what's the length of your clusters' names that are causing the issue?

benjaminjb avatar Mar 29 '22 21:03 benjaminjb

Hi @benjaminjb, Thank you for your answer. Yes, the issue with limited characters is particularly tricky with some Kubernetes resources, but with the addition of pgbackrest it occurs extremely quickly with the cronjobs.

My thought would have been either the following: Name: cluster.Name + "-" + repoName + "-" + backuptype[0:1], saving: 15 characters

Alternatively, however, I wonder whether an assignment of the name is absolutely necessary. Why not create a base32-string or similar from the cluster name and use it: base32 string + "-" + repoName + "-" + backuptype I would then simply set the cluster name via label and an assignment would be given.

To solve the problem, I switched to shortened clusternames in the cronjob and then directly limited the cluster name kubernetes-wide for new clusters. I shorten the cluster name to x characters and append a 4-character random value to ensure that the cluster names are unique.

Many greetings

Schmaetz avatar Mar 30 '22 09:03 Schmaetz

@Schmaetz Thank you for the additional information. As mentioned above, PR #3106 shortened the generated scheduled backup CronJob names by removing pgbackrest-. This should allow for reasonable PostgresCluster names and meet your use case.

tjmoore4 avatar Sep 27 '22 14:09 tjmoore4