|
7 | 7 | "github.com/kubernetes-csi/external-resizer/pkg/util"
|
8 | 8 | "google.golang.org/grpc/codes"
|
9 | 9 | "google.golang.org/grpc/status"
|
| 10 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
10 | 11 | "k8s.io/client-go/tools/cache"
|
11 | 12 | "testing"
|
12 | 13 | "time"
|
@@ -156,6 +157,25 @@ func TestSyncPVC(t *testing.T) {
|
156 | 157 | pvcWithUncreatedPV := createTestPVC(pvcName, targetVac /*vacName*/, testVac /*curVacName*/, testVac /*targetVacName*/)
|
157 | 158 | pvcWithUncreatedPV.Spec.VolumeName = ""
|
158 | 159 |
|
| 160 | + nonCSIPVC := &v1.PersistentVolumeClaim{ |
| 161 | + ObjectMeta: metav1.ObjectMeta{Name: pvcName, Namespace: pvcNamespace}, |
| 162 | + Spec: v1.PersistentVolumeClaimSpec{ |
| 163 | + VolumeAttributesClassName: &targetVac, |
| 164 | + VolumeName: pvName, |
| 165 | + }, |
| 166 | + Status: v1.PersistentVolumeClaimStatus{ |
| 167 | + Phase: v1.ClaimBound, |
| 168 | + }, |
| 169 | + } |
| 170 | + nonCSIPV := &v1.PersistentVolume{ |
| 171 | + ObjectMeta: metav1.ObjectMeta{ |
| 172 | + Name: pvName, |
| 173 | + }, |
| 174 | + Spec: v1.PersistentVolumeSpec{ |
| 175 | + VolumeAttributesClassName: nil, |
| 176 | + }, |
| 177 | + } |
| 178 | + |
159 | 179 | tests := []struct {
|
160 | 180 | name string
|
161 | 181 | pvc *v1.PersistentVolumeClaim
|
@@ -192,6 +212,12 @@ func TestSyncPVC(t *testing.T) {
|
192 | 212 | pv: basePV,
|
193 | 213 | callCSIModify: false,
|
194 | 214 | },
|
| 215 | + { |
| 216 | + name: "Should NOT modify if PV wasn't provisioned by CSI driver", |
| 217 | + pvc: nonCSIPVC, |
| 218 | + pv: nonCSIPV, |
| 219 | + callCSIModify: false, |
| 220 | + }, |
195 | 221 | }
|
196 | 222 |
|
197 | 223 | for _, test := range tests {
|
|
0 commit comments