Skip to content

Conversation

@pooknull
Copy link
Contributor

@pooknull pooknull commented Oct 27, 2025

K8SPS-498 Powered by Pull Request Badge

https://perconadev.atlassian.net/browse/K8SPS-498

DESCRIPTION

This PR fixes 2 issues:

  1. Removes the ...get statefulset: ... error during cluster deployment.
  2. Fixes .status.mysql.imageID constantly appearing and disappearing.

It also reduces the risk of writing an outdated status by introducing updateStatus function into writeStatus. This way writeStatus will update .status based on the latest .status state.

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

Copilot AI review requested due to automatic review settings October 27, 2025 09:35
@pull-request-size pull-request-size bot added the size/L 100-499 lines label Oct 27, 2025
Copy link
Contributor

Copilot AI left a comment

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 refactors status update operations to use a callback-based approach, preventing race conditions and ensuring atomic status updates. The changes address K8SPS-498 by modifying the writeStatus function to accept an update callback instead of a complete status object.

Key changes:

  • Modified writeStatus to use a callback function that operates on a fresh copy of the CR
  • Updated all status update call sites to use the new callback pattern
  • Removed an unnecessary Get call in EnsureComponent

Reviewed Changes

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

File Description
pkg/k8s/utils.go Removed redundant object retrieval before creating PodDisruptionBudget
pkg/controller/ps/version.go Converted direct status field assignments to use callback-based writeStatus calls
pkg/controller/ps/status.go Refactored writeStatus to accept update callback and rewrote reconcileCRStatus to use callback pattern
pkg/controller/ps/controller.go Updated bootstrap status reconciliation to use new callback-based status update pattern

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

@pooknull
Copy link
Contributor Author

The merge conflicts will be resolved after #1139 merge

@pooknull pooknull marked this pull request as ready for review October 27, 2025 10:23
Copilot AI review requested due to automatic review settings October 28, 2025 11:46
Copy link
Contributor

Copilot AI left a comment

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 5 out of 5 changed files in this pull request and generated 4 comments.


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

// It writes the `scripts[execCount].stdout`, `scripts[execCount].stderr` to `stdin` and `stderr` parameters.
// fakeClient should have the array of fakeClientScript objects in order they are going to be executed in the tested function.
func (c *fakeClient) Exec(_ context.Context, _ *corev1.Pod, _ string, command []string, stdin io.Reader, stdout, stderr io.Writer, _ bool) error {
fmt.Println("TEST", command)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Debug print statement should be removed before merging to production. This appears to be leftover debugging code.

Suggested change
fmt.Println("TEST", command)

Copilot uses AI. Check for mistakes.
Comment on lines -313 to -315
if err := cl.Get(ctx, client.ObjectKeyFromObject(obj), obj); err != nil {
return errors.Wrap(err, "get statefulset")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to understand why we performed this get before. Do we still have the context of that decision?

Copy link
Contributor Author

@pooknull pooknull Oct 29, 2025

Choose a reason for hiding this comment

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

It was introduced in the #991 to set owner references for pdb. But #1073 changed the owner and didn't remove the Get call

Copy link
Contributor

@egegunes egegunes left a comment

Choose a reason for hiding this comment

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

LGTM, but please check @gkech and copilot comments

Copilot AI review requested due to automatic review settings October 29, 2025 11:35
Copy link
Contributor

Copilot AI left a comment

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 5 out of 5 changed files in this pull request and generated 1 comment.


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

Copy link
Contributor

Copilot AI left a comment

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 6 out of 6 changed files in this pull request and generated 1 comment.


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

if err != nil {
return errors.Wrap(err, "get MySQL status")
}
mysqlStatus.ImageID = status.MySQL.ImageID
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The ImageID field is being manually preserved from the existing status, but this is fragile. If other fields need to be preserved in the future, they must also be manually copied. Consider having appStatus accept the existing status and preserve fields that shouldn't be recomputed, or document clearly why ImageID needs special handling.

Copilot uses AI. Check for mistakes.
@JNKPercona
Copy link
Collaborator

Test Name Result Time
async-ignore-annotations-8-4 passed 00:06:25
async-global-metadata-8-4 passed 00:15:33
async-upgrade-8-0 passed 00:12:43
async-upgrade-8-4 passed 00:12:35
auto-config-8-4 passed 00:24:45
config-8-4 passed 00:16:51
config-router-8-0 passed 00:07:16
config-router-8-4 passed 00:07:32
demand-backup-minio-8-0 passed 00:20:11
demand-backup-minio-8-4 passed 00:19:42
demand-backup-cloud-8-4 passed 00:22:28
async-data-at-rest-encryption-8-0 passed 00:13:55
async-data-at-rest-encryption-8-4 passed 00:14:12
gr-global-metadata-8-4 passed 00:15:22
gr-data-at-rest-encryption-8-0 passed 00:14:28
gr-data-at-rest-encryption-8-4 passed 00:14:53
gr-demand-backup-minio-8-4 passed 00:12:17
gr-demand-backup-cloud-8-4 passed 00:21:39
gr-demand-backup-haproxy-8-4 passed 00:09:52
gr-finalizer-8-4 passed 00:05:52
gr-haproxy-8-0 passed 00:04:21
gr-haproxy-8-4 passed 00:04:10
gr-ignore-annotations-8-4 passed 00:04:39
gr-init-deploy-8-0 passed 00:09:53
gr-init-deploy-8-4 passed 00:09:25
gr-one-pod-8-4 passed 00:07:11
gr-recreate-8-4 passed 00:17:09
gr-scaling-8-4 passed 00:08:02
gr-scheduled-backup-8-4 passed 00:16:20
gr-security-context-8-4 passed 00:10:05
gr-self-healing-8-4 passed 00:28:56
gr-tls-cert-manager-8-4 passed 00:08:58
gr-users-8-4 passed 00:05:24
gr-upgrade-8-0 passed 00:09:07
gr-upgrade-8-4 passed 00:09:19
haproxy-8-0 passed 00:08:51
haproxy-8-4 passed 00:08:22
init-deploy-8-0 passed 00:05:34
init-deploy-8-4 passed 00:05:45
limits-8-4 passed 00:06:27
monitoring-8-4 passed 00:14:01
one-pod-8-0 passed 00:05:52
one-pod-8-4 passed 00:05:23
operator-self-healing-8-4 passed 00:11:23
pvc-resize-8-4 passed 00:07:45
recreate-8-4 passed 00:12:53
scaling-8-4 passed 00:10:24
scheduled-backup-8-0 passed 00:14:21
scheduled-backup-8-4 passed 00:16:16
service-per-pod-8-4 passed 00:06:32
sidecars-8-4 passed 00:04:32
smart-update-8-4 passed 00:09:31
storage-8-4 passed 00:04:02
telemetry-8-4 passed 00:06:09
tls-cert-manager-8-4 passed 00:10:19
users-8-0 passed 00:08:24
users-8-4 passed 00:07:35
version-service-8-4 passed 00:19:56
Summary Value
Tests Run 58/58
Job Duration 01:46:00
Total Test Time 10:52:16

commit: 32b9210
image: perconalab/percona-server-mysql-operator:PR-1140-32b92103

@hors hors merged commit 16ee670 into main Oct 31, 2025
22 checks passed
@hors hors deleted the K8SPS-498-fix branch October 31, 2025 08:18
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.

6 participants