-
Notifications
You must be signed in to change notification settings - Fork 32
HELP-85556 - fix PVC scaling ignoring namespaces #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
MCK 1.6.2 Release NotesBug Fixes
|
| } | ||
| } | ||
|
|
||
| err = resizePVCsStorage(fakeClient, createStatefulSet("test", "mongodb-test", "30Gi", "30Gi", "20Gi"), zap.S()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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
resizePVCsStoragelogic.Checklist
skip-changeloglabel if not needed