Content-Length: 393229 | pFad | http://github.com/kubernetes/kubernetes/pull/131907/files

29 {WIP} Do not expand non expnadable volumes by gnufied · Pull Request #131907 · kubernetes/kubernetes · GitHub
Skip to content

{WIP} Do not expand non expnadable volumes #131907

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkg/volume/util/operationexecutor/node_expander.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -100,9 +101,15 @@ func (ne *NodeExpander) runPreCheck() bool {
ne.pvcAlreadyUpdated = true
}

// PVC is already expanded but we are still trying to expand the volume because
// last recorded size in ASOW is older. This can happen for RWX volume types.
if ne.pvcAlreadyUpdated && storage.ContainsAccessMode(ne.pvc.Spec.AccessModes, v1.ReadWriteMany) {
// if the volume is already expanded, but volume is of type RWX and
// pvc doesn't have annotation indicating that node expansion is not required
// then we should allow node expansion to proceed, even if the volume is already expanded.
//
// This special cases is needed because, in case of RWX volumes, the volume expansion
// should be performed on all nodes, even if the volume is already expanded.
if ne.pvcAlreadyUpdated &&
storage.ContainsAccessMode(ne.pvc.Spec.AccessModes, v1.ReadWriteMany) &&
!metav1.HasAnnotation(ne.pvc.ObjectMeta, volumetypes.NodeExpansionNotRequired) {
return true
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/volume/util/operationexecutor/node_expander_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func TestNodeExpander(t *testing.T) {
nodeResizeFailed := v1.PersistentVolumeClaimNodeResizeInfeasible

nodeResizePending := v1.PersistentVolumeClaimNodeResizePending
// TODO: Add tests that checks return value of expandOnPlugin function
// because that is what is used in actual code.
var tests = []struct {
name string
pvc *v1.PersistentVolumeClaim
Expand Down Expand Up @@ -162,6 +164,18 @@ func TestNodeExpander(t *testing.T) {
expectFinalErrors: false,
expectedStatusSize: resource.MustParse("2G"),
},
{
name: "RWX volumes, pv.spec.cap = pvc.status.cap, resizeStatus='', desiredSize > actualSize, node-expansion-not-required",
pvc: addAnnotation(addAccessMode(getTestPVC("test-vol0", "2G", "2G", "2G", nil), v1.ReadWriteMany), volumetypes.NodeExpansionNotRequired, "true"),
pv: getTestPV("test-vol0", "2G"),
recoverVolumeExpansionFailure: true,

expectedResizeStatus: "",
expectResizeCall: false,
assumeResizeOpAsFinished: true,
expectFinalErrors: false,
expectedStatusSize: resource.MustParse("2G"),
},
{
name: "pv.spec.cap > pvc.status.cap, resizeStatus=node_expansion_pending, featuregate=disabled",
pvc: getTestPVC("test-vol0", "2G", "1G", "2G", &nodeResizePending),
Expand Down
8 changes: 8 additions & 0 deletions pkg/volume/util/operationexecutor/operation_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,14 @@ func addAccessMode(pvc *v1.PersistentVolumeClaim, mode v1.PersistentVolumeAccess
return pvc
}

func addAnnotation(pvc *v1.PersistentVolumeClaim, key, value string) *v1.PersistentVolumeClaim {
if pvc.Annotations == nil {
pvc.Annotations = make(map[string]string)
}
pvc.Annotations[key] = value
return pvc
}

func getTestPV(volumeName string, specSize string) *v1.PersistentVolume {
return &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Expand Down
4 changes: 4 additions & 0 deletions pkg/volume/util/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"k8s.io/mount-utils"
)

var (
NodeExpansionNotRequired = "volume.kubernetes.io/node-expansion-not-required"
)

// UniquePodName defines the type to key pods off of
type UniquePodName types.UID

Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kubernetes/kubernetes/pull/131907/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy