Skip to content

K8SPG-1058: Fix failing pgupgrade if names are too long#1649

Open
Kajot-dev wants to merge 3 commits into
percona:mainfrom
Kajot-dev:fix/failing-pg-upgrade
Open

K8SPG-1058: Fix failing pgupgrade if names are too long#1649
Kajot-dev wants to merge 3 commits into
percona:mainfrom
Kajot-dev:fix/failing-pg-upgrade

Conversation

@Kajot-dev

Copy link
Copy Markdown
Contributor

CHANGE DESCRIPTION

Problem:
When the pgupgrade name/cluster name is too long the generated job names for pgupgrade will exceed 63 characters and upgrade will silently fail (visible in the logs, but not visible by the user, which sees the upgrade as indefinietely progressing)

Solution:
We need to trim the name (and preserve uniqueness) to

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

Signed-off-by: jjaruszewski <jjaruszewski@man.poznan.pl>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses pgupgrade Jobs silently failing when generated Kubernetes Job names exceed the DNS-1123 label limit (63 chars), by introducing DNS-safe naming helpers and switching pgupgrade Jobs to use a truncated/unique name approach.

Changes:

  • Added SafeDNSName / SafeDNSUniqueName helpers in internal/naming/dns.go to enforce the 63-character DNS label limit.
  • Updated pgupgrade and remove-data Job name generation to use the new DNS-safe unique naming helper.
  • Updated pgupgrade reconciliation to locate the upgrade Job by labels (instead of by deterministic name), and added a unit test for long upgrade names.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
internal/naming/dns.go Introduces helpers to truncate DNS label names and generate “unique” names under the 63-char limit.
internal/controller/pgupgrade/pgupgrade_controller.go Changes upgrade Job lookup logic to search Jobs by role label.
internal/controller/pgupgrade/jobs.go Switches pgupgrade/remove-data Job naming to use SafeDNSUniqueName.
internal/controller/pgupgrade/jobs_test.go Adds a unit test validating long-name Job generation stays within DNS limits.

Comment thread internal/controller/pgupgrade/pgupgrade_controller.go
Comment thread internal/naming/dns.go
Comment thread internal/controller/pgupgrade/jobs.go
Comment thread internal/controller/pgupgrade/jobs.go
Signed-off-by: jjaruszewski <jjaruszewski@man.poznan.pl>
Copilot AI review requested due to automatic review settings June 22, 2026 16:13
@Kajot-dev Kajot-dev force-pushed the fix/failing-pg-upgrade branch from f50582a to 57ffb08 Compare June 22, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread internal/naming/dns.go
Comment thread internal/controller/pgupgrade/jobs_test.go
Comment thread internal/naming/dns.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be great to have unit tests for new functions here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests

@egegunes egegunes changed the title Fix failing pgupgrade if names are too long K8SPG-1058: Fix failing pgupgrade if names are too long Jun 23, 2026
@egegunes egegunes added this to the v3.1.0 milestone Jun 23, 2026
Signed-off-by: Jakub Jaruszewski <jjaruszewski@man.poznan.pl>
@Kajot-dev Kajot-dev requested a review from egegunes June 23, 2026 11:51
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
backup-enable-disable passed 00:12:44
builtin-extensions passed 00:06:14
cert-manager-tls passed 00:09:36
custom-envs passed 00:18:05
custom-tls passed 00:07:35
database-init-sql passed 00:02:38
demand-backup passed 00:24:57
demand-backup-offline-snapshot passed 00:13:24
dynamic-configuration passed 00:03:22
finalizers passed 00:03:39
init-deploy passed 00:03:22
huge-pages passed 00:03:03
major-upgrade-14-to-15 passed 00:11:14
major-upgrade-15-to-16 passed 00:11:07
major-upgrade-16-to-17 passed 00:11:20
major-upgrade-17-to-18 passed 00:10:16
ldap passed 00:03:48
ldap-tls passed 00:05:51
monitoring passed 00:08:30
monitoring-pmm3 passed 00:09:18
one-pod passed 00:06:10
operator-self-healing passed 00:10:09
pitr passed 00:11:41
scaling passed 00:05:10
scheduled-backup passed 00:30:10
self-healing passed 00:09:02
sidecars passed 00:02:53
standby-pgbackrest passed 00:19:14
standby-streaming passed 00:12:58
start-from-backup passed 00:11:38
tablespaces passed 00:06:52
telemetry-transfer passed 00:04:27
upgrade-consistency passed 00:06:01
upgrade-minor passed 00:06:34
users passed 00:04:44
Summary Value
Tests Run 35/35
Job Duration 01:50:10
Total Test Time 05:28:04

commit: c1ea66c
image: perconalab/percona-postgresql-operator:PR-1649-c1ea66cac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants