Skip to content

Commit

Permalink
rbd: app failing to mount with volumenameprefix
Browse files Browse the repository at this point in the history
Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
  • Loading branch information
riya-singhal31 committed Jul 19, 2023
1 parent 47b79c8 commit b7d749e
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
81 changes: 81 additions & 0 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3099,6 +3099,87 @@ var _ = Describe("RBD", func() {
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
})

By("creating an app with a PVC, using a topology constrained StorageClass with volumenameprefix", func() {
By("checking node has required CSI topology labels set", func() {
err := checkNodeHasLabel(f.ClientSet, nodeCSIRegionLabel, regionValue)
if err != nil {
framework.Failf("failed to check node label: %v", err)
}
err = checkNodeHasLabel(f.ClientSet, nodeCSIZoneLabel, zoneValue)
if err != nil {
framework.Failf("failed to check node label: %v", err)
}
})

By("creating a StorageClass with delayed binding mode and CSI topology parameter")
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
framework.Failf("failed to delete storageclass: %v", err)
}
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"domainSegments\":" +
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
err = createRBDStorageClass(f.ClientSet, f, defaultSCName,
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
map[string]string{
"topologyConstrainedPools": topologyConstraint,
"volumeNamePrefix": "foo-bar-",
}, deletePolicy)
if err != nil {
framework.Failf("failed to create storageclass: %v", err)
}

By("creating an app using a PV from the delayed binding mode StorageClass")
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, 0)
if err != nil {
framework.Failf("failed to create PVC and application: %v", err)
}

By("ensuring created PV has required node selector values populated")
err = checkPVSelectorValuesForPVC(f, pvc)
if err != nil {
framework.Failf("failed to check pv selector values: %v", err)
}
By("ensuring created PV has its image in the topology specific pool")
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
if err != nil {
framework.Failf("failed to check image in pool: %v", err)
}

By("ensuring created PV has its image journal in the topology specific pool")
err = checkPVCImageJournalInPool(f, pvc, rbdTopologyPool)
if err != nil {
framework.Failf("failed to check image journal: %v", err)
}

By("ensuring created PV has its CSI journal in the CSI journal specific pool")
err = checkPVCCSIJournalInPool(f, pvc, "replicapool")
if err != nil {
framework.Failf("failed to check csi journal in pool: %v", err)
}

err = deleteJournalInfoInPool(f, pvc, "replicapool")
if err != nil {
framework.Failf("failed to delete omap data: %v", err)
}
err = deletePVCAndApp("", f, pvc, app)
if err != nil {
framework.Failf("failed to delete PVC and application: %v", err)
}
validateRBDImageCount(f, 0, defaultRBDPool)
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)

err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
framework.Failf("failed to delete storageclass: %v", err)
}

err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
if err != nil {
framework.Failf("failed to create storageclass: %v", err)
}
})

// Mount pvc to pod with invalid mount option,expected that
// mounting will fail
By("Mount pvc to pod with invalid mount option", func() {
Expand Down
4 changes: 4 additions & 0 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ func (cs *ControllerServer) parseVolCreateRequest(

// store topology information from the request
rbdVol.TopologyPools, rbdVol.TopologyRequirement, err = util.GetTopologyFromRequest(req)
volOp := req.GetParameters()
if namePrefix, ok := volOp["volumeNamePrefix"]; ok {
rbdVol.NamePrefix = namePrefix
}
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
Expand Down

0 comments on commit b7d749e

Please sign in to comment.