Skip to content

Commit c27e00a

Browse files
committed
e2e: add NFS test for modifying clients via VolumeAttributesClass
Add comprehensive e2e test that verifies the clients parameter can be modified using VolumeAttributesClass. The test: - Creates a volume with restrictive clients (1.1.1.1) - Verifies that an app fails to mount with restrictive settings - Updates the clients parameter via VolumeAttributesClass to allow all clients (0.0.0.0/0) - Verifies that the app successfully mounts after the update The test runs just before the cleanup phase to ensure proper test sequencing. Assisted-by: AskBob <askbob@ibm.com> Signed-off-by: Niels de Vos <ndevos@ibm.com>
1 parent c29354b commit c27e00a

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

e2e/nfs.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,103 @@ var _ = Describe("nfs", func() {
12491249
validateOmapCount(f, 0, cephfsType, metadataPool, volumesType)
12501250
})
12511251

1252+
It("create a storageclass with clients restriction and modify it with VolumeAttributesClass", func() {
1253+
if !k8sVersionGreaterEquals(c, 1, 34) {
1254+
framework.Logf("skipping VolumeAttributesClass test, needs Kubernetes >= 1.34")
1255+
1256+
return
1257+
}
1258+
1259+
// Initial clients list - restrictive (Cloudflare DNS, should fail to mount)
1260+
initialClients := "1.1.1.1"
1261+
// Updated clients list - permissive (allow all clients)
1262+
updatedClients := "0.0.0.0/0"
1263+
1264+
err := createNFSStorageClass(f.ClientSet, f, false, map[string]string{
1265+
"clients": initialClients,
1266+
})
1267+
if err != nil {
1268+
logAndFail("failed to create NFS storageclass: %v", err)
1269+
}
1270+
err = createNFSVolumeAttributesClass(f.ClientSet, f, map[string]string{
1271+
"clients": updatedClients,
1272+
})
1273+
if err != nil {
1274+
logAndFail("failed to create NFS volumeattributesclass: %v", err)
1275+
}
1276+
1277+
pvc, err := loadPVC(pvcPath)
1278+
if err != nil {
1279+
logAndFail("Could not load PVC: %v", err)
1280+
}
1281+
pvc.Namespace = f.UniqueName
1282+
1283+
// Create PVC first without VolumeAttributesClass
1284+
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
1285+
if err != nil {
1286+
logAndFail("failed to create PVC: %v", err)
1287+
}
1288+
1289+
// Verify initial restrictive clients parameter
1290+
if !checkExports(f, "my-nfs", initialClients) {
1291+
logAndFail("failed to verify initial clients in exports")
1292+
}
1293+
1294+
app, err := loadApp(appPath)
1295+
if err != nil {
1296+
logAndFail("failed to load application: %v", err)
1297+
}
1298+
app.Namespace = f.UniqueName
1299+
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
1300+
1301+
// Try to create app with restrictive clients - should fail to reach running state
1302+
err = createApp(f.ClientSet, app, deployTimeout)
1303+
if err == nil {
1304+
logAndFail("app should have failed to start with restrictive clients, but succeeded")
1305+
}
1306+
framework.Logf("app correctly failed to start with restrictive clients: %v", err)
1307+
1308+
// Delete the failed app
1309+
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
1310+
if err != nil {
1311+
logAndFail("failed to delete app: %v", err)
1312+
}
1313+
1314+
// Apply VolumeAttributesClass to PVC to update clients
1315+
vacName := "updated-parameters"
1316+
pvc.Spec.VolumeAttributesClassName = &vacName
1317+
_, err = f.ClientSet.CoreV1().PersistentVolumeClaims(pvc.Namespace).Update(
1318+
context.TODO(), pvc, metav1.UpdateOptions{})
1319+
if err != nil {
1320+
logAndFail("failed to update PVC with VolumeAttributesClass: %v", err)
1321+
}
1322+
1323+
// Now create app again - VolumeAttributesClass should update clients to 0.0.0.0/0
1324+
err = createApp(f.ClientSet, app, deployTimeout)
1325+
if err != nil {
1326+
logAndFail("failed to create application with updated clients: %v", err)
1327+
}
1328+
1329+
// Verify the updated clients parameter is applied
1330+
if !checkExports(f, "my-nfs", updatedClients) {
1331+
logAndFail("failed to verify updated clients in exports")
1332+
}
1333+
1334+
// delete PVC and app
1335+
err = deletePVCAndApp("", f, pvc, app)
1336+
if err != nil {
1337+
logAndFail("failed to delete PVC or application: %v", err)
1338+
}
1339+
err = deleteResource(nfsExamplePath + "storageclass.yaml")
1340+
if err != nil {
1341+
logAndFail("failed to delete NFS storageclass: %v", err)
1342+
}
1343+
err = deleteNFSVolumeAttributesClass(f.ClientSet, f)
1344+
if err != nil {
1345+
logAndFail("failed to delete NFS volumeattributesclass: %v", err)
1346+
}
1347+
})
1348+
12521349
It("delete NFS provisioner and plugin secret", func() {
12531350
// delete nfs provisioner secret
12541351
err := deleteCephUser(f, keyringCephFSProvisionerUsername)

0 commit comments

Comments
 (0)