Skip to content

K8SPXC-1835 | status condition improvements#2480

Draft
mayankshah1607 wants to merge 6 commits into
mainfrom
K8SPXC-1835
Draft

K8SPXC-1835 | status condition improvements#2480
mayankshah1607 wants to merge 6 commits into
mainfrom
K8SPXC-1835

Conversation

@mayankshah1607

@mayankshah1607 mayankshah1607 commented May 14, 2026

Copy link
Copy Markdown
Member

CHANGE DESCRIPTION

Revamps status conditions and adds some new condition types:

	ConditionTLSEnabled     string = "TLSEnabled"
	ConditionErrorReconcile string = "ErrorReconcile"
	ConditionProxyReady     string = "ProxyReady"
	ConditionPXCReady       string = "PXCReady"
	ConditionPaused         string = "ClusterPaused"
	ConditionVolumeResizing string = "VolumeResizing"

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?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

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 PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Copilot AI review requested due to automatic review settings May 14, 2026 13:04
@pull-request-size pull-request-size Bot added the size/L 100-499 lines label May 14, 2026

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 revamps PerconaXtraDBCluster status conditions by migrating from the operator’s legacy ClusterCondition/annotation-based tracking to Kubernetes-native metav1.Condition, and introduces new condition types (TLS enabled, reconcile error, component readiness, paused, volume resizing) to improve status signaling.

Changes:

  • Migrate .status.conditions to []metav1.Condition and update status-writing logic to set/remove the new condition types.
  • Replace PVC resize progress tracking from CR annotations to a VolumeResizing status condition (and adjust related logic/tests).
  • Add legacy-condition cleanup/normalization paths (notably for the old "tls" condition) and update CRD schemas accordingly.

Reviewed changes

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

Show a summary per file
File Description
pkg/naming/condition.go Updates TLS condition state helper to return metav1.ConditionStatus.
pkg/controller/pxc/volumes.go Switches PVC resize in-progress tracking from annotations to a status condition.
pkg/controller/pxc/volumes_test.go Updates tests to use status conditions for resize in-progress setup/verification.
pkg/controller/pxc/tls.go Adds legacy TLS condition normalization and migrates TLS condition handling to metav1.Condition.
pkg/controller/pxc/status.go Reworks status condition updates to use new condition types and meta.Set/RemoveStatusCondition.
pkg/apis/pxc/v1/zz_generated.deepcopy.go Regenerates deepcopy for []metav1.Condition status field.
pkg/apis/pxc/v1/pxc_types.go Adds new condition type constants; changes status conditions field type; removes legacy condition helpers; updates PVC resize detection.
deploy/cw-bundle.yaml Updates CRD schema for metav1.Condition fields/validation.
deploy/crd.yaml Updates CRD schema for metav1.Condition fields/validation.
deploy/bundle.yaml Updates CRD schema for metav1.Condition fields/validation.
config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml Updates CRD base schema for metav1.Condition fields/validation.
Files not reviewed (1)
  • pkg/apis/pxc/v1/zz_generated.deepcopy.go: Language not supported
Comments suppressed due to low confidence (1)

pkg/controller/pxc/status.go:72

  • updateStatus always removes ConditionErrorReconcile, but only re-adds it when cr.Status.Status != AppStateError. If reconciles keep failing after the first error, the condition gets cleared even though reconcileErr != nil, losing the error condition and making status inconsistent. Consider setting ConditionErrorReconcile=True unconditionally whenever reconcileErr != nil (updating message/reason as needed), or at least avoid removing it in the error path.
func (r *ReconcilePerconaXtraDBCluster) updateStatus(ctx context.Context, cr *api.PerconaXtraDBCluster, inProgress bool, reconcileErr error) (err error) {
	cleanupLegacyConditions(cr)

	meta.RemoveStatusCondition(&cr.Status.Conditions, api.ConditionErrorReconcile)
	if reconcileErr != nil {
		if cr.Status.Status != api.AppStateError {
			meta.SetStatusCondition(&cr.Status.Conditions, metav1.Condition{
				Type:    api.ConditionErrorReconcile,
				Status:  metav1.ConditionTrue,
				Reason:  "Error",
				Message: reconcileErr.Error(),
			})
			cr.Status.Messages = append(cr.Status.Messages, "Error: "+reconcileErr.Error())
			cr.Status.Status = api.AppStateError
		}

		return r.writeStatus(ctx, cr)
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controller/pxc/tls.go
Comment on lines +489 to +506
func normalizeLegacyTLSCondition(cr *api.PerconaXtraDBCluster) {
for i, cond := range cr.Status.Conditions {
if cond.Type == "tls" {
updated := metav1.Condition{
Type: api.ConditionTLSEnabled,
LastTransitionTime: cond.LastTransitionTime,
Status: metav1.ConditionFalse,
Message: "ReconcileTLSToggle",
Reason: "ReconcileTLSToggle",
}
if cond.Status == "enabled" {
updated.Status = metav1.ConditionTrue
}
cr.Status.Conditions[i] = updated
return
}
}
}
Status: metav1.ConditionTrue,
Reason: "VolumeResizing",
Message: "Volume resizing in progress",
})
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
auto-tuning-8-0 passed 00:22:35
allocator-8-0 passed 00:15:16
allocator-8-4 passed 00:14:10
backup-storage-tls-8-0 passed 00:25:49
cross-site-8-0 passed 00:39:02
cross-site-proxysql-8-0 passed 00:45:35
cross-site-proxysql-8-4 passed 00:43:31
custom-users-8-0 passed 00:14:59
demand-backup-cloud-8-0 passed 01:07:26
demand-backup-cloud-8-4 passed 01:07:06
demand-backup-cloud-pxb-8-0 passed 01:05:19
demand-backup-encrypted-with-tls-5-7 failure 01:11:48
demand-backup-encrypted-with-tls-8-0 passed 00:55:22
demand-backup-encrypted-with-tls-8-4 passed 00:54:08
demand-backup-encrypted-with-tls-pxb-5-7 passed 00:20:19
demand-backup-encrypted-with-tls-pxb-8-0 passed 00:25:20
demand-backup-encrypted-with-tls-pxb-8-4 passed 00:19:55
demand-backup-8-0 passed 00:49:11
demand-backup-flow-control-8-0 passed 00:15:15
demand-backup-flow-control-8-4 passed 00:12:27
demand-backup-parallel-8-0 passed 00:11:24
demand-backup-parallel-8-4 passed 00:10:35
demand-backup-without-passwords-8-0 passed 00:22:05
demand-backup-without-passwords-8-4 passed 00:17:58
extra-pvc-8-0 passed 00:29:35
haproxy-5-7 passed 00:17:35
haproxy-8-0 passed 00:19:06
haproxy-8-4 passed 00:17:13
init-deploy-5-7 passed 00:18:43
init-deploy-8-0 passed 00:21:31
limits-8-0 passed 00:17:18
monitoring-2-0-8-0 passed 00:27:27
monitoring-pmm3-8-0 passed 00:20:10
monitoring-pmm3-8-4 passed 00:20:33
one-pod-5-7 passed 00:18:54
one-pod-8-0 passed 00:18:54
pitr-8-0 passed 01:12:53
pitr-8-4 passed 01:11:43
pitr-pxb-8-0 failure 00:34:08
pitr-pxb-8-4 failure 00:35:52
pitr-gap-errors-8-0 passed 00:56:38
pitr-gap-errors-8-4 failure 00:58:57
proxy-protocol-8-0 passed 00:15:59
proxy-switch-8-0 passed 00:15:09
proxysql-sidecar-res-limits-8-0 passed 00:12:40
proxysql-scheduler-8-0 passed 00:30:04
pvc-resize-5-7 failure 00:22:05
pvc-resize-8-0 failure 00:21:39
recreate-8-0 passed 00:20:59
restore-to-encrypted-cluster-8-0 passed 00:31:22
restore-to-encrypted-cluster-8-4 passed 00:33:08
restore-to-encrypted-cluster-pxb-8-0 passed 00:20:15
restore-to-encrypted-cluster-pxb-8-4 passed 00:18:12
scaling-proxysql-8-0 passed 00:13:50
scaling-8-0 passed 00:15:15
scheduled-backup-5-7 passed 01:05:04
scheduled-backup-8-0 failure 00:00:46
scheduled-backup-8-4 passed 01:09:15
security-context-8-0 passed 00:29:08
smart-update1-8-0 passed 00:38:47
smart-update1-8-4 passed 00:38:52
smart-update2-8-0 passed 00:43:25
smart-update2-8-4 passed 00:43:01
smart-update3-8-0 passed 00:18:40
sst-retry-limit-8-0 passed 00:14:58
sst-retry-limit-8-4 passed 00:18:31
storage-8-0 passed 00:12:46
tls-issue-cert-manager-ref-8-0 passed 00:10:35
tls-issue-cert-manager-8-0 failure 00:14:11
tls-issue-self-8-0 failure 00:05:52
upgrade-consistency-8-0 passed 00:12:49
upgrade-consistency-8-4 passed 00:15:02
upgrade-haproxy-5-7 passed 00:27:10
upgrade-haproxy-8-0 passed 00:28:17
upgrade-proxysql-5-7 passed 00:19:43
upgrade-proxysql-8-0 passed 00:19:20
users-5-7 failure 00:00:45
users-8-0 failure 00:12:48
users-scheduler-8-4 failure 00:13:34
validation-hook-8-0 failure 00:04:27
Summary Value
Tests Run 80/80
Job Duration 04:08:56
Total Test Time 37:12:46

commit: 98f4e09
image: perconalab/percona-xtradb-cluster-operator:PR-2480-98f4e09b

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

Labels

size/L 100-499 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants