Description
Overview
The upgrade operator should validate the length of the PGUpgrade name and the PostgreCluster name before starting the upgrade process.
Unvalidated this might run into the issue that the Job which is created during the upgrade has a name which is longer than 63 characters. This will essentially break the upgrade process and leave the user with a broken Cluster.
Environment
Please provide the following details:
- Platform:
Kubernetes
- Platform Version:
1.24.x
- PGO Image Tag:
ubi8-5.3.0-0
- Postgres Version
13
(upgrading to14
- Storage: - not relevant-
Steps to Reproduce
REPRO
- Create a PostgresCluster with the following name
db-1d8a9b06-696d-4e3f-8db5
andpostgresVersion: 13
- Create a PGUpgrade object with the following name
db-1d8a9b06-696d-4e3f-8db5-1314upgrade
The resulting job name during the upgrade would be (80characters): db-1d8a9b06-696d-4e3f-8db5-1314upgrade-db-1d8a9b06-696d-4e3f-8db5-instance1-abcd
EXPECTED
The postgres-operator-upgrade should validate the PGUpgrade metadata.name before starting the upgrade and print a ERROR without stating the upgrade.
OR
The postgres-operator-upgrade could be registered as validatingwebhookconfiguration and create a error before the related PGUpgrade object is created.
ACTUAL
The postgres-operator-upgrade controller will run into errors and stops the upgrade process in the middle.
Logs
1.6763749073794844e+09 ERROR Reconciler error {"controller": "pgupgrade", "controllerGroup": "postgres-operator.crunchydata.com", "controllerKind": "PGUpgrade", "pGUpgrade": {"name":"db-1d8a9b06-696d-4e3f-8db5-1314upgrade","namespace":"database"}, "namespace": "database", "name": "db-1d8a9b06-696d-4e3f-8db5-1314upgrade", "reconcileID": "d634458d-77bd-4f53-9e9b-dcbeaeec902d", "error": "Job.batch \"db-1d8a9b06-696d-4e3f-8db5-1314upgrade-db-1d8a9b06-696d-4e3f-8db5-instance1-abcd\" is invalid: spec.template.labels: Invalid value: \"db-1d8a9b06-696d-4e3f-8db5-1314upgrade-db-1d8a9b06-696d-4e3f-8db5-instance1-abcd\": must be no more than 63 characters"}