Skip to content

Commit 520eab7

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#51356 from wongma7/pv-cap-resize
Automatic merge from submit-queue (batch tested with PRs 51441, 51356, 51460) Don't update pvc.status.capacity if pvc is already Bound As discussed here kubernetes/community#657 (comment), in order for `pvc.status.Capacity < pv.Spec.Capcity` to be the mechanism for volume filesystem* resize, the pv controller should stop updating pvc.status.Capacity every resync period. /assign @jsafrane /sig storage ```release-note NONE ```
2 parents 169de99 + 19ebaf2 commit 520eab7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

‎pkg/controller/volume/persistentvolume/pv_controller.go‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,19 @@ func (ctrl *PersistentVolumeController) updateClaimStatus(claim *v1.PersistentVo
626626
dirty = true
627627
}
628628

629-
volumeCap, ok := volume.Spec.Capacity[v1.ResourceStorage]
630-
if !ok {
631-
return nil, fmt.Errorf("PersistentVolume %q is without a storage capacity", volume.Name)
632-
}
633-
claimCap, ok := claim.Status.Capacity[v1.ResourceStorage]
634-
if !ok || volumeCap.Cmp(claimCap) != 0 {
635-
claimClone.Status.Capacity = volume.Spec.Capacity
636-
dirty = true
629+
// Update Capacity if the claim is becoming Bound, not if it was already.
630+
// A discrepancy can be intentional to mean that the PVC filesystem size
631+
// doesn't match the PV block device size, so don't clobber it
632+
if claim.Status.Phase != phase {
633+
volumeCap, ok := volume.Spec.Capacity[v1.ResourceStorage]
634+
if !ok {
635+
return nil, fmt.Errorf("PersistentVolume %q is without a storage capacity", volume.Name)
636+
}
637+
claimCap, ok := claim.Status.Capacity[v1.ResourceStorage]
638+
if !ok || volumeCap.Cmp(claimCap) != 0 {
639+
claimClone.Status.Capacity = volume.Spec.Capacity
640+
dirty = true
641+
}
637642
}
638643
}
639644

0 commit comments

Comments
 (0)