-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Use workqueues for volume expansion #77883
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gnufied The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
87352c8
to
7faaf93
Compare
/kind bug |
/sig storage |
cc @kubernetes/sig-storage-misc @jsafrane |
Add a test for patch creation
7faaf93
to
c16a555
Compare
/assign @jsafrane |
/retest |
5e9e087
to
673773c
Compare
lgtm-ish, @msau42, WDYT? |
/retest |
1 similar comment
/retest |
} | ||
expc.recorder.Event(pvc, eventType, events.ExternalExpanding, fmt.Sprintf("Ignoring the PVC: %v.", msg)) | ||
klog.V(3).Infof("Ignoring the PVC %q (uid: %q) : %v.", util.GetPersistentVolumeClaimQualifiedName(pvc), pvc.UID, msg) |
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.
should this be level 3? Seems like a configuration problem if we can't find the plugin?
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.
Any PVC that should be resized externally will hit this code (CSI) and it is not a configuration problem if plugin can't be found. For example - CSI plugin does not actually implement Expandable
interface and only implements NodeExpandable
interface inside k8s.
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.
Do we need to log so high if we know it's an expected normal occurrence?
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.
We could, but in most clusters I hope resizing itself should relatively be less often than other stuff. Logging this at V(3) gives us opportunity to verify if expand_controller did in fact process the PVC. I think of this the way, we log a successful mount event or attach event, even though those events will happen much more often than resize event - we still log them.
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.
It looks like Info logs in the operation generator are using either default info level, or 4. Can we follow the same?
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.
I moved this to Infof
level.
return fmt.Errorf("Unexpected error marshaling new PV %q with error : %v", pvClone.Name, err) | ||
} | ||
|
||
patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldData, newData, pvClone) |
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.
is resource version in this patch?
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.
The PV update is not doing resource version check. I think it is fine, because resource version check is important when you don't want to unconditionally patch a field but is less important when your patch does not depend on more recent version of object.
In this case - getting latest version of PV object isn't going to make a difference. Also since PV is non-namespaced object, users should not be editing them.
572f4d4
to
4886e87
Compare
/lgtm |
/retest Review the full test history for this PR. Silence the bot with an |
} | ||
|
||
oldSize := oldPVC.Spec.Resources.Requests[v1.ResourceStorage] | ||
newPVC, ok := new.(*v1.PersistentVolumeClaim) |
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.
It seems this (including the check on line 133) should be done before obtaining oldSize.
newSize := newPVC.Spec.Resources.Requests[v1.ResourceStorage] | ||
if newSize.Cmp(oldSize) > 0 { | ||
expc.enqueuePVC(new) | ||
} |
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.
Maybe add a log saying why the request is ignored.
Use workqueues for volume expansion. This PR reduces race between volume expansion and other controllers by using resourceVersion match while patching the PVCs.
Fixes #71760 and #71470
This is a rebased and updated version of #75386