-
Notifications
You must be signed in to change notification settings - Fork 133
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
Prevent calling controller-expand if volume in-use #86
Prevent calling controller-expand if volume in-use #86
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 |
pkg/controller/controller.go
Outdated
|
||
func (ctrl *resizeController) deletePod(obj interface{}) { | ||
pod := parsePod(obj) | ||
if pod != 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.
Same comment here.
@@ -98,17 +112,38 @@ func NewResizeController( | |||
DeleteFunc: ctrl.deletePVC, | |||
}, resyncPeriod) | |||
|
|||
podInformer.Informer().AddEventHandlerWithResyncPeriod(cache.ResourceEventHandlerFuncs{ |
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 see that the in-tree PVC protection controller also checks the pod. What is the advantage of checking thru the pod vs checking the VolumeAttachment object?
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.
Because not all volume types support attach/detach and hence there may not be an VolumeAttachment object.
pkg/controller/controller.go
Outdated
if ctrl.usedPVCs.hasInUseErrors(pvc) && ctrl.usedPVCs.checkForUse(pvc) { | ||
// Record an event to indicate that resizer is not expanding the pvc | ||
ctrl.eventRecorder.Event(pvc, v1.EventTypeWarning, util.VolumeResizeFailed, | ||
fmt.Sprintf("CSI resizer is not expanding %s because it is in-use", pv.Name)) |
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.
Can you add a message to indicate that the CSI driver only supports offline volume expansion.
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.
pkg/controller/controller.go
Outdated
} | ||
pod, ok := obj.(*v1.Pod) | ||
if !ok { | ||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown) |
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.
Can you pick a different name than "tombstone"?
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.
renamed to staleObj
return false | ||
} | ||
// if this is a failed precondition error then that means driver does not support expansion | ||
// of in-use volumes |
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.
Can you add a comment linking to the CSI spec description about this?
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
1bc70d8
to
38e5ebf
Compare
@xing-yang PTAL. addressed last comments. |
/retest |
pvcInUse: true, | ||
}, | ||
{ | ||
Name: "Resize PVC, no FS resize, pvc-inuse but no failedprecondition error", |
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.
This one should be "with FS resize" as there is no failedprecondition?
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 should not matter. The "FS resize" only decides whether node expansion is pending or not. But since in this case, all we are trying to test is - if a pvc was in-use but has no failedprecondition from before then expansion should proceed as usual.
/lgtm |
If volume can not be expanded when in-use we must not call ControllerExpandVolume until we know volume is not in-use.
Fixes #81