Skip to content

Conversation

@MaciejKaras
Copy link
Collaborator

@MaciejKaras MaciejKaras commented Dec 17, 2025

Summary

We are ignoring namespaces when listing PVCs to resize and if customer has multiple resources named exactly the same, but in different namespaces, we will try to resize them all. This fix adds namespace filtering in resizePVCsStorage + more accurate logging when actual resize is requested.

Additionally fixed issues with missing context propagation. These fixes are commented in the PR.

Proof of Work

Updated unit tests that verify resizePVCsStorage logic.

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@github-actions
Copy link

github-actions bot commented Dec 17, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.6.2 Release Notes

Bug Fixes

  • Persistent Volume Claim resize fix: Fixed an issue where the Operator ignored namespaces when listing PVCs, causing conflicts with PVCs of the same name. Now, PVCs are filtered by both name and namespace for accurate resizing.

@MaciejKaras MaciejKaras marked this pull request as ready for review December 17, 2025 15:27
@MaciejKaras MaciejKaras requested review from a team and vinilage as code owners December 17, 2025 15:27
}
}

err = resizePVCsStorage(fakeClient, createStatefulSet("test", "mongodb-test", "30Gi", "30Gi", "20Gi"), zap.S())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you add a comment above this line to explain that we are resizing initialSts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!


log.Infof("Detected PVC size expansion; patching all pvcs and increasing the size for sts: %s", desiredSts.Name)
if err := resizePVCsStorage(memberClient, desiredSts); err != nil {
if err := resizePVCsStorage(ctx, memberClient, desiredSts, log); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resizePVCsStorage() function did not receive parent context, this is fixed now

// Cascade delete the StatefulSet
deletePolicy := metav1.DeletePropagationOrphan
if err := memberClient.Delete(context.TODO(), desiredSts, client.PropagationPolicy(deletePolicy)); err != nil && !apiErrors.IsNotFound(err) {
if err := memberClient.Delete(ctx, desiredSts, client.PropagationPolicy(deletePolicy)); err != nil && !apiErrors.IsNotFound(err) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

memberClient.Delete used background context and not parent context

func resizePVCsStorage(ctx context.Context, kubeClient kubernetesClient.Client, statefulSetToCreate *appsv1.StatefulSet, log *zap.SugaredLogger) error {
// this is to ensure that requests to a potentially not allowed resource is not blocking the operator until the end
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now properly creating a context with timeout from parent context

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants